Ansible cron task needs string escaping
Vicarium opened this issue · 1 comments
Vicarium commented
I ran into an error when running "make deploy_user".
Error points to {{cookiecutter.project_slug}}/ansible/roles/nginx/tasks/setup_nginx.yml Line 62:
- name: Add the renewal cronjob to the system
become: yes
become_user: root
cron: name="LE certificate renewal" minute="30" hour="2,7"
job="/usr/bin/certbot renew --pre-hook "service nginx stop" --post-hook "service nginx start""
when: use_ssl|bool and cert_stat.stat.exists
tags:
- ssl
- nginx
Unless I'm missing something it just looks like its just a matter of escaping the quotes, the line "job=..." should be:
job="/usr/bin/certbot renew --pre-hook \"service nginx stop\" --post-hook \"service nginx start\""
The error:
$ make deploy_user
\033[33;34m Create the deploy user for based production \033[0m
(\
cd ansible; \
ansible-playbook -i production provision.yml --tags user; \
)
ERROR! this task 'cron' has extra params, which is only allowed in the following modules: include_vars, add_host, command, script, win_command, include, meta, import_tasks, win_shell, include_role, shell, raw, group_by, import_role, include_tasks, set_fact
The error appears to be in '/home/tyler/Code/Workspace/vsite/ansible/roles/nginx/tasks/setup_nginx.yml': line 62, column 3, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
- name: Add the renewal cronjob to the system
^ here
make: *** [Makefile:142: deploy_user] Error 4
chrisdev commented
I don't think we even need to add these cron jobs as Certbot may handles this. Need to test on all supported versions of Ubuntu