nginx: fix multiple fails in check mode
All checks were successful
Ansible Lint |Total|New|Outstanding|Fixed|Trend |:-:|:-:|:-:|:-:|:-: |2670|11|2659|11|:-1: Reference build: <a href="https://jenkins.evolix.org/job/gitea/job/ansible-roles/job/unstable/443//ansiblelint">Evolix » ansible-roles » unstable #443</a>
gitea/ansible-roles/pipeline/head This commit looks good

This commit is contained in:
William Hirigoyen 2024-01-03 11:29:20 +01:00
parent 41897f4c62
commit 0a590b6679
7 changed files with 15 additions and 1 deletions

View file

@ -80,6 +80,8 @@ The **patch** part changes is incremented if multiple releases happen the same m
* webapps/nextcloud: fix Add Ceph volume to fstab : missing UUID= in src * webapps/nextcloud: fix Add Ceph volume to fstab : missing UUID= in src
* webapps/nextcloud: fix misplaced gid attribute * webapps/nextcloud: fix misplaced gid attribute
* webapps/nextcloud: fix missing gid * webapps/nextcloud: fix missing gid
* nginx: fix mistake between "check_mode: no" and "when: not ansible_check_mode" (fail in check mode)
* nginx: add "when: not ansible_check_mode" in various tasks to prevent fail in check mode
### Removed ### Removed

View file

@ -3,13 +3,16 @@
ansible.builtin.service: ansible.builtin.service:
name: nginx name: nginx
state: restarted state: restarted
when: not ansible_check_mode
- name: reload nginx - name: reload nginx
ansible.builtin.service: ansible.builtin.service:
name: nginx name: nginx
state: reloaded state: reloaded
when: not ansible_check_mode
- name: restart munin - name: restart munin
ansible.builtin.service: ansible.builtin.service:
name: munin-node name: munin-node
state: restarted state: restarted
when: not ansible_check_mode

View file

@ -6,6 +6,7 @@
line: "allow {{ item }};" line: "allow {{ item }};"
state: present state: present
loop: "{{ nginx_ipaddr_whitelist_present }}" loop: "{{ nginx_ipaddr_whitelist_present }}"
when: not ansible_check_mode
notify: reload nginx notify: reload nginx
tags: tags:
- nginx - nginx
@ -17,6 +18,7 @@
line: "allow {{ item }};" line: "allow {{ item }};"
state: absent state: absent
loop: "{{ nginx_ipaddr_whitelist_absent }}" loop: "{{ nginx_ipaddr_whitelist_absent }}"
when: not ansible_check_mode
notify: reload nginx notify: reload nginx
tags: tags:
- nginx - nginx

View file

@ -24,6 +24,7 @@
line: '\1worker_connections 1024;' line: '\1worker_connections 1024;'
insertafter: 'events \{' insertafter: 'events \{'
backrefs: yes backrefs: yes
when: not ansible_check_mode
tags: tags:
- nginx - nginx
@ -34,6 +35,7 @@
line: '\1use epoll;' line: '\1use epoll;'
insertafter: 'events \{' insertafter: 'events \{'
backrefs: yes backrefs: yes
when: not ansible_check_mode
tags: tags:
- nginx - nginx
@ -145,6 +147,7 @@
name: nginx name: nginx
enabled: yes enabled: yes
state: started state: started
when: not ansible_check_mode
tags: tags:
- nginx - nginx

View file

@ -37,3 +37,4 @@
daemon_reload: yes daemon_reload: yes
enabled: yes enabled: yes
state: started state: started
when: not ansible_check_mode

View file

@ -26,13 +26,15 @@
ansible.builtin.command: ansible.builtin.command:
cmd: "tail -n 1 {{ nginx_serverstatus_suffix_file }}" cmd: "tail -n 1 {{ nginx_serverstatus_suffix_file }}"
changed_when: False changed_when: False
check_mode: no when: not ansible_check_mode
register: new_nginx_serverstatus_suffix register: new_nginx_serverstatus_suffix
- name: overwrite nginx_serverstatus_suffix - name: overwrite nginx_serverstatus_suffix
ansible.builtin.set_fact: ansible.builtin.set_fact:
nginx_serverstatus_suffix: "{{ new_nginx_serverstatus_suffix.stdout }}" nginx_serverstatus_suffix: "{{ new_nginx_serverstatus_suffix.stdout }}"
when: not ansible_check_mode
- ansible.builtin.debug: - ansible.builtin.debug:
var: nginx_serverstatus_suffix var: nginx_serverstatus_suffix
verbosity: 1 verbosity: 1
when: not ansible_check_mode

View file

@ -17,4 +17,5 @@
dest: /etc/nginx/sites-available/evolinux-default.conf dest: /etc/nginx/sites-available/evolinux-default.conf
regexp: 'location /server-status-? {' regexp: 'location /server-status-? {'
replace: 'location /server-status-{{ nginx_serverstatus_suffix }} {' replace: 'location /server-status-{{ nginx_serverstatus_suffix }} {'
when: not ansible_check_mode
notify: reload nginx notify: reload nginx