ansibleguy.infra_mariadb/tasks/debian/letsencrypt/nginx.yml

31 lines
946 B
YAML

---
- name: Certificates | LetsEncrypt Certbot | Nginx | Install package
ansible.builtin.package:
name: ['python3-certbot-nginx']
state: present
- name: Certificates | LetsEncrypt Certbot | Nginx | Checking sites
ansible.builtin.command: 'ls /etc/nginx/sites-enabled/'
changed_when: false
register: enabled_nginx_sites
check_mode: false
- name: Certificates | LetsEncrypt Certbot | Nginx | Deploying temporary nginx site
ansible.builtin.template:
src: 'templates/etc/nginx/sites-enabled/le_dummy.j2'
dest: '/etc/nginx/sites-enabled/tmp_le_dummy'
owner: 'root'
group: 'root'
mode: 0644
register: tmp_site_enable
when: enabled_nginx_sites.stdout_lines | length == 0
- name: Certificates | LetsEncrypt Certbot | Nginx | Reloading apache
ansible.builtin.systemd:
name: 'nginx.service'
state: reloaded
when:
- enabled_nginx_sites.stdout_lines | length == 0
- tmp_site_enable.changed