diff --git a/defaults/main.yml b/defaults/main.yml index d1c5d8f..bf8d0c4 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -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. diff --git a/molecule/common/Dockerfile.j2 b/molecule/common/Dockerfile.j2 index bb20dd7..dee58c6 100644 --- a/molecule/common/Dockerfile.j2 +++ b/molecule/common/Dockerfile.j2 @@ -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 \ diff --git a/molecule/default/molecule.yml b/molecule/default/molecule.yml index f66127b..90dbc2b 100644 --- a/molecule/default/molecule.yml +++ b/molecule/default/molecule.yml @@ -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 diff --git a/molecule/default/playbook.yml b/molecule/default/playbook.yml index a434e9c..1f060b8 100644 --- a/molecule/default/playbook.yml +++ b/molecule/default/playbook.yml @@ -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 }}" diff --git a/tasks/keys/apk-key.yml b/tasks/keys/apk-key.yml index bb3ba7a..131634d 100644 --- a/tasks/keys/apk-key.yml +++ b/tasks/keys/apk-key.yml @@ -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 diff --git a/tasks/opensource/install-oss-linux.yml b/tasks/opensource/install-oss-linux.yml index a554d6c..2650b16 100644 --- a/tasks/opensource/install-oss-linux.yml +++ b/tasks/opensource/install-oss-linux.yml @@ -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" diff --git a/tasks/opensource/setup-alpine.yml b/tasks/opensource/setup-alpine.yml index 2942bd0..86e4d00 100644 --- a/tasks/opensource/setup-alpine.yml +++ b/tasks/opensource/setup-alpine.yml @@ -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 }}" diff --git a/tasks/opensource/setup-debian.yml b/tasks/opensource/setup-debian.yml index 2b90dd3..3b6046f 100644 --- a/tasks/opensource/setup-debian.yml +++ b/tasks/opensource/setup-debian.yml @@ -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 }}" diff --git a/tasks/opensource/setup-redhat.yml b/tasks/opensource/setup-redhat.yml index 6e70aff..51364af 100644 --- a/tasks/opensource/setup-redhat.yml +++ b/tasks/opensource/setup-redhat.yml @@ -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 diff --git a/tasks/opensource/setup-suse.yml b/tasks/opensource/setup-suse.yml index f4167b7..a7f9bd3 100644 --- a/tasks/opensource/setup-suse.yml +++ b/tasks/opensource/setup-suse.yml @@ -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 }}" diff --git a/tasks/plus/install-plus.yml b/tasks/plus/install-plus.yml index a78978c..be74eb9 100644 --- a/tasks/plus/install-plus.yml +++ b/tasks/plus/install-plus.yml @@ -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('') }}"