-
-
Notifications
You must be signed in to change notification settings - Fork 349
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Zhuravlev E
committed
Jul 25, 2024
1 parent
d1cbcde
commit 7a5b35d
Showing
9 changed files
with
61 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
--- | ||
- name: Clone Certbot into configured directory. | ||
git: | ||
ansible.builtin.git: | ||
repo: "{{ certbot_repo }}" | ||
dest: "{{ certbot_dir }}" | ||
version: "{{ certbot_version }}" | ||
update: "{{ certbot_keep_updated }}" | ||
force: true | ||
|
||
- name: Set Certbot script variable. | ||
set_fact: | ||
ansible.builtin.set_fact: | ||
certbot_script: "{{ certbot_dir }}/certbot-auto" | ||
|
||
- name: Ensure certbot-auto is executable. | ||
file: | ||
ansible.builtin.file: | ||
path: "{{ certbot_script }}" | ||
mode: 0755 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,41 @@ | ||
--- | ||
- import_tasks: include-vars.yml | ||
- name: Include vars | ||
ansible.builtin.import_tasks: include-vars.yml | ||
|
||
- import_tasks: setup-RedHat.yml | ||
- name: Import Redhat task | ||
ansible.builtin.import_tasks: setup-RedHat.yml | ||
when: ansible_os_family == 'RedHat' | ||
|
||
- import_tasks: install-with-package.yml | ||
- name: Standalone install method choosed | ||
ansible.builtin.import_tasks: install-with-package.yml | ||
when: certbot_install_method == 'package' | ||
|
||
- import_tasks: install-with-snap.yml | ||
- name: Snap install method choosed | ||
ansible.builtin.import_tasks: install-with-snap.yml | ||
when: certbot_install_method == 'snap' | ||
|
||
- import_tasks: install-from-source.yml | ||
- name: Source install method choosed | ||
ansible.builtin.import_tasks: install-from-source.yml | ||
when: certbot_install_method == 'source' | ||
|
||
- include_tasks: create-cert-standalone.yml | ||
- name: Create certs for standalone install | ||
ansible.builtin.include_tasks: create-cert-standalone.yml | ||
with_items: "{{ certbot_certs }}" | ||
when: | ||
- certbot_create_if_missing | ||
- certbot_create_method == 'standalone' | ||
loop_control: | ||
loop_var: cert_item | ||
|
||
- include_tasks: create-cert-webroot.yml | ||
- name: Create certs for webroot install | ||
ansible.builtin.include_tasks: create-cert-webroot.yml | ||
with_items: "{{ certbot_certs }}" | ||
when: | ||
- certbot_create_if_missing | ||
- certbot_create_method == 'webroot' | ||
loop_control: | ||
loop_var: cert_item | ||
|
||
- import_tasks: renew-cron.yml | ||
- name: Check cron jobs | ||
ansible.builtin.import_tasks: renew-cron.yml | ||
when: certbot_auto_renew |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,27 @@ | ||
--- | ||
# See: https://github.com/geerlingguy/ansible-role-certbot/issues/107 | ||
- block: | ||
|
||
- name: Check dnf modules for Redhat family | ||
when: | ||
- ansible_distribution == 'CentOS' | ||
- ansible_distribution_major_version | int >= 8 | ||
block: | ||
- name: Ensure dnf-plugins are installed on CentOS 8+. | ||
yum: | ||
ansible.builtin.yum: | ||
name: dnf-plugins-core | ||
state: present | ||
|
||
- block: | ||
|
||
when: ansible_facts['distribution_version'] is version('8.2', '<=') | ||
- name: Check dnf modules for Centos | ||
block: | ||
- name: Enable DNF module for CentOS 8.3+. | ||
shell: | | ||
ansible.builtin.shell: | | ||
dnf config-manager --set-enabled powertools | ||
register: dnf_module_enable | ||
changed_when: false | ||
|
||
when: ansible_facts['distribution_version'] is version('8.3', '>=') | ||
|
||
- name: Enable DNF module for CentOS 8.0–8.2. | ||
shell: | | ||
ansible.builtin.shell: | | ||
dnf config-manager --set-enabled PowerTools | ||
register: dnf_module_enable | ||
changed_when: false | ||
|
||
when: ansible_facts['distribution_version'] is version('8.2', '<=') | ||
|
||
when: | ||
- ansible_distribution == 'CentOS' | ||
- ansible_distribution_major_version | int >= 8 |