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