Hi..
I want to change the current directory in remote host by Ansible. so, i have created the playbook like below. but, it is not working correctly. would you please let me know how can i do change the current directory in the remote host? Kevin ======================================================================================================================= --- - name: Testing to change current direcotry hosts: Ansible-01 tasks: - name: confirm current Directory in the switch become: yes become_method: sudo command: 'pwd' register: exec_result - debug: var=exec_result.stdout_lines - name: Go to "/tmp" Directory in the switch become: yes become_method: sudo command: ' cd /tmp ' - name: confirm current Directory in the switch become: yes become_method: sudo command: 'pwd' register: exec_result - debug: var=exec_result.stdout_lines ====================================================================================================================== admin@ubuntu-Ansible:~$ ansible-playbook Change-dir.yml PLAY [Testing to change current direcotry] ******************************************************************************************************************* TASK [Gathering Facts] *************************************************************************************************************************************** ok: [Ansible-01] TASK [confirm current Directory in the switch] *************************************************************************************************************** changed: [Ansible-01] TASK [debug] ************************************************************************************************************************************************* ok: [Ansible-01] => { "exec_result.stdout_lines": [ *"/home/admin"* ] } TASK [Go to "/tmp" Directory in the switch] **************************************************************************************************************** fatal: [Ansible-01]: FAILED! => {"changed": false, "cmd": "cd /tmp", "msg": "[Errno 2] No such file or directory", "rc": 2} to retry, use: --limit @/home/admin/Change-dir.retry PLAY RECAP *************************************************************************************************************************************************** Ansible-01 : ok=3 changed=1 unreachable=0 failed=1 admin@ubuntu-Ansible:~$ -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+unsubscr...@googlegroups.com. To post to this group, send email to ansible-project@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/4c6c90a0-445a-4e1e-ae6d-6d2e23f23369%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.