chore: update
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
---
|
||||
- name: Installation et configuration du frontend et backend
|
||||
hosts: uber-stup
|
||||
hosts: demo-uber
|
||||
become: true
|
||||
gather_facts: true
|
||||
|
||||
@@ -203,7 +203,6 @@
|
||||
port: "{{ item }}"
|
||||
proto: tcp
|
||||
loop:
|
||||
- "{{ backend_port }}"
|
||||
- 80
|
||||
- 22
|
||||
|
||||
@@ -211,15 +210,15 @@
|
||||
ansible.builtin.ufw:
|
||||
state: enabled
|
||||
|
||||
- name: Vérifier si un certificat existe déjà
|
||||
ansible.builtin.stat:
|
||||
path: "/etc/letsencrypt/live/{{ domain_name }}/fullchain.pem"
|
||||
register: cert_file
|
||||
tags: [certbot]
|
||||
|
||||
# - name: Vérifier si un certificat existe déjà
|
||||
# ansible.builtin.stat:
|
||||
# path: "/etc/letsencrypt/live/{{ domain_name }}/fullchain.pem"
|
||||
# register: cert_file
|
||||
# tags: [certbot]
|
||||
#
|
||||
- name: Déployer la configuration Nginx HTTP
|
||||
ansible.builtin.template:
|
||||
src: templates/nginx.conf.j2
|
||||
src: templates/nginx2.conf.j2
|
||||
dest: /etc/nginx/sites-available/api
|
||||
vars:
|
||||
ssl_enabled: false
|
||||
@@ -254,59 +253,57 @@
|
||||
# ============================================================
|
||||
# Certificat SSL Let's Encrypt
|
||||
# ============================================================
|
||||
|
||||
- name: Générer le certificat SSL avec Certbot
|
||||
ansible.builtin.command: >
|
||||
certbot certonly --nginx
|
||||
-d {{ domain_name }}
|
||||
--non-interactive
|
||||
--agree-tos
|
||||
--email admin@{{ domain_name }}
|
||||
when: not cert_file.stat.exists
|
||||
tags: [certbot]
|
||||
# - name: Générer le certificat SSL avec Certbot
|
||||
# ansible.builtin.command: >
|
||||
# certbot certonly --nginx
|
||||
# -d {{ domain_name }}
|
||||
# --non-interactive
|
||||
# --agree-tos
|
||||
# --email admin@{{ domain_name }}
|
||||
# tags: [certbot]
|
||||
|
||||
# ============================================================
|
||||
# Nginx - reconfiguration HTTPS après certificat
|
||||
# ============================================================
|
||||
- name: Vérifier la présence du certificat
|
||||
ansible.builtin.stat:
|
||||
path: "/etc/letsencrypt/live/{{ domain_name }}/fullchain.pem"
|
||||
register: cert_file_after
|
||||
tags: [nginx]
|
||||
# - name: Vérifier la présence du certificat
|
||||
# ansible.builtin.stat:
|
||||
# path: "/etc/letsencrypt/live/{{ domain_name }}/fullchain.pem"
|
||||
# register: cert_file_after
|
||||
# tags: [nginx]
|
||||
|
||||
- name: Déployer la configuration Nginx HTTPS
|
||||
ansible.builtin.template:
|
||||
src: templates/nginx.conf.j2
|
||||
dest: /etc/nginx/sites-available/api
|
||||
vars:
|
||||
ssl_enabled: true
|
||||
when: cert_file_after.stat.exists
|
||||
notify: Restart nginx
|
||||
tags: [nginx]
|
||||
#- name: Déployer la configuration Nginx HTTPS
|
||||
# ansible.builtin.template:
|
||||
# src: templates/nginx.conf.j2
|
||||
# dest: /etc/nginx/sites-available/api
|
||||
# vars:
|
||||
# ssl_enabled: true
|
||||
# when: cert_file_after.stat.exists
|
||||
# notify: Restart nginx
|
||||
# tags: [nginx]
|
||||
|
||||
- name: Test de la configuration Nginx finale
|
||||
ansible.builtin.command: nginx -t
|
||||
changed_when: false
|
||||
tags: [nginx]
|
||||
#- name: Test de la configuration Nginx finale
|
||||
# ansible.builtin.command: nginx -t
|
||||
# changed_when: false
|
||||
# tags: [nginx]
|
||||
|
||||
- name: Redémarrage de Nginx avec SSL
|
||||
ansible.builtin.systemd:
|
||||
name: nginx
|
||||
state: restarted
|
||||
when: cert_file_after.stat.exists
|
||||
tags: [nginx]
|
||||
# - name: Redémarrage de Nginx avec SSL
|
||||
# ansible.builtin.systemd:
|
||||
# name: nginx
|
||||
# state: restarted
|
||||
# when: cert_file_after.stat.exists
|
||||
# tags: [nginx]
|
||||
|
||||
- name: Vérifier le renouvellement automatique
|
||||
ansible.builtin.command: certbot renew --dry-run
|
||||
register: certbot_renew
|
||||
changed_when: false
|
||||
failed_when: false
|
||||
tags: [certbot]
|
||||
# - name: Vérifier le renouvellement automatique
|
||||
# ansible.builtin.command: certbot renew --dry-run
|
||||
# register: certbot_renew
|
||||
# changed_when: false
|
||||
# failed_when: false
|
||||
# tags: [certbot]
|
||||
|
||||
- name: Afficher le statut du renouvellement
|
||||
ansible.builtin.debug:
|
||||
msg: "{{ certbot_renew.stdout_lines }}"
|
||||
tags: [certbot]
|
||||
# - name: Afficher le statut du renouvellement
|
||||
# ansible.builtin.debug:
|
||||
# msg: "{{ certbot_renew.stdout_lines }}"
|
||||
# tags: [certbot]
|
||||
|
||||
handlers:
|
||||
- name: Reload systemd
|
||||
|
||||
Reference in New Issue
Block a user