2021-12-09 21:40:57 +01:00
|
|
|
---
|
|
|
|
- name: Verify
|
|
|
|
hosts: all
|
|
|
|
tasks:
|
|
|
|
- name: Check if NGINX is installed
|
2022-03-22 18:27:11 +01:00
|
|
|
ansible.builtin.package:
|
2021-12-09 21:40:57 +01:00
|
|
|
name: nginx
|
|
|
|
state: present
|
|
|
|
check_mode: true
|
|
|
|
register: install
|
|
|
|
failed_when: (install is changed) or (install is failed)
|
|
|
|
|
|
|
|
- name: Check if NGINX service is running
|
2022-03-22 18:27:11 +01:00
|
|
|
ansible.builtin.service:
|
2021-12-09 21:40:57 +01:00
|
|
|
name: nginx
|
|
|
|
state: started
|
|
|
|
enabled: true
|
|
|
|
check_mode: true
|
|
|
|
register: service
|
|
|
|
failed_when: (service is changed) or (service is failed)
|
|
|
|
|
|
|
|
- name: Verify NGINX is up and running
|
2022-03-22 18:27:11 +01:00
|
|
|
ansible.builtin.uri:
|
2021-12-09 21:40:57 +01:00
|
|
|
url: http://localhost
|
|
|
|
status_code: 200
|
|
|
|
|
2022-03-22 18:27:11 +01:00
|
|
|
- name: Verify NGINX has been downgraded
|
|
|
|
ansible.builtin.command: nginx -v
|
|
|
|
args:
|
|
|
|
chdir: "{{ ((ansible_facts['system'] | lower is not search('bsd')) | ternary('/etc/nginx', '/usr/local/sbin')) }}"
|
|
|
|
changed_when: false
|
|
|
|
register: version
|
|
|
|
failed_when: version is not search('1.20.2')
|