Looks like setting "sudo_user" on a task doesn't actively cause it to invoke sudo on that task. To me, I think it should.
Can you file a ticket on this if you are seeing this in Ansible 1.7.2 or later? Thanks! On Mon, Nov 24, 2014 at 8:48 AM, Волков Евгений <[email protected]> wrote: > HI, > I had some problems with sudo_user switching. Config file not changed. > ansible 1.7.2 > > test.yml > --- > - hosts: test_host.local > remote_user: notroot > tasks: > - name: test1 > *sudo_user: test* > shell: whoami > > - name: test2 > sudo: yes > *sudo_user: test* > shell: whoami > > *********************************************************** > > ansible-playbook test.yml -v > > PLAY [test_host.local] ***************************** > > GATHERING FACTS > *************************************************************** > ok: [test_host.local] > > TASK: [test1] > ***************************************************************** > changed: [test_host.local] => {"changed": true, "cmd": "whoami", "delta": > "0:00:00.002587", "end": "2014-11-24 15:41:03.876659", "rc": 0, "start": > "2014-11-24 15:41:03.874072", "stderr": "", "*stdout": "notroot"*} > > TASK: [test2] > ***************************************************************** > changed: [test_host.local] => {"changed": true, "cmd": "whoami", "delta": > "0:00:00.002617", "end": "2014-11-24 15:41:04.847170", "rc": 0, "start": > "2014-11-24 15:41:04.844553", "stderr": "", *"stdout": "root"*} > > PLAY RECAP > ******************************************************************** > test_host.local : ok=3 changed=2 unreachable=0 failed=0 > *********************************************************** > > In docs, I saw this example: > > http://docs.ansible.com/playbooks_intro.html > > You can also login as you, and then sudo to different users than root: > > --- > - hosts: webservers > remote_user: yourname > sudo: yes > sudo_user: postgres > > But as you see it's not quite right. > > Help please. How can i execute command under specific user, not root end > not remote user? > > -- > 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/523e4274-c75c-485c-80cb-2f27be2e7ade%40googlegroups.com > <https://groups.google.com/d/msgid/ansible-project/523e4274-c75c-485c-80cb-2f27be2e7ade%40googlegroups.com?utm_medium=email&utm_source=footer> > . > 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/CA%2BnsWgwQ1%2B81y-3s6G2MGMHM-zyo_TSN%2BZa-4O2Rq%2BxUs-%3D58Q%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
