Hi Dick, Thanks for response. I have already tried that and it was not working. I think the problem is related t the fact that I am running this playbook with connection=local. I have a feeling that even though this is locally, ansible still sees 127.0.0.1 as a separate entity on which the directory does not exist. Not sure if I am talking sense though.
Regards Charles On Thursday, 15 September 2016 16:55:28 UTC+1, Dick Davies wrote: > > your 'cd' command runs as a separate command, that's why its' not working. > > Try adding a chdir= option to your script command, see : > > http://docs.ansible.com/ansible/command_module.html > > On 15 September 2016 at 16:10, Charles Moga <[email protected] > <javascript:>> wrote: > > Hello, > > I hope someone can answer this. I have a bunch of commands (shell > scripts ) > > in a specific directory I need to run as root user. So I do: > > > > - name: Becoming root > > command: sudo su - > > > > - name: Changing directory > > command: cd "{{ command_directory }}" > > > > - name: Sourcing commands > > command: source mycommand.sh > > > > > > The problem is keep getting: > > fatal: [127.0.0.1]: FAILED! => {"changed": false, "cmd": "cd > > full_path_to_my_command_directory", "failed": true, "msg": "[Errno 2] No > > such file or directory", "rc": 2} > > > > If I do manually, it works fine. > > > > Any suggestions? I have tried become but exactly the same result. It > just > > seems like once I change to root, cd command does not work anymore. > > > > Thanks and regards > > Charles > > > > > > > > -- > > 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 [email protected] <javascript:>. > > To post to this group, send email to [email protected] > <javascript:>. > > To view this discussion on the web visit > > > https://groups.google.com/d/msgid/ansible-project/d33d5d14-9f51-4e40-891b-b29b54004b89%40googlegroups.com. > > > > For more options, visit https://groups.google.com/d/optout. > -- 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 [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/5b591c71-fd88-482f-bf98-19a0280711b1%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
