forked from infra/ansible
certbot: customize certbot configuration
Arguments can now be injected into conf template and different authenticators may be used. Role was revised to comply with linter. Signed-off-by: Jiri Podivin <jpodivin@redhat.com>
This commit is contained in:
parent
4670fea4dc
commit
bbc603c535
5 changed files with 52 additions and 36 deletions
|
|
@ -404,16 +404,6 @@ roles/bz_review_report/tasks/main.yml no-free-form
|
|||
roles/centosci-keytab role-name
|
||||
roles/centosci-keytab/tasks/main.yml fqcn[action-core]
|
||||
roles/centosci-keytab/tasks/main.yml jinja[spacing]
|
||||
roles/certbot/tasks/letsencrypt.yml args[module]
|
||||
roles/certbot/tasks/letsencrypt.yml fqcn[action-core]
|
||||
roles/certbot/tasks/letsencrypt.yml fqcn[action]
|
||||
roles/certbot/tasks/letsencrypt.yml jinja[spacing]
|
||||
roles/certbot/tasks/letsencrypt.yml name[missing]
|
||||
roles/certbot/tasks/letsencrypt.yml no-free-form
|
||||
roles/certbot/tasks/letsencrypt.yml risky-file-permissions
|
||||
roles/certbot/tasks/main.yml fqcn[action-core]
|
||||
roles/certbot/tasks/main.yml name[missing]
|
||||
roles/certbot/templates/.certbot.j2.un~ load-failure[unicodedecodeerror]
|
||||
roles/cgit/base/tasks/main.yml jinja[spacing]
|
||||
roles/cgit/base/tasks/main.yml no-free-form
|
||||
roles/cgit/clean_lock_cron/tasks/main.yml no-free-form
|
||||
|
|
|
|||
8
roles/certbot/defaults/main.yml
Normal file
8
roles/certbot/defaults/main.yml
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
---
|
||||
# Optional extra arguments passed verbatim to certbot on renewal.
|
||||
# Example: certbot_args: "--force-renewal"
|
||||
# certbot_args:
|
||||
|
||||
# Authenticator used for certificate renewal. Defaults to webroot.
|
||||
# Set to "standalone" for hosts without a web server serving challenge files.
|
||||
certbot_renewal_authenticator: webroot
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
---
|
||||
- set_fact:
|
||||
- name: Set letsencrypt path and backup
|
||||
ansible.builtin.set_fact:
|
||||
le_source_path: /etc/letsencrypt
|
||||
# https://forge.fedoraproject.org/infra/tickets/issues/10524
|
||||
le_backup_path: /srv/certbot-certs
|
||||
|
|
@ -7,26 +8,32 @@
|
|||
- certbot
|
||||
|
||||
- name: Install certbot package
|
||||
ansible.builtin.package: name=certbot state=present
|
||||
ansible.builtin.package:
|
||||
name: certbot
|
||||
state: present
|
||||
tags:
|
||||
- certbot
|
||||
|
||||
- name: Install certbot config
|
||||
ansible.builtin.template: src=certbot.j2 dest=/etc/sysconfig/certbot
|
||||
mode=0644
|
||||
ansible.builtin.template:
|
||||
src: certbot.j2
|
||||
dest: /etc/sysconfig/certbot
|
||||
mode: '0644'
|
||||
tags:
|
||||
- certbot
|
||||
|
||||
- name: Install certbot deploy script
|
||||
ansible.builtin.template: src={{ letsencrypt.predefined_deploy_script }}
|
||||
dest=/usr/libexec/auto-certbot-deploy
|
||||
mode=0755
|
||||
ansible.builtin.template:
|
||||
src: "{{ letsencrypt.predefined_deploy_script }}"
|
||||
dest: /usr/libexec/auto-certbot-deploy
|
||||
mode: '0755'
|
||||
when: letsencrypt.predefined_deploy_script is defined
|
||||
tags:
|
||||
- certbot
|
||||
|
||||
- name: Check whether we need to initialize letsencrypt first
|
||||
stat: path="/etc/letsencrypt/live/{{ item.key }}"
|
||||
ansible.builtin.stat:
|
||||
path: "/etc/letsencrypt/live/{{ item.key }}"
|
||||
register: le_stat_checks
|
||||
with_dict: "{{ letsencrypt.certificates }}"
|
||||
tags:
|
||||
|
|
@ -34,15 +41,15 @@
|
|||
|
||||
- name: Check if we already have the backup
|
||||
delegate_to: localhost
|
||||
stat:
|
||||
path: "{{ le_backup_path }}/{{ (letsencrypt.certificates|dictsort)[0][0] }}"
|
||||
ansible.builtin.stat:
|
||||
path: "{{ le_backup_path }}/{{ (letsencrypt.certificates | dictsort)[0][0] }}"
|
||||
register: le_stat_backup_dir
|
||||
tags:
|
||||
- certbot
|
||||
|
||||
- name: Restore the certificates from backup (backed up on batcave)
|
||||
synchronize:
|
||||
src: "{{ le_backup_path }}/{{ (letsencrypt.certificates|dictsort)[0][0] }}/"
|
||||
ansible.posix.synchronize:
|
||||
src: "{{ le_backup_path }}/{{ (letsencrypt.certificates | dictsort)[0][0] }}/"
|
||||
dest: "{{ le_source_path }}"
|
||||
mode: push
|
||||
tags:
|
||||
|
|
@ -68,20 +75,25 @@
|
|||
tags:
|
||||
- certbot
|
||||
|
||||
- name: Configure certbot to use webroot next time
|
||||
ini_file: dest="/etc/letsencrypt/renewal/{{ item.item.key }}.conf"
|
||||
section=renewalparams
|
||||
option=authenticator
|
||||
value=webroot
|
||||
- name: Configure certbot renewal authenticator
|
||||
community.general.ini_file:
|
||||
dest: "/etc/letsencrypt/renewal/{{ item.item.key }}.conf"
|
||||
section: renewalparams
|
||||
option: authenticator
|
||||
value: "{{ certbot_renewal_authenticator }}"
|
||||
mode: '0644'
|
||||
with_items: "{{ le_stat_checks.results }}"
|
||||
tags:
|
||||
- certbot
|
||||
|
||||
- name: Configure certbot to use webroot next time
|
||||
ini_file: dest="/etc/letsencrypt/renewal/{{ item.item.key }}.conf"
|
||||
section=renewalparams
|
||||
option=webroot_path
|
||||
value="{{ item.item.value.challenge_dir }}"
|
||||
- name: Configure certbot to use webroot next time - set webroot_path
|
||||
community.general.ini_file:
|
||||
dest: "/etc/letsencrypt/renewal/{{ item.item.key }}.conf"
|
||||
section: renewalparams
|
||||
option: webroot_path
|
||||
value: "{{ item.item.value.challenge_dir }}"
|
||||
mode: '0644'
|
||||
when: certbot_renewal_authenticator == 'webroot'
|
||||
with_items: "{{ le_stat_checks.results }}"
|
||||
tags:
|
||||
- certbot
|
||||
|
|
@ -98,7 +110,7 @@
|
|||
- certbot
|
||||
|
||||
- name: Automatize cert renewal
|
||||
service:
|
||||
ansible.builtin.service:
|
||||
name: certbot-renew.timer
|
||||
state: started
|
||||
enabled: yes
|
||||
|
|
@ -113,7 +125,7 @@
|
|||
# https://pagure.io/copr/copr/issue/2001 Resolves:
|
||||
# https://forge.fedoraproject.org/infra/tickets/issues/10391
|
||||
- name: Allow lighttpd to step into certbots directories
|
||||
acl:
|
||||
ansible.posix.acl:
|
||||
path: "{{ item }}"
|
||||
entity: lighttpd
|
||||
etype: user
|
||||
|
|
@ -141,7 +153,7 @@
|
|||
certbot
|
||||
|
||||
- name: Backup the letsencrypt certs to batcave directory
|
||||
synchronize:
|
||||
ansible.posix.synchronize:
|
||||
src: "{{ le_source_path }}/"
|
||||
dest: "{{ le_backup_path }}/{{ item.key }}"
|
||||
mode: pull
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
---
|
||||
- include_tasks: letsencrypt.yml
|
||||
- name: Configure certbot
|
||||
ansible.builtin.include_tasks: letsencrypt.yml
|
||||
when:
|
||||
- letsencrypt is defined
|
||||
tags: always
|
||||
|
|
|
|||
|
|
@ -5,6 +5,11 @@
|
|||
# uncomment the following config option, and hit `systemctl start
|
||||
# certbot-renew.service`. WARNING WARNING Don't forget to comment it again!
|
||||
#CERTBOT_ARGS="--force-renewal"
|
||||
|
||||
{% if certbot_args is defined %}
|
||||
CERTBOT_ARGS="{{ certbot_args }}"
|
||||
{% endif %}
|
||||
|
||||
{% if letsencrypt.predefined_deploy_script is defined %}
|
||||
|
||||
# Execute the script after certificate renewal, usually this is needed to
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue