Skip to content

Commit 59e0170

Browse files
authored
Fix OSS Alpine installation and add Alpine test coverage (#190)
1 parent 16f21c5 commit 59e0170

File tree

11 files changed

+88
-32
lines changed

11 files changed

+88
-32
lines changed

defaults/main.yml

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ nginx_start: true
1111
nginx_debug_output: false
1212

1313
# Supported systems
14-
nginx_linux_families: ['Debian', 'RedHat', 'Suse']
14+
nginx_linux_families: ['Alpine', 'Debian', 'RedHat', 'Suse']
1515
nginx_bsd_systems: ['FreeBSD', 'NetBSD', 'OpenBSD', 'DragonFlyBSD', 'HardenedBSD']
1616

1717
# Specify which type of NGINX you want to install.
@@ -35,24 +35,7 @@ nginx_install_from: nginx_repository
3535
# Specify source repository for NGINX Open Source.
3636
# Only works if 'install_from' is set to 'nginx_repository'.
3737
# Defaults are the official NGINX repositories.
38-
nginx_repository:
39-
alpine: >-
40-
https://nginx.org/packages/{{ (nginx_branch == 'mainline')
41-
| ternary('mainline/', '') }}alpine/v{{ ansible_distribution_version | regex_search('^[0-9]+\\.[0-9]+') }}/main
42-
debian:
43-
- >-
44-
deb https://nginx.org/packages/{{ (nginx_branch == 'mainline')
45-
| ternary('mainline/', '') }}{{ ansible_distribution | lower }}/ {{ ansible_distribution_release }} nginx
46-
- >-
47-
deb-src https://nginx.org/packages/{{ (nginx_branch == 'mainline')
48-
| ternary('mainline/', '') }}{{ ansible_distribution | lower }}/ {{ ansible_distribution_release }} nginx
49-
redhat: >-
50-
https://nginx.org/packages/{{ (nginx_branch == 'mainline')
51-
| ternary('mainline/', '') }}{{ (ansible_distribution == "RedHat")
52-
| ternary('rhel', 'centos') }}/{{ ansible_distribution_major_version }}/$basearch/
53-
suse: >-
54-
https://nginx.org/packages/{{ (nginx_branch == 'mainline')
55-
| ternary('mainline/', '') }}sles/{{ ansible_distribution_major_version }}
38+
# nginx_repository: deb https://nginx.org/packages/mainline/debian/ stretch nginx
5639

5740
# Choose to install BSD packages or ports.
5841
# Options are True for packages or False for ports.

molecule/common/Dockerfile.j2

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ RUN \
3434
&& zypper clean -a; \
3535
elif [ $(command -v apk) ]; then \
3636
apk update \
37-
&& apk add --no-cache python sudo bash ca-certificates; \
37+
&& apk add --no-cache python sudo bash ca-certificates curl openrc; \
38+
echo 'rc_provide="loopback net"' >> /etc/rc.conf; \
3839
elif [ $(command -v xbps-install) ]; then \
3940
xbps-install -Syu \
4041
&& xbps-install -y python sudo bash ca-certificates iproute2 \

molecule/default/molecule.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,18 @@ driver:
44
lint:
55
name: yamllint
66
platforms:
7+
- name: alpine-3.8
8+
image: alpine:3.8
9+
dockerfile: ../common/Dockerfile.j2
10+
command: "/sbin/init"
11+
- name: alpine-3.9
12+
image: alpine:3.9
13+
dockerfile: ../common/Dockerfile.j2
14+
command: "/sbin/init"
15+
- name: alpine-3.10
16+
image: alpine:3.10
17+
dockerfile: ../common/Dockerfile.j2
18+
command: "/sbin/init"
719
- name: centos-6
820
image: centos:6
921
dockerfile: ../common/Dockerfile.j2

molecule/default/playbook.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
- name: Converge
33
hosts: all
44
pre_tasks:
5+
- name: "Set repo if Alpine"
6+
set_fact:
7+
version: "=1.17.6-r1"
8+
when: ansible_os_family == "Alpine"
59
- name: "Set repo if Debian"
610
set_fact:
711
version: "=1.17.6-1~{{ ansible_distribution_release }}"

tasks/keys/apk-key.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
---
2+
- name: "(Install: APK OSs) Set Default APK NGINX Signing Key URL"
3+
set_fact:
4+
default_keysite: https://nginx.org/keys/nginx_signing.rsa.pub
5+
6+
- name: "(Install: APK OSs) Set APK NGINX Signing Key URL"
7+
set_fact:
8+
keysite: "{{ nginx_signing_key | default(default_keysite) }}"
9+
210
- name: "(Install: APK OSs) Download NGINX Signing Key"
311
get_url:
4-
url: https://nginx.org/keys/nginx_signing.rsa.pub
12+
url: "{{ keysite }}"
513
dest: /etc/apk/keys/nginx_signing.rsa.pub

