Hi

Is this what you are looking for??

---

- hosts: localhost

  gather_facts: no



  tasks:

    - name: Run a command as stephen.maher

      command: whoami

      become: yes

      become_method: sudo

      become_user: stephen.maher

      register: output


    - debug:

        var: output.stdout_lines



    - name: Run a command as root

      command: whoami

      become: yes

      become_method: sudo

      become_user: root

      register: output


    - debug:

        var: output.stdout_lines



$ ansible-playbook  test.yml




PLAY [localhost]
***********************************************************************************************************************************************************************************************


TASK [Run a command as stephen.maher]
**************************************************************************************************************************************************************************

changed: [localhost]


TASK [debug]
***************************************************************************************************************************************************************************************************

ok: [localhost] => {

    "output.stdout_lines": [

        "stephen.maher"

    ]

}


TASK [Run a command as nobody]
*********************************************************************************************************************************************************************************

changed: [localhost]


TASK [debug]
***************************************************************************************************************************************************************************************************

ok: [localhost] => {

    "output.stdout_lines": [

        "root"

    ]

}


PLAY RECAP
*****************************************************************************************************************************************************************************************************

localhost                  : ok=4    changed=2    unreachable=0    failed=0
  skipped=0    rescued=0    ignored=0




On Wed, 21 Aug 2019 at 13:15, Karther <[email protected]> wrote:

> Hey all !!
>
> Ok thanks very much community ansible for your help !! :)
>
> It's very pity that ansible not can play the same playbook on the same
> host with different user ...
>
> Thanks very much for your help !! :)
>
> Regards,
>
> Karther
>
> Le mardi 20 août 2019 17:00:33 UTC+2, Karther a écrit :
>>
>> Hey,
>>
>> I want to know if possible use a lot of user for ansible.
>>
>> Exemple, if i use *ansible_user=user1, user2*
>>
>> because i want to use *serial: 1*
>>
>> And i want that ansible use firt user1 and secondaly user2
>>
>> If possible or not please ??
>>
>> Regards,
>>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/1aeb59b1-aff3-44a6-b530-b2284013169e%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/1aeb59b1-aff3-44a6-b530-b2284013169e%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>


-- 

Regards,

Stephen Maher

[email protected] | 0777 5832553

UNIX Engineer

Ocado Technology, Buildings One & Two, Trident Place, Mosquito Way,
Hatfield, Hertfordshire,

AL10 9UL

ocado.com <http://www.ocado.com/>

Need some work done by any of the Infrastructure Teams? Click here!
<https://engage-infra.oca.do/>

-- 


Notice: 
This email is confidential and may contain copyright material of 
members of the Ocado Group. Opinions and views expressed in this message 
may not necessarily reflect the opinions and views of the members of the 
Ocado Group.

If you are not the intended recipient, please notify us 
immediately and delete all copies of this message. Please note that it is 
your responsibility to scan this message for viruses.

References to the 
"Ocado Group" are to Ocado Group plc (registered in England and Wales with 
number 7098618) and its subsidiary undertakings (as that expression is 
defined in the Companies Act 2006) from time to time. The registered office 
of Ocado Group plc is Buildings One & Two, Trident Place, Mosquito Way, 
Hatfield, Hertfordshire, AL10 9UL.

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAAQBYytRy5_zvNONVT0nszGqjo8OK9MD%3D%2BbLVZSk4cTf%3DfVeeQ%40mail.gmail.com.

Reply via email to