google-cloud-ops-agents-ansible
google-cloud-ops-agents-ansible copied to clipboard
Use template module
Use template ansible module to place file to desired destination.
For ex: In google-cloud-ops-agents-ansible/tasks/linux.yml
on line 35 we have
- when: package_state == 'present'
block:
- name: Copy main config file onto the remote machine
copy:
src: "{{ main_config_file }}"
dest: "{{ vars[agent_type + '_config_path'] }}"
force: true
mode: 0644
Copy module will only copy the same file present on host machine.
The template module takes the file from host, changes the variables if required by end-user, and then copies to the remote location, provided the file should be present in templates directory besides the tasks directory
Solution:
- when: package_state == 'present'
block:
- name: Copy main config file onto the remote machine
template:
src: "{{ main_config_file }}"
dest: "{{ vars[agent_type + '_config_path'] }}"
force: true
mode: 0644