geerlingguy / ansible-role-certbot

Ansible Role - Certbot (for Let's Encrypt)
https://galaxy.ansible.com/geerlingguy/certbot/
MIT License
794 stars 348 forks source link

Script fails if certbot_create_extra_args is not defined since #109 #225

Open m5p3nc3r opened 1 month ago

m5p3nc3r commented 1 month ago

I came back to use this script after months of inactivity, and I found the execution failed with:

TASK [geerlingguy.certbot : Generate new certificate if one doesn't exist.] ******************************************************************
fatal: [machine.localdomain]: FAILED! => {"msg": "The task includes an option with an undefined variable.. {{ certbot_script }} certonly --{{ certbot_create_method  }} {{ '--hsts' if certbot_hsts else '' }} {{ '--test-cert' if certbot_testmode else '' }} --noninteractive --agree-tos --email {{ cert_item.email | default(certbot_admin_email) }} {{ '--webroot-path ' if certbot_create_method == 'webroot'  else '' }} {{ cert_item.webroot | default(certbot_webroot) if certbot_create_method == 'webroot' else '' }} {{ certbot_create_extra_args }} -d {{ cert_item.domains | join(',') }} {{ '--pre-hook /etc/letsencrypt/renewal-hooks/pre/stop_services'\n  if certbot_create_standalone_stop_services and certbot_create_method == 'standalone'\nelse '' }} {{ '--post-hook /etc/letsencrypt/renewal-hooks/post/start_services'\n  if certbot_create_standalone_stop_services and certbot_create_method == 'standalone'\nelse '' }}: 'certbot_create_extra_args' is undefined\n\nThe error appears to be in '/home/{user}/.ansible/roles/geerlingguy.certbot/tasks/create-cert-standalone.yml': line 40, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: Generate new certificate if one doesn't exist.\n  ^ here\n"}

On investigation, it seems to be after the addition of #109.

If I add certbot_create_extra_args: "" to my ansible configuration, the installation succeeds.

I believe the expectation is that the script should work if certbot_create_extra_args is not defined.