diff --git a/frontend.yaml b/frontend.yaml index 31327da..43ad4fd 100755 --- a/frontend.yaml +++ b/frontend.yaml @@ -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"