I want to copy a template generated file to /etc/init.d
folder. But template
task doesn't seem to support sudo parameter.
What is the recommended way to handle this? should I copy it to temporary directory and then move file with with sudo?
The playbook task looks like as shown below. Ansible version 1.8.2
- name: copy init script
template: src=template/optimus_api_service.sh dest=/etc/init.d/optimus-api mode=0755 force=yes owner=root group=root
I have tested the following playbook and it works.
My setup:
The User
vagrant
on the machinevm
is allowed to execute commands password-free withsudo
.I created a simple template and installed it with the following playbook: