parent
d1cbcde4de
commit
7a5b35d625
@ -1,14 +1,20 @@ |
|||||||
--- |
--- |
||||||
- name: Check if certificate already exists. |
- name: Check if certificate already exists. |
||||||
stat: |
ansible.builtin.stat: |
||||||
path: /etc/letsencrypt/live/{{ cert_item.domains | first }}/cert.pem |
path: /etc/letsencrypt/live/{{ cert_item.domains | first }}/cert.pem |
||||||
register: letsencrypt_cert |
register: letsencrypt_cert |
||||||
|
|
||||||
- name: Create webroot directory if it doesn't exist yet |
- name: Create webroot directory if it doesn't exist yet |
||||||
file: |
ansible.builtin.file: |
||||||
path: "{{ cert_item.webroot | default(certbot_webroot) }}" |
path: "{{ cert_item.webroot | default(certbot_webroot) }}" |
||||||
state: directory |
state: directory |
||||||
|
owner: root |
||||||
|
group: root |
||||||
|
mode: '0755' |
||||||
|
|
||||||
- name: Generate new certificate if one doesn't exist. |
- name: Generate new certificate if one doesn't exist. |
||||||
command: "{{ certbot_create_command }}" |
ansible.builtin.command: "{{ certbot_create_command }}" |
||||||
|
register: certbot_create_command_result |
||||||
when: not letsencrypt_cert.stat.exists |
when: not letsencrypt_cert.stat.exists |
||||||
|
changed_when: |
||||||
|
- certbot_create_command_result.rc is defined and certbot_create_command_result.rc == 0 |
||||||
|
@ -1,7 +1,9 @@ |
|||||||
--- |
--- |
||||||
- name: Install Certbot. |
- name: Install Certbot. |
||||||
package: "name={{ certbot_package }} state=present" |
ansible.builtin.package: |
||||||
|
name: "{{ certbot_package }}" |
||||||
|
state: present |
||||||
|
|
||||||
- name: Set Certbot script variable. |
- name: Set Certbot script variable. |
||||||
set_fact: |
ansible.builtin.set_fact: |
||||||
certbot_script: "{{ certbot_package }}" |
certbot_script: "{{ certbot_package }}" |
||||||
|
@ -1,41 +1,36 @@ |
|||||||
--- |
--- |
||||||
- name: Ensure snapd is installed. |
- name: Ensure snapd is installed. |
||||||
package: |
ansible.builtin.package: |
||||||
name: snapd |
name: snapd |
||||||
state: present |
state: present |
||||||
register: snapd_install |
notify: |
||||||
|
- Update snap after install |
||||||
|
|
||||||
- name: Ensure snapd is enabled. |
- name: Ensure snapd is enabled. |
||||||
systemd: |
ansible.builtin.systemd: |
||||||
name: snapd.socket |
name: snapd.socket |
||||||
enabled: true |
enabled: true |
||||||
state: started |
state: started |
||||||
|
|
||||||
- name: Enable classic snap support. |
- name: Enable classic snap support. |
||||||
file: |
ansible.builtin.file: |
||||||
src: /var/lib/snapd/snap |
src: /var/lib/snapd/snap |
||||||
dest: /snap |
dest: /snap |
||||||
state: link |
state: link |
||||||
when: ansible_os_family != "Debian" |
when: ansible_os_family != "Debian" |
||||||
|
|
||||||
- name: Update snap after install. |
|
||||||
shell: snap install core; snap refresh core |
|
||||||
changed_when: true |
|
||||||
failed_when: false |
|
||||||
when: snapd_install is changed |
|
||||||
|
|
||||||
- name: Install certbot via snap. |
- name: Install certbot via snap. |
||||||
snap: |
community.general.snap: |
||||||
name: certbot |
name: certbot |
||||||
classic: true |
classic: true |
||||||
|
|
||||||
- name: Symlink certbot into place. |
- name: Symlink certbot into place. |
||||||
file: |
ansible.builtin.file: |
||||||
src: /snap/bin/certbot |
src: /snap/bin/certbot |
||||||
dest: /usr/bin/certbot |
dest: /usr/bin/certbot |
||||||
state: link |
state: link |
||||||
ignore_errors: "{{ ansible_check_mode }}" |
ignore_errors: "{{ ansible_check_mode }}" |
||||||
|
|
||||||
- name: Set Certbot script variable. |
- name: Set Certbot script variable. |
||||||
set_fact: |
ansible.builtin.set_fact: |
||||||
certbot_script: /usr/bin/certbot |
certbot_script: /usr/bin/certbot |
||||||
|
Loading…
Reference in new issue