Ansible-Roles/roles/nginx/tasks/main.yml
2026-05-08 22:25:29 +03:00

53 lines
1.5 KiB
YAML

---
- name: Install Nginx for Debian
ansible.builtin.import_tasks: nginx-deb.yml
when: ansible_distribution_file_variety == "Debian"
- name: Install Nginx for EL
ansible.builtin.import_tasks: nginx-rh.yml
when: ansible_distribution_file_variety == "RedHat"
- name: Generate Nginx Config
ansible.builtin.import_tasks: nginx-config.yml
- name: Configure VHosts
ansible.builtin.import_tasks: nginx-virtualhosts.yml
# when: nginx_virthosts is defined
when: nginx_virthosts | length > 0
- name: Configure streams
ansible.builtin.import_tasks: nginx-stream.yml
when: nginx_streams | length > 0
- name: Generate robots.txt
ansible.builtin.import_tasks: robots-txt.yml
- name: Configure logrotate
ansible.builtin.import_tasks: nginx-logrotate.yml
#
# - name: Confugure Letsencrypt
# ansible.builtin.import_tasks: nginx-letsencrypt.yml
# when: letsencrypt_acme_install is defined and letsencrypt_acme_install
# - ansible.builtin.import_tasks: basic-auth.yml
# - ansible.builtin.import_tasks: pam-ldap.yml
- name: Ensure that the webserver is running and enabled at boot time
ansible.builtin.service:
name: nginx
state: started
enabled: true
when: nginx_enabled
# ignore_errors: true
failed_when: false
tags: nginx
- name: Ensure that the webserver is stopped and disabled
ansible.builtin.service:
name: nginx
state: stopped
enabled: true
when: not nginx_enabled
# ignore_errors: true
failed_when: false
tags: nginx