Shruti, The default behavior of become is to use sudo, you don't mention if you checked that sudo as the ansible user works correctly or if it is say, prompting for a password or something that you need to provide.
That may not be your problem but I would start troubleshooting there. Of course you should also try and get verbose output with -vvv when possible but it sounds like it is either waiting for something to time out or for user input so that may not help as much for this specific issue. Good luck On Sun, Jun 21, 2020 at 5:44 AM chavali shruti <chavali.shr...@gmail.com> wrote: > Hi all, > > Ansible version: > > ansible 2.8.0 > config file = */ansible/ansible.cfg > configured module search path = ['*/.ansible/plugins/modules', > '/usr/share/ansible/plugins/modules'] > ansible python module location = > */.virtualenvs/redfish/lib/python3.6/site-packages/ansible > executable location = */.virtualenvs/redfish/bin/ansible > python version = 3.6.9 (default, Oct 29 2019, 10:39:36) [GCC] > > I have created few vm's using ansible. I have to run few commands on those > vm's, as a different user. I am not able to switch to that user using any > method. I think it might be some config issue, which I am missing. > > Target OS: Rhel 7.6 > > My task inside my playbook is as follows: > > --- > - name: Sample playbook > hosts: all > remote_user: root > #become: yes > gather_facts: True > > tasks: > - name: switch user > shell: su - **** > delegate_to: testvm > > The above code hangs, may be because it expects password. > > I tried, > > tasks: > - name: switch user > shell: my_command > become: yes > become_user: **** > delegate_to: testvm > > This runs the command on the root login itself, and fails as the command > only exists for the other user. > become documentation doesnt mention any config file change. > > I need help, if there is any config file I need to change, for this to > work. Please suggest. > > Thanks and Regards, > Shruti > > > -- > You received this message because you are subscribed to the Google Groups > "Ansible Development" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to ansible-devel+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/ansible-devel/a644571e-de85-443f-a74d-0ed407e48f0eo%40googlegroups.com > <https://groups.google.com/d/msgid/ansible-devel/a644571e-de85-443f-a74d-0ed407e48f0eo%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "Ansible Development" group. To unsubscribe from this group and stop receiving emails from it, send an email to ansible-devel+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-devel/CAJ7P4uiW3qMgC-DyiG2bnt8UBUVdPLimOuY2C84mKEg238%2BHgg%40mail.gmail.com.