tasks/opensource/install-oss-linux.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
- name: "(Install: Linux) Configure NGINX repo"
33
block:
44

5+
- import_tasks: setup-alpine.yml
6+
when: ansible_os_family == "Alpine"
7+
58
- import_tasks: setup-debian.yml
69
when: ansible_os_family == "Debian"
710

tasks/opensource/setup-alpine.yml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
---
2-
- name: "(Install: Alpine Linux) Add NGINX Plus Repository"
2+
- name: "(Install: Alpine) Set Default APK NGINX Repository"
3+
set_fact:
4+
default_repository: >-
5+
https://nginx.org/packages/{{ (nginx_branch == 'mainline')
6+
| ternary('mainline/', '') }}alpine/v{{ ansible_distribution_version.split('.')[0] }}.{{ ansible_distribution_version.split('.')[1] }}/main
7+
8+
- name: "(Install: Alpine) Set APK NGINX Repository"
9+
set_fact:
10+
repository: "{{ nginx_repository | default(default_repository) }}"
11+
12+
- name: "(Install: Alpine) Add NGINX Repository"
313
lineinfile:
414
path: /etc/apk/repositories
515
insertafter: EOF
6-
line: "{{ nginx_repository.alpine }}"
16+
line: "{{ repository }}"

tasks/opensource/setup-debian.yml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,20 @@
11
---
2+
- name: "(Install: Debian/Ubuntu) Set Default APT NGINX Repository"
3+
set_fact:
4+
default_repository:
5+
- >-
6+
deb https://nginx.org/packages/{{ (nginx_branch == 'mainline')
7+
| ternary('mainline/', '') }}{{ ansible_distribution | lower }}/ {{ ansible_distribution_release }} nginx
8+
- >-
9+
deb-src https://nginx.org/packages/{{ (nginx_branch == 'mainline')
10+
| ternary('mainline/', '') }}{{ ansible_distribution | lower }}/ {{ ansible_distribution_release }} nginx
11+
12+
- name: "(Install: Debian/Ubuntu) Set APT NGINX Repository"
13+
set_fact:
14+
repository: "{{ nginx_repository | default(default_repository) }}"
15+
216
- name: "(Install: Debian/Ubuntu) Add NGINX Repository"
317
apt_repository:
418
repo: "{{ item }}"
519
with_items:
6-
- "{{ nginx_repository.debian }}"
20+
- "{{ repository }}"

tasks/opensource/setup-redhat.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,19 @@
11
---
2+
- name: "(Install: CentOS/RedHat) Set Default YUM NGINX Repository"
3+
set_fact:
4+
default_repository: >-
5+
https://nginx.org/packages/{{ (nginx_branch == 'mainline')
6+
| ternary('mainline/', '') }}{{ (ansible_distribution == "RedHat")
7+
| ternary('rhel', 'centos') }}/{{ ansible_distribution_major_version }}/$basearch/
8+
9+
- name: "(Install: CentOS/RedHat) Set YUM NGINX Repository"
10+
set_fact:
11+
repository: "{{ nginx_repository | default(default_repository) }}"
12+
213
- name: "(Install: CentOS/RedHat) Add NGINX Repository"
314
yum_repository:
415
name: nginx
5-
baseurl: "{{ nginx_repository.redhat }}"
16+
baseurl: "{{ repository }}"
617
description: NGINX Repository
718
enabled: yes
819
gpgcheck: yes

tasks/opensource/setup-suse.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
---
2+
- name: "(Install: SUSE) Set Default SUSE NGINX Repository"
3+
set_fact:
4+
default_repository: >-
5+
https://nginx.org/packages/{{ (nginx_branch == 'mainline')
6+
| ternary('mainline/', '') }}sles/{{ ansible_distribution_major_version }}
7+
8+
- name: "(Install: SUSE) Set SUSE NGINX Repository"
9+
set_fact:
10+
repository: "{{ nginx_repository | default(default_repository) }}"
11+
212
- name: "(Install: SUSE) Add NGINX Repository"
313
zypper_repository:
414
name: "nginx-{{ nginx_branch }}"
5-
repo: "{{ nginx_repository.suse }}"
15+
repo: "{{ repository }}"

0 commit comments

Comments
 (0)