Fix OSS Alpine installation and add Alpine test coverage (#190)

This commit is contained in:
Alessandro Fael Garcia 2019-11-22 15:52:34 +01:00 committed by GitHub
parent 16f21c5c7c
commit 59e0170313
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 88 additions and 32 deletions

View File

@ -11,7 +11,7 @@ nginx_start: true
nginx_debug_output: false
# Supported systems
nginx_linux_families: ['Debian', 'RedHat', 'Suse']
nginx_linux_families: ['Alpine', 'Debian', 'RedHat', 'Suse']
nginx_bsd_systems: ['FreeBSD', 'NetBSD', 'OpenBSD', 'DragonFlyBSD', 'HardenedBSD']
# Specify which type of NGINX you want to install.
@ -35,24 +35,7 @@ nginx_install_from: nginx_repository
# Specify source repository for NGINX Open Source.
# Only works if 'install_from' is set to 'nginx_repository'.
# Defaults are the official NGINX repositories.
nginx_repository:
alpine: >-
https://nginx.org/packages/{{ (nginx_branch == 'mainline')
| ternary('mainline/', '') }}alpine/v{{ ansible_distribution_version | regex_search('^[0-9]+\\.[0-9]+') }}/main
debian:
- >-
deb https://nginx.org/packages/{{ (nginx_branch == 'mainline')
| ternary('mainline/', '') }}{{ ansible_distribution | lower }}/ {{ ansible_distribution_release }} nginx
- >-
deb-src https://nginx.org/packages/{{ (nginx_branch == 'mainline')
| ternary('mainline/', '') }}{{ ansible_distribution | lower }}/ {{ ansible_distribution_release }} nginx
redhat: >-
https://nginx.org/packages/{{ (nginx_branch == 'mainline')
| ternary('mainline/', '') }}{{ (ansible_distribution == "RedHat")
| ternary('rhel', 'centos') }}/{{ ansible_distribution_major_version }}/$basearch/
suse: >-
https://nginx.org/packages/{{ (nginx_branch == 'mainline')
| ternary('mainline/', '') }}sles/{{ ansible_distribution_major_version }}
# nginx_repository: deb https://nginx.org/packages/mainline/debian/ stretch nginx
# Choose to install BSD packages or ports.
# Options are True for packages or False for ports.

View File

@ -34,7 +34,8 @@ RUN \
&& zypper clean -a; \
elif [ $(command -v apk) ]; then \
apk update \
&& apk add --no-cache python sudo bash ca-certificates; \
&& apk add --no-cache python sudo bash ca-certificates curl openrc; \
echo 'rc_provide="loopback net"' >> /etc/rc.conf; \
elif [ $(command -v xbps-install) ]; then \
xbps-install -Syu \
&& xbps-install -y python sudo bash ca-certificates iproute2 \

View File

@ -4,6 +4,18 @@ driver:
lint:
name: yamllint
platforms:
- name: alpine-3.8
image: alpine:3.8
dockerfile: ../common/Dockerfile.j2
command: "/sbin/init"
- name: alpine-3.9
image: alpine:3.9
dockerfile: ../common/Dockerfile.j2
command: "/sbin/init"
- name: alpine-3.10
image: alpine:3.10
dockerfile: ../common/Dockerfile.j2
command: "/sbin/init"
- name: centos-6
image: centos:6
dockerfile: ../common/Dockerfile.j2

View File

@ -2,6 +2,10 @@
- name: Converge
hosts: all
pre_tasks:
- name: "Set repo if Alpine"
set_fact:
version: "=1.17.6-r1"
when: ansible_os_family == "Alpine"
- name: "Set repo if Debian"
set_fact:
version: "=1.17.6-1~{{ ansible_distribution_release }}"

View File

@ -1,5 +1,13 @@
---
- name: "(Install: APK OSs) Set Default APK NGINX Signing Key URL"
set_fact:
default_keysite: https://nginx.org/keys/nginx_signing.rsa.pub
- name: "(Install: APK OSs) Set APK NGINX Signing Key URL"
set_fact:
keysite: "{{ nginx_signing_key | default(default_keysite) }}"
- name: "(Install: APK OSs) Download NGINX Signing Key"
get_url:
url: https://nginx.org/keys/nginx_signing.rsa.pub
url: "{{ keysite }}"
dest: /etc/apk/keys/nginx_signing.rsa.pub

View File

