Set-OPS-Public/roles/app_statique/tasks/main.yml

36 lines
1.3 KiB
YAML
Raw Normal View History

---
- name: "Statique : vhost nginx — {{ app_statique_application.nom }}"
ansible.builtin.template:
src: site.conf.j2
dest: "/etc/nginx/sites-available/{{ app_statique_vhost }}"
owner: root
group: root
mode: "0644"
register: app_statique_conf
- name: "Statique : activer le vhost — {{ app_statique_application.nom }}"
ansible.builtin.file:
src: "/etc/nginx/sites-available/{{ app_statique_vhost }}"
dest: "/etc/nginx/sites-enabled/{{ app_statique_vhost }}"
state: link
force: "{{ ansible_check_mode }}"
register: app_statique_lien
# PAS DE HANDLER : ce role est inclus une fois par site, et un handler ne verrait que les
# variables du dernier. Le vhost vise le dossier du nouveau commit : le recharger EST la bascule.
- name: "Statique : nginx accepte-t-il sa configuration ? — {{ app_statique_application.nom }}"
ansible.builtin.command:
argv: [nginx, -t, -q]
changed_when: false
when:
- app_statique_conf is changed or app_statique_lien is changed
- not ansible_check_mode
- name: "Statique : recharger nginx — {{ app_statique_application.nom }}"
ansible.builtin.systemd:
name: nginx
state: reloaded
when:
- app_statique_conf is changed or app_statique_lien is changed
- not ansible_check_mode