Skip to content

Commit

Permalink
Switch dictionaries to individual variables (#349)
Browse files Browse the repository at this point in the history
  • Loading branch information
alessfg committed Nov 17, 2020
1 parent a11e457 commit 6645e08
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 35 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## 0.18.1 (November 17, 2020)

ENHANCEMENTS:

Switch NGINX keysites and OSS default repository data from a dictionary to individual variables to prevent potential issues arisen from Jinja2 dictionary run-time evaluations.

## 0.18.0 (November 13, 2020)

BREAKING CHANGES:
Expand Down
4 changes: 2 additions & 2 deletions tasks/keys/setup-keys.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
block:
- name: (Alpine Linux) Set up NGINX signing key URL
set_fact:
keysite: "{{ nginx_signing_key | default(nginx_default_signing_key['rsa_pub']) }}"
keysite: "{{ nginx_signing_key | default(nginx_default_signing_key_rsa_pub) }}"

- name: (Alpine Linux) Download NGINX signing key
get_url:
Expand All @@ -14,7 +14,7 @@

- name: (Debian/Red Hat/SLES OSs) Set up NGINX signing key URL
set_fact:
keysite: "{{ nginx_signing_key | default(nginx_default_signing_key['pgp']) }}"
keysite: "{{ nginx_signing_key | default(nginx_default_signing_key_pgp) }}"
when: ansible_facts['os_family'] != "Alpine"

- name: (Debian/Ubuntu) Add NGINX signing key
Expand Down
4 changes: 2 additions & 2 deletions tasks/opensource/install-alpine.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
lineinfile:
path: /etc/apk/repositories
insertafter: EOF
line: "{{ repository }}"
line: "{{ nginx_repository | default(nginx_default_repository_alpine) }}"

- name: (Alpine Linux) Install NGINX
apk:
name: "nginx{{ nginx_version | default('') }}"
repository: "{{ repository }}"
repository: "{{ nginx_repository | default(nginx_default_repository_alpine) }}"
state: "{{ nginx_state }}"
update_cache: yes
ignore_errors: "{{ ansible_check_mode }}"
Expand Down
2 changes: 1 addition & 1 deletion tasks/opensource/install-debian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
repo: "{{ item }}"
update_cache: yes
mode: 0644
loop: "{{ repository }}"
loop: "{{ nginx_repository | default(nginx_default_repository_debian) }}"

- name: (Debian/Ubuntu) Install NGINX
apt:
Expand Down
8 changes: 1 addition & 7 deletions tasks/opensource/install-oss.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,7 @@
- name: Install NGINX in Linux systems
block:
- name: Install NGINX from repository
block:
- name: Set NGINX repository
set_fact:
repository: "{{ nginx_repository | default(nginx_default_repository[ansible_facts['os_family'] | lower]) }}"

- name: Install NGINX from repository
include_tasks: "{{ role_path }}/tasks/opensource/install-{{ ansible_facts['os_family'] | lower }}.yml"
include_tasks: "{{ role_path }}/tasks/opensource/install-{{ ansible_facts['os_family'] | lower }}.yml"
when: nginx_install_from == "nginx_repository"

- name: Install NGINX from source
Expand Down
4 changes: 2 additions & 2 deletions tasks/opensource/install-redhat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
- name: (CentOS/RHEL 6/7) Configure NGINX repository
yum_repository:
name: nginx
baseurl: "{{ repository }}"
baseurl: "{{ nginx_repository | default(nginx_default_repository_redhat) }}"
description: NGINX Repository
enabled: yes
gpgcheck: yes
Expand All @@ -15,7 +15,7 @@
create: yes
block: |
[nginx]
baseurl = {{ repository }}
baseurl = {{ nginx_repository | default(nginx_default_repository_redhat) }}
enabled = 1
gpgcheck = 1
name = NGINX Repository
Expand Down
2 changes: 1 addition & 1 deletion tasks/opensource/install-suse.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
- name: (SLES) Configure NGINX repository
zypper_repository:
name: "nginx-{{ nginx_branch }}"
repo: "{{ repository }}"
repo: "{{ nginx_repository | default(nginx_default_repository_suse) }}"

- name: (SLES) Install NGINX
zypper:
Expand Down
2 changes: 1 addition & 1 deletion tasks/plus/install-suse.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
- name: (SLES) {{ nginx_license_status is defined | ternary('Remove', 'Configure') }} NGINX Plus repository
zypper_repository:
name: nginx-plus
repo: "{{ nginx_repository | default(nginx_plus_default_repository_sles) }}"
repo: "{{ nginx_repository | default(nginx_plus_default_repository_suse) }}"
state: "{{ nginx_license_status | default ('present') }}"

- name: (SLES) Install NGINX Plus
Expand Down
36 changes: 17 additions & 19 deletions vars/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,34 +13,32 @@ nginx_plus_distributions: [
]

# Default NGINX signing key
nginx_default_signing_key:
rsa_pub: https://nginx.org/keys/nginx_signing.rsa.pub
pgp: https://nginx.org/keys/nginx_signing.key
nginx_default_signing_key_rsa_pub: https://nginx.org/keys/nginx_signing.rsa.pub
nginx_default_signing_key_pgp: https://nginx.org/keys/nginx_signing.key

# Default NGINX Open Source repositories
nginx_default_repository:
alpine: "https://nginx.org/packages/{{ (nginx_branch == 'mainline')
| ternary('mainline/', '') }}alpine/v{{ ansible_facts['distribution_version'] | regex_search('^[0-9]+\\.[0-9]+') }}/main"
debian:
- "deb [arch=amd64] https://nginx.org/packages/{{ (nginx_branch == 'mainline')
| ternary('mainline/', '') }}{{ ansible_facts['distribution'] | lower }}/ {{ ansible_facts['distribution_release'] }} nginx"
- "deb-src https://nginx.org/packages/{{ (nginx_branch == 'mainline')
| ternary('mainline/', '') }}{{ ansible_facts['distribution'] | lower }}/ {{ ansible_facts['distribution_release'] }} nginx"
redhat: "https://nginx.org/packages/{{ (nginx_branch == 'mainline')
| ternary('mainline/', '') }}{{ (ansible_facts['distribution'] == 'CentOS')
| ternary('centos', 'rhel') }}/{{ ansible_facts['distribution_major_version'] }}/$basearch/"
suse: "https://nginx.org/packages/{{ (nginx_branch == 'mainline')
| ternary('mainline/', '') }}sles/{{ ansible_facts['distribution_major_version'] }}"
nginx_default_repository_alpine: "https://nginx.org/packages/{{ (nginx_branch == 'mainline') | ternary('mainline/', '') }}\
alpine/v{{ ansible_facts['distribution_version'] | regex_search('^[0-9]+\\.[0-9]+') }}/main"
nginx_default_repository_debian:
- "deb [arch=amd64] https://nginx.org/packages/{{ (nginx_branch == 'mainline') | ternary('mainline/', '') }}\
{{ ansible_facts['distribution'] | lower }}/ {{ ansible_facts['distribution_release'] }} nginx"
- "deb-src https://nginx.org/packages/{{ (nginx_branch == 'mainline') | ternary('mainline/', '') }}\
{{ ansible_facts['distribution'] | lower }}/ {{ ansible_facts['distribution_release'] }} nginx"
nginx_default_repository_redhat: "https://nginx.org/packages/{{ (nginx_branch == 'mainline') | ternary('mainline/', '') }}\
{{ (ansible_facts['distribution'] == 'CentOS') | ternary('centos', 'rhel') }}/\
{{ ansible_facts['distribution_major_version'] }}/$basearch/"
nginx_default_repository_suse: "https://nginx.org/packages/{{ (nginx_branch == 'mainline') | ternary('mainline/', '') }}\
sles/{{ ansible_facts['distribution_major_version'] }}"

