cleanup comments and debug

This commit is contained in:
2026-01-19 21:49:02 -07:00
parent 313d730638
commit a8b85590f9

View File

@@ -1,32 +1,22 @@
- name: Gather package facts - name: Gather package facts
ansible.builtin.package_facts: ansible.builtin.package_facts:
manager: auto # Automatically detects the package manager (apt, yum, dnf, etc.) manager: auto
- name: Debug if NGINX is installed
ansible.builtin.debug:
msg: "NGINX is installed (version: {{ ansible_facts.packages['nginx'][0].version }})"
when: "'nginx' in ansible_facts.packages" # Checks if 'nginx' key exists in the gathered facts
- name: Debug if NGINX is NOT installed
ansible.builtin.debug:
msg: "NGINX is not installed"
when: "'nginx' not in ansible_facts.packages"
- name: Stop nginx to generate initial lego cert - name: Stop nginx to generate initial lego cert
service: service:
name: nginx name: nginx
state: stopped state: stopped
when: "'nginx' in ansible_facts.packages" # Checks if 'nginx' key exists in the gathered facts when: "'nginx' in ansible_facts.packages"
- name: Generate initial cert - name: Generate initial cert
command: command:
cmd: /usr/local/bin/lego -a --email="{{ letsencrypt_email }}" --domains="{{ inventory_hostname | default(cert_domain) }}" --key-type {{ cert_key_type | default('rsa4096') }} --http run cmd: /usr/local/bin/lego -a --email="{{ letsencrypt_email }}" --domains="{{ inventory_hostname | default(cert_domain) }}" --key-type {{ cert_key_type | default('rsa4096') }} --http run
chdir: /root chdir: /root
creates: "/root/.lego/certificates/{{ inventory_hostname | default(cert_domain) }}.crt" creates: "/root/.lego/certificates/{{ inventory_hostname | default(cert_domain) }}.crt"
when: "'nginx' in ansible_facts.packages" # Checks if 'nginx' key exists in the gathered facts when: "'nginx' in ansible_facts.packages"
- name: Start nginx after generating initial lego cert - name: Start nginx after generating initial lego cert
service: service:
name: nginx name: nginx
state: started state: started
when: "'nginx' in ansible_facts.packages" # Checks if 'nginx' key exists in the gathered facts when: "'nginx' in ansible_facts.packages"