How to change the working directory in Ansible during the execution of commands
Ideally there is no no concept of current directory in Ansible. But we can specify the working directory for specific tasks.
Sample playbook is as following.
- name: Run command on specific folder
command: ls
args:
chdir: /root/
Here the command is "ls" and the folder name is "/root". This will list out all the files and folders in the "/root" directory.
We need to change the command and directory according to the requirements.
That's all…