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!
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
Thanks Kai