2023-07-26 17:39:14 +00:00
|
|
|
---
|
2024-10-05 08:04:19 +00:00
|
|
|
- name: Check if state is supported
|
|
|
|
ansible.builtin.fail:
|
|
|
|
msg: >-2
|
|
|
|
Unsupported state '{{ nginx_state }}'. Supported
|
|
|
|
states are {{ nginx_states | join(', ') }}.
|
|
|
|
when: nginx_state not in nginx_states
|
2023-07-26 17:39:14 +00:00
|
|
|
|
2024-10-05 08:15:48 +00:00
|
|
|
- name: Check if deployment_method is supported
|
|
|
|
ansible.builtin.fail:
|
|
|
|
msg: >-2
|
|
|
|
Unsupported state '{{ nginx_deployment_method }}'. Supported
|
|
|
|
states are {{ nginx_deployment_methods | join(', ') }}.
|
|
|
|
when: nginx_deployment_method not in nginx_deployment_methods
|
|
|
|
|
2024-10-05 08:04:19 +00:00
|
|
|
- name: Ensure nginx config file is {{ nginx_state }}
|
|
|
|
ansible.builtin.file:
|
|
|
|
path: "{{ nginx_config_file }}"
|
|
|
|
state: "{{ nginx_state }}"
|
|
|
|
when: nginx_state == 'absent'
|
|
|
|
|
|
|
|
- name: Ensure base path '{{ nginx_base_path }}' is {{ nginx_state }}
|
2023-07-26 17:39:14 +00:00
|
|
|
ansible.builtin.file:
|
|
|
|
path: "{{ nginx_base_path }}"
|
2024-10-05 08:04:19 +00:00
|
|
|
mode: "0755"
|
|
|
|
state: >-2
|
|
|
|
{{ (nginx_state == 'present') | ternary('directory', 'absent') }}
|
2023-07-26 17:39:14 +00:00
|
|
|
|
|
|
|
- name: Ensure nginx config file is templated
|
|
|
|
ansible.builtin.copy:
|
|
|
|
dest: "{{ nginx_config_file }}"
|
|
|
|
content: "{{ nginx_config }}"
|
|
|
|
mode: 0640
|
|
|
|
notify:
|
|
|
|
- restart-nginx
|
2024-10-05 08:04:19 +00:00
|
|
|
when: nginx_state == 'present'
|
2023-07-26 17:39:14 +00:00
|
|
|
|
2024-10-05 08:15:48 +00:00
|
|
|
- name: Deploy using {{ nginx_deployment_method }}
|
|
|
|
ansible.builtin.include_tasks:
|
|
|
|
file: "deploy-{{ nginx_deployment_method }}.yml"
|