Use vault secret for Cloudflare token and fail if empty
An unset env var led to an empty cloudflare.ini, breaking certbot renewal. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
1 parent
19402b8bce
commit
a409b985e8
1 file changed
+6
-1
+6
-1
@@ -9,7 +9,7 @@
|
||||
|
||||
certbot_dir: "{{ ansible_env.HOME }}/.local/share/certbot"
|
||||
certbot_config_dir: "{{ ansible_env.HOME }}/.config/letsencrypt"
|
||||
cloudflare_api_token: "{{ lookup('env', 'CLOUDFLARE_API_TOKEN') }}"
|
||||
cloudflare_api_token: "{{ secrets.CLOUDFLARE_API_TOKEN | default(lookup('env', 'CLOUDFLARE_API_TOKEN')) }}"
|
||||
certbot_admin_email: "{{ lookup('env', 'CERTBOT_ADMIN_EMAIL') }}"
|
||||
|
||||
roles:
|
||||
@@ -41,6 +41,11 @@
|
||||
- "{{ certbot_config_dir }}/work"
|
||||
- "{{ certbot_config_dir }}/logs"
|
||||
|
||||
- name: Ensure Cloudflare API token is set
|
||||
ansible.builtin.assert:
|
||||
that: cloudflare_api_token | length > 0
|
||||
fail_msg: CLOUDFLARE_API_TOKEN is empty; certbot renewal would fail. Pass -e @secrets.enc or set the env var.
|
||||
|
||||
- name: Deploy Cloudflare API credentials file
|
||||
ansible.builtin.copy:
|
||||
dest: "{{ certbot_config_dir }}/cloudflare.ini"
|
||||
|
||||
Reference in new issue
Block a user