Skip to content

Commit bf2916f

Browse files
authored
Update Ansible to 2.9.12 and explicitly set mode on relevant tasks (#309)
* Explicitly define `mode` in relevant tasks. * Explicitly define the `nginx` `apt_repository` filename in Debian based distros. * Building OpenSSL from source should now work properly in CentOS 8.
1 parent 79ddc30 commit bf2916f

30 files changed

+173
-94
lines changed

.travis.yml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,17 @@ jobs:
5757
- name: "(CentOS) Install from Source"
5858
env:
5959
scenario: source_centos
60-
before_install: sudo apt-get -qq update
60+
before_install:
61+
- curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
62+
- sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
63+
- sudo apt-get update
64+
- sudo apt-get -y -o Dpkg::Options::="--force-confnew" install docker-ce
6165
install:
62-
- pip install ansible==2.9.11
63-
- pip install molecule==3.0.6
64-
- pip install docker==4.2.2
65-
- pip install ansible-lint==4.2.0
66+
- pip install ansible==2.9.12
67+
- pip install ansible-lint==4.3.2
68+
- pip install molecule==3.0.8
69+
- pip install docker==4.3.1
6670
script:
67-
- molecule --version
68-
- ansible --version
6971
- travis_wait 50 molecule test -s $scenario
7072
notifications:
7173
webhooks: https://galaxy.ansible.com/api/v1/notifications/

CHANGELOG.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,25 @@
11
# Changelog
22

3+
## 0.16.0 (August 28, 2020)
4+
5+
BREAKING CHANGES:
6+
7+
* The Debian and Ubuntu repositories have slightly changed. You may run into some duplication issues when running the role on a preexisting target that already has had NGINX installed using the role. To fix this, manually remove the old repository source.
8+
9+
ENHANCEMENTS:
10+
11+
* Update Ansible to `2.9.12` and Ansible Lint to `4.3.2`.
12+
* Explicitly define `mode` in relevant tasks.
13+
* Explicitly define the `nginx` `apt_repository` filename in Debian based distros.
14+
15+
FEATURES:
16+
17+
* TravisCI now always uses the latest version of Docker.
18+
19+
BUG FIXES:
20+
21+
* Building OpenSSL from source should now work properly in CentOS 8.
22+
323
## 0.15.0 (August 20, 2020)
424

525
DEPRECATION WARNING:

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ This role installs NGINX Open Source, NGINX Plus, the NGINX Amplify agent, or NG
99
**Note:** This role is still in active development. There may be unidentified issues and the role variables may change as development continues.
1010

1111
**Deprecation Warnings:**
12-
* There now is a separate role to manage and create NGINX configurations available [here](https://github.com/nginxinc/ansible-role-nginx-config). Any new issues or PRs related to configuring NGINX should be submitted in the new NGINX Config repository. New issues or PRs related to configuring NGINX submitted in this repository will not be worked on. The NGINX configuration functionalities included in this role will be removed in an upcoming release.
13-
* NGINX Unit now has a separate role available [here](https://github.com/nginxinc/ansible-role-nginx-unit). Any new issues or PRs related to NGINX Unit should be submitted in the new NGINX Unit repository. New issues or PRs related to NGINX Unit submitted in this repository will not be worked on. The NGINX Unit functionalities included in this role will be removed in an upcoming release.
12+
13+
* There now is a separate role to manage and create NGINX configurations available [here](https://github.com/nginxinc/ansible-role-nginx-config). Any new issues or PRs related to configuring NGINX should be submitted in the new NGINX Config repository. New issues or PRs related to configuring NGINX submitted in this repository will not be worked on (with the exception of major bugfixes). The NGINX configuration functionalities included in this role will be removed in an upcoming release.
14+
* NGINX Unit now has a separate role available [here](https://github.com/nginxinc/ansible-role-nginx-unit). Any new issues or PRs related to NGINX Unit should be submitted in the new NGINX Unit repository. New issues or PRs related to NGINX Unit submitted in this repository will not be worked on (with the exception of major bugfixes). The NGINX Unit functionalities included in this role will be removed in an upcoming release.
1415

1516
Requirements
1617
------------

defaults/main/linux.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ nginx_linux_families: ['Alpine', 'Debian', 'RedHat', 'Suse']
88
nginx_plus_linux_families: ['Alpine', 'Debian', 'RedHat', 'Suse']
99

1010
# Default locations and versions when 'nginx_install_from; is set to 'source'
11-
pcre_version: pcre-8.43
11+
pcre_version: pcre-8.44
1212
zlib_version: zlib-1.2.11
13-
openssl_version: openssl-1.1.1c
13+
openssl_version: openssl-1.1.1g

handlers/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
changed_when: false
2323
when:
2424
- nginx_start | bool
25-
- not ansible_check_mode
25+
- not ansible_check_mode | bool
2626

2727
- name: "(Handler: All OSs) Start NGINX Amplify Agent"
2828
service:

molecule/common/playbooks/module_verify.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,6 @@
2121
- name: Check default.conf does not exist
2222
stat:
2323
path: /etc/nginx/conf.d/default.conf
24+
check_mode: yes
2425
register: stat_result
2526
failed_when: stat_result.stat.exists

molecule/common/playbooks/stable_push_verify.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
- name: Check default.conf exists
2727
stat:
2828
path: /etc/nginx/conf.d/default.conf
29+
check_mode: yes
2930
register: stat_result
3031
failed_when: not stat_result.stat.exists
3132

molecule/common/playbooks/template_converge.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
include_role:
77
name: ansible-role-nginx
88
vars:
9-
nginx_debug_output: true
9+
# nginx_debug_output: true
1010

1111
nginx_service_modify: true
1212
nginx_service_timeout: 95

molecule/common/playbooks/template_verify.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,21 @@
2626
- name: Check default.conf exists
2727
stat:
2828
path: /etc/nginx/conf.d/default.conf
29+
check_mode: yes
2930
register: stat_result
3031
failed_when: not stat_result.stat.exists
3132

3233
- name: Check frontend_default.conf exists
3334
stat:
3435
path: /etc/nginx/conf.d/frontend_default.conf
36+
check_mode: yes
3537
register: stat_result
3638
failed_when: not stat_result.stat.exists
3739

3840
- name: Check backend_default.conf exists
3941
stat:
4042
path: /etc/nginx/conf.d/backend_default.conf
43+
check_mode: yes
4144
register: stat_result
4245
failed_when: not stat_result.stat.exists
4346

tasks/amplify/install-amplify.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
remote_src: yes
1515
src: /etc/amplify-agent/agent.conf.default
1616
dest: /etc/amplify-agent/agent.conf
17+
mode: 0644
1718

1819
- name: "(Setup: All OSs) Configure NGINX Amplify Agent API Key"
1920
lineinfile:

tasks/amplify/setup-debian.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,14 @@
33
apt_repository:
44
filename: nginx-amplify
55
repo: deb [arch=amd64] http://packages.amplify.nginx.com/{{ ansible_distribution|lower }}/ {{ ansible_distribution_release|lower }} amplify-agent
6+
update_cache: yes
7+
mode: 0644
68
when: ansible_distribution_release != "focal"
79

810
- name: "(Install: Debian/Ubuntu) Add NGINX Amplify Agent Repository"
911
apt_repository:
1012
filename: nginx-amplify
1113
repo: deb [arch=amd64] https://packages.amplify.nginx.com/py3/ubuntu focal amplify-agent
14+
update_cache: yes
15+
mode: 0644
1216
when: ansible_distribution_release == "focal"

tasks/amplify/setup-redhat.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@
66
description: NGINX Amplify Agent
77
enabled: yes
88
gpgcheck: yes
9+
mode: 0644

tasks/conf/logrotate.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,5 @@
3131
template:
3232
src: "logrotate/nginx.j2"
3333
dest: "/etc/logrotate.d/nginx"
34+
mode: 0644
3435
notify: "(Config: All OSs) Run Logrotate"

tasks/conf/template-config.yml

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
file:
44
path: "{{ item.value.html_file_location | default('/usr/share/nginx/html') }}"
55
state: directory
6+
mode: 0755
67
with_dict: "{{ nginx_html_demo_template }}"
78
when: nginx_html_demo_template_enable | bool
89

@@ -11,27 +12,31 @@
1112
src: "{{ item.value.template_file | default('www/index.html.j2') }}"
1213
dest: "{{ item.value.html_file_location | default('/usr/share/nginx/html') }}/{{ item.value.html_file_name | default('index.html') }}"
1314
backup: yes
15+
mode: 0644
1416
with_dict: "{{ nginx_html_demo_template }}"
1517
when: nginx_html_demo_template_enable | bool
1618

1719
- name: "(Setup: All NGINX) Ensure NGINX Main Directory Exists"
1820
file:
1921
path: "{{ nginx_main_template.conf_file_location | default('/etc/nginx') }}"
2022
state: directory
23+
mode: 0755
2124
when: nginx_main_template_enable | bool
2225

2326
- name: "(Setup: All NGINX) Dynamically Generate NGINX Main Configuration File"
2427
template:
2528
src: "{{ nginx_main_template.template_file | default('nginx.conf.j2') }}"
2629
dest: "{{ nginx_main_template.conf_file_location | default('/etc/nginx') }}/{{ nginx_main_template.conf_file_name | default('nginx.conf') }}"
2730
backup: yes
31+
mode: 0644
2832
when: nginx_main_template_enable | bool
2933
notify: "(Handler: All OSs) Reload NGINX"
3034

3135
- name: "(Setup: All NGINX) Ensure NGINX HTTP Directory Exists"
3236
file:
3337
path: "{{ item.value.conf_file_location | default('/etc/nginx/conf.d/') }}"
3438
state: directory
39+
mode: 0755
3540
with_dict: "{{ nginx_http_template }}"
3641
when: nginx_http_template_enable | bool
3742

@@ -40,6 +45,7 @@
4045
path: "{{ item.1.path }}"
4146
state: directory
4247
owner: "{{ nginx_main_template.user | default('nginx') }}"
48+
mode: 0755
4349
with_subelements:
4450
- "{{ nginx_http_template }}"
4551
- proxy_cache.proxy_cache_path
@@ -51,6 +57,7 @@
5157
src: "{{ item.value.template_file | default('http/default.conf.j2') }}"
5258
dest: "{{ item.value.conf_file_location | default('/etc/nginx/conf.d/') }}/{{ item.value.conf_file_name | default('default.conf') }}"
5359
backup: yes
60+
mode: 0644
5461
with_dict: "{{ nginx_http_template }}"
5562
when: nginx_http_template_enable | bool
5663
notify: "(Handler: All OSs) Reload NGINX"
@@ -60,21 +67,24 @@
6067
src: "{{ nginx_status_template_file | default('http/status.conf.j2') }}"
6168
dest: "{{ nginx_status_file_location | default('/etc/nginx/conf.d/status.conf') }}"
6269
backup: yes
63-
notify: "(Handler: All OSs) Reload NGINX"
70+
mode: 0644
6471
when: nginx_status_enable | bool
72+
notify: "(Handler: All OSs) Reload NGINX"
6573

6674
- name: "(Setup: All NGINX) Dynamically Generate NGINX API Configuration File"
6775
template:
6876
src: "{{ nginx_rest_api_template_file | default('http/api.conf.j2') }}"
6977
dest: "{{ nginx_rest_api_file_location | default('/etc/nginx/conf.d/api.conf') }}"
7078
backup: yes
71-
notify: "(Handler: All OSs) Reload NGINX"
79+
mode: 0644
7280
when: nginx_rest_api_enable | bool
81+
notify: "(Handler: All OSs) Reload NGINX"
7382

7483
- name: "(Setup: All NGINX) Ensure NGINX Stream Directory Exists"
7584
file:
7685
path: "{{ item.value.conf_file_location | default('/etc/nginx/conf.d/stream/') }}"
7786
state: directory
87+
mode: 0755
7888
with_dict: "{{ nginx_stream_template }}"
7989
when: nginx_stream_template_enable | bool
8090

@@ -83,6 +93,7 @@
8393
src: "{{ item.value.template_file | default('stream/default.conf.j2') }}"
8494
dest: "{{ item.value.conf_file_location | default('/etc/nginx/conf.d/stream/') }}/{{ item.value.conf_file_name | default('default.conf') }}"
8595
backup: yes
96+
mode: 0644
8697
with_dict: "{{ nginx_stream_template }}"
87-
notify: "(Handler: All OSs) Reload NGINX"
8898
when: nginx_stream_template_enable | bool
99+
notify: "(Handler: All OSs) Reload NGINX"

tasks/conf/upload-config.yml

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,50 @@
11
---
2+
- name: "(Setup: All NGINX) Ensure NGINX HTML Directory Exists"
3+
file:
4+
path: "{{ nginx_html_upload_dest | default('/usr/share/nginx/html') }}"
5+
state: directory
6+
mode: 0755
7+
when: nginx_html_upload_enable | bool
8+
9+
- name: "(Setup: All NGINX) Upload NGINX HTML Files"
10+
copy:
11+
src: "{{ item }}"
12+
dest: "{{ nginx_html_upload_dest | default('/usr/share/nginx/html') }}"
13+
backup: yes
14+
mode: 0644
15+
with_fileglob: "{{ nginx_html_upload_src }}"
16+
when: nginx_html_upload_enable | bool
17+
notify: "(Handler: All OSs) Reload NGINX"
18+
219
- name: "(Setup: All NGINX) Ensure NGINX Main Directory Exists"
320
file:
421
path: "{{ nginx_main_upload_dest | default('/etc/nginx/') }}"
522
state: directory
23+
mode: 0755
624
when: nginx_main_upload_enable | bool
725

826
- name: "(Setup: All NGINX) Upload NGINX Main Configuration File"
927
copy:
1028
src: "{{ nginx_main_upload_src | default('conf/nginx.conf') }}"
1129
dest: "{{ nginx_main_upload_dest | default('/etc/nginx/') }}"
1230
backup: yes
31+
mode: 0644
1332
when: nginx_main_upload_enable | bool
1433
notify: "(Handler: All OSs) Reload NGINX"
1534

1635
- name: "(Setup: All NGINX) Ensure NGINX HTTP Directory Exists"
1736
file:
1837
path: "{{ nginx_http_upload_dest | default('/etc/nginx/conf.d/') }}"
1938
state: directory
39+
mode: 0755
2040
when: nginx_http_upload_enable | bool
2141

2242
- name: "(Setup: All NGINX) Upload NGINX HTTP Configuration Files"
2343
copy:
2444
src: "{{ item }}"
2545
dest: "{{ nginx_http_upload_dest | default('/etc/nginx/conf.d/') }}"
2646
backup: yes
47+
mode: 0644
2748
with_fileglob: "{{ nginx_http_upload_src }}"
2849
when: nginx_http_upload_enable | bool
2950
notify: "(Handler: All OSs) Reload NGINX"
@@ -32,61 +53,50 @@
3253
file:
3354
path: "{{ nginx_stream_upload_dest | default('/etc/nginx/conf.d/') }}"
3455
state: directory
56+
mode: 0755
3557
when: nginx_stream_upload_enable | bool
3658

3759
- name: "(Setup: All NGINX) Upload NGINX Stream Configuration Files"
3860
copy:
3961
src: "{{ item }}"
4062
dest: "{{ nginx_stream_upload_dest | default('/etc/nginx/conf.d/') }}"
4163
backup: yes
64+
mode: 0644
4265
with_fileglob: "{{ nginx_stream_upload_src }}"
4366
when: nginx_stream_upload_enable | bool
4467
notify: "(Handler: All OSs) Reload NGINX"
4568

46-
- name: "(Setup: All NGINX) Ensure NGINX HTML Directory Exists"
47-
file:
48-
path: "{{ nginx_html_upload_dest | default('/usr/share/nginx/html') }}"
49-
state: directory
50-
when: nginx_html_upload_enable | bool
51-
52-
- name: "(Setup: All NGINX) Upload NGINX HTML Files"
53-
copy:
54-
src: "{{ item }}"
55-
dest: "{{ nginx_html_upload_dest | default('/usr/share/nginx/html') }}"
56-
backup: yes
57-
with_fileglob: "{{ nginx_html_upload_src }}"
58-
when: nginx_html_upload_enable | bool
59-
notify: "(Handler: All OSs) Reload NGINX"
60-
6169
- name: "(Setup: All NGINX) Ensure SSL Certificate Directory Exists"
6270
file:
6371
path: "{{ nginx_ssl_crt_upload_dest | default('/etc/ssl/certs/') }}"
6472
state: directory
73+
mode: 0755
6574
when: nginx_ssl_upload_enable | bool
6675

6776
- name: "(Setup: All NGINX) Ensure SSL Key Directory Exists"
6877
file:
6978
path: "{{ nginx_ssl_key_upload_dest | default('/etc/ssl/private/') }}"
7079
state: directory
80+
mode: 0755
7181
when: nginx_ssl_upload_enable | bool
7282

7383
- name: "(Setup: All NGINX) Upload NGINX SSL Certificates"
7484
copy:
7585
src: "{{ item }}"
7686
dest: "{{ nginx_ssl_crt_upload_dest | default('/etc/ssl/certs/') }}"
77-
mode: 0640
7887
decrypt: yes
7988
backup: yes
89+
mode: 0640
8090
with_fileglob: "{{ nginx_ssl_crt_upload_src }}"
8191
when: nginx_ssl_upload_enable | bool
8292

8393
- name: "(Setup: All NGINX) Upload NGINX SSL Keys"
8494
copy:
8595
src: "{{ item }}"
8696
dest: "{{ nginx_ssl_key_upload_dest | default('/etc/ssl/private/') }}"
87-
mode: 0640
8897
decrypt: yes
8998
backup: yes
99+
mode: 0640
90100
with_fileglob: "{{ nginx_ssl_key_upload_src }}"
91101
no_log: yes
92102
when: nginx_ssl_upload_enable | bool

tasks/keys/apk-key.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@
1111
get_url:
1212
url: "{{ keysite }}"
1313
dest: /etc/apk/keys/nginx_signing.rsa.pub
14+
mode: 0400

tasks/opensource/install-oss-linux.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
include_tasks: "{{ role_path }}/tasks/prerequisites/setup-systemd.yml"
1313
when:
1414
- ansible_service_mgr == "systemd"
15-
- nginx_service_modify
15+
- nginx_service_modify | bool
1616

1717
- name: "(Install: Linux) Install NGINX From Source"
1818
include_tasks: "{{ role_path }}/tasks/opensource/setup-source.yml"

tasks/opensource/setup-debian.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@
1515

1616
- name: "(Install: Debian/Ubuntu) Add NGINX Repository"
1717
apt_repository:
18+
filename: nginx
1819
repo: "{{ item }}"
20+
update_cache: yes
21+
mode: 0644
1922
loop: "{{ repository }}"
2023

2124
- name: "(Install: Debian/Ubuntu) Install NGINX"

0 commit comments

Comments
 (0)