# Default NGINX Plus repositories
nginx_plus_default_repository_alpine: "https://plus-pkgs.nginx.com/alpine/v{{ ansible_facts['distribution_version'] | regex_search('^[0-9]+\\.[0-9]+') }}/main"
nginx_plus_default_repository_amazon: "https://plus-pkgs.nginx.com/amzn{{ (ansible_facts['distribution_major_version'] is version('2', '==')) | ternary('2', '') }}/$releasever/$basearch"
nginx_plus_default_repository_debian: "deb [arch=amd64] https://plus-pkgs.nginx.com/{{ ansible_facts['distribution'] | lower }} {{ ansible_facts['distribution_release'] }} nginx-plus"
nginx_plus_default_repository_freebsd: "https://plus-pkgs.nginx.com/freebsd/${ABI}/latest"
nginx_plus_default_repository_redhat: "https://plus-pkgs.nginx.com/{{ (ansible_facts['distribution'] == 'CentOS')
| ternary('centos', 'rhel') }}/{{ (ansible_facts['distribution_version'] is version('7.4', '>=')
nginx_plus_default_repository_redhat: "https://plus-pkgs.nginx.com/{{ (ansible_facts['distribution'] == 'CentOS') | ternary('centos', 'rhel') }}/\
{{ (ansible_facts['distribution_version'] is version('7.4', '>=')
and ansible_facts['distribution_version'] is version('8', '<')) | ternary('7.4', ansible_facts['distribution_major_version']) }}/$basearch/"
nginx_plus_default_repository_sles: "https://plus-pkgs.nginx.com/sles/{{ ansible_facts['distribution_major_version'] }}\
nginx_plus_default_repository_suse: "https://plus-pkgs.nginx.com/sles/{{ ansible_facts['distribution_major_version'] }}\
?ssl_clientcert=/etc/ssl/nginx/nginx-repo-bundle.crt&ssl_verify=peer"

# Alpine dependencies
Expand Down

0 comments on commit 6645e08

Please sign in to comment.