Modifying local files while targeting a remote system

25 views
Skip to first unread message

EspressoBeanies

unread,
Nov 7, 2017, 2:12:59 PM11/7/17
to Ansible Project
Is it possible to modify local files while targeting a remote system in an Ansible YAML file? I'm trying to run an Ansible script on a remote machine, but when everything finishes on that remote machine, I'd like to move that hostname from one Ansible hosts file to another. Is it possible and if so, could someone point me in the right direction? Thanks!

Kai Stian Olstad

unread,
Nov 7, 2017, 2:19:48 PM11/7/17
to ansible...@googlegroups.com
On all task you can use delegate_to[1] and that task will run on the delegated machine.
So "delegate_to: localhost" will run on local machine and not on the remote host.

To change a file you have the lineinfile module or the template module.


[1] https://docs.ansible.com/ansible/latest/playbooks_delegation.html#delegation

--
Kai Stian Olstad

EspressoBeanies

unread,
Nov 7, 2017, 5:23:22 PM11/7/17
to Ansible Project
Thanks Kai
Reply all
Reply to author
Forward
0 new messages