su in ansible doesn't look like that.

Be sure you have set user appropriately, but you should use the native su
or sudo constructs.  sudo is preferred, but su works as well.

  ---
  - hosts: host1
    su: True
    su_user: user1
    tasks:
      - name: run ls -l
        shell: "ls -l"

There's various reasons for the machinery, but a lot of it has do how
modules are transferred.

In Ansible, you should avoid interactive commands, and you'll probably need
to specify --ask-su-pass or --ask-sudo-pass as appropriate.




On Mon, Jul 28, 2014 at 11:16 AM, weichi cheng <[email protected]> wrote:

> Just go through a few tutorials of Ansible and am trying to see if I can
> use it to replace our 'tcl expect' template engine in house.
>
> We have an internal server inside a isolated domain that have 'root'
> access to most of the internal boxes from other domains.
> The template engine's job is to execute commands supplied in a file and
> run as uid that will be input to the template engine also. The template
> engine either successfully run all commands or stop at the first failed
> command and return error and output.
>
> a simple test like below hang forever.
>
>   ---
>   - hosts: host1
>     user: root
>     tasks:
>       - name: run as user1 on host1 and with ls -l
>         shell: "su - user1; ls -l"
>
>
> Is this kind of task achievable?
>
> Thanks for any insight!
> Jack Cheng
>
> --
> 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/7cac515a-ab6f-4069-b39e-dce88485395e%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/7cac515a-ab6f-4069-b39e-dce88485395e%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%2BnsWgxYR1p0Q3ibwbMRzTwkR_A9FBv1_L2ZuSL2wF5MGr8zug%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to