@ -2,6 +2,9 @@
- name: "(Install: Linux) Configure NGINX repo"
block:
- import_tasks: setup-alpine.yml
when: ansible_os_family == "Alpine"
- import_tasks: setup-debian.yml
when: ansible_os_family == "Debian"

View File

@ -1,6 +1,16 @@
---
- name: "(Install: Alpine Linux) Add NGINX Plus Repository"
- name: "(Install: Alpine) Set Default APK NGINX Repository"
set_fact:
default_repository: >-
https://nginx.org/packages/{{ (nginx_branch == 'mainline')
| ternary('mainline/', '') }}alpine/v{{ ansible_distribution_version.split('.')[0] }}.{{ ansible_distribution_version.split('.')[1] }}/main
- name: "(Install: Alpine) Set APK NGINX Repository"
set_fact:
repository: "{{ nginx_repository | default(default_repository) }}"
- name: "(Install: Alpine) Add NGINX Repository"
lineinfile:
path: /etc/apk/repositories
insertafter: EOF
line: "{{ nginx_repository.alpine }}"
line: "{{ repository }}"

View File

@ -1,6 +1,20 @@
---
- name: "(Install: Debian/Ubuntu) Set Default APT NGINX Repository"
set_fact:
default_repository:
- >-
deb https://nginx.org/packages/{{ (nginx_branch == 'mainline')
| ternary('mainline/', '') }}{{ ansible_distribution | lower }}/ {{ ansible_distribution_release }} nginx
- >-
deb-src https://nginx.org/packages/{{ (nginx_branch == 'mainline')
| ternary('mainline/', '') }}{{ ansible_distribution | lower }}/ {{ ansible_distribution_release }} nginx
- name: "(Install: Debian/Ubuntu) Set APT NGINX Repository"
set_fact:
repository: "{{ nginx_repository | default(default_repository) }}"
- name: "(Install: Debian/Ubuntu) Add NGINX Repository"
apt_repository:
repo: "{{ item }}"
with_items:
- "{{ nginx_repository.debian }}"
- "{{ repository }}"

View File

@ -1,8 +1,19 @@
---
- name: "(Install: CentOS/RedHat) Set Default YUM NGINX Repository"
set_fact:
default_repository: >-
https://nginx.org/packages/{{ (nginx_branch == 'mainline')
| ternary('mainline/', '') }}{{ (ansible_distribution == "RedHat")
| ternary('rhel', 'centos') }}/{{ ansible_distribution_major_version }}/$basearch/
- name: "(Install: CentOS/RedHat) Set YUM NGINX Repository"
set_fact:
repository: "{{ nginx_repository | default(default_repository) }}"
- name: "(Install: CentOS/RedHat) Add NGINX Repository"
yum_repository:
name: nginx
baseurl: "{{ nginx_repository.redhat }}"
baseurl: "{{ repository }}"
description: NGINX Repository
enabled: yes
gpgcheck: yes

View File

@ -1,5 +1,15 @@
---
- name: "(Install: SUSE) Set Default SUSE NGINX Repository"
set_fact:
default_repository: >-
https://nginx.org/packages/{{ (nginx_branch == 'mainline')
| ternary('mainline/', '') }}sles/{{ ansible_distribution_major_version }}
- name: "(Install: SUSE) Set SUSE NGINX Repository"
set_fact:
repository: "{{ nginx_repository | default(default_repository) }}"
- name: "(Install: SUSE) Add NGINX Repository"
zypper_repository:
name: "nginx-{{ nginx_branch }}"
repo: "{{ nginx_repository.suse }}"
repo: "{{ repository }}"

View File

@ -1,21 +1,21 @@
---
- import_tasks: setup-license.yml
- import_tasks: setup-alpine.yml
when: ansible_os_family == "Alpine"
- import_tasks: setup-debian.yml
when: ansible_os_family == "Debian"
- import_tasks: setup-freebsd.yml
when: ansible_os_family == "FreeBSD"
- import_tasks: setup-redhat.yml
when: ansible_os_family == "RedHat"
- import_tasks: setup-suse.yml
when: ansible_os_family == "Suse"
- import_tasks: setup-freebsd.yml
when: ansible_os_family == "FreeBSD"
- import_tasks: setup-alpine.yml
when: ansible_os_family == "Alpine"
- name: "(Install: All OSs) Install NGINX Plus"
package:
name: "nginx-plus{{ nginx_version | default('') }}"