Run one simple coomand with sudo priviliges.

Hello All,
I would like ask about privileges escalation by sudo.

I need run command on RemoteMachine. User: someone and Command: /usr/local/blah.sh for example

suoders file:

someone RemoteMachine =(root)**/usr/local/blah.sh**

Unfortunately I can’t give permission to switch root, and I can’t give NOPASSWD phrase in sudoers.

I tried by:

`

shell: /usr/local/blah.sh
become: yes
become_method: sudo

`

But it is failed because ansible trying switch to user before run command.

I tried also:

shell: "**sudo** /usr/local/blah.sh"

But this one hanging ansible, because he is waiting for sudo password.

Is there any possibility to just run command with sudo and provide password automatically ?

I will be very happy for help.

Than you Ansible community,
Regards Dawid D.

Hello All,
    I would like ask about privileges escalation by sudo.

    I need run command on *RemoteMachine*. *User: someone* and *Command:
/usr/local/blah.sh *for example

    suoders file:
someone RemoteMachine =(root)*/usr/local/blah.sh*

    Unfortunately I can't give permission to switch root, and *I can't give*
NOPASSWD phrase in sudoers.

    I tried by:
shell: /usr/local/blah.sh
*become: yes*
*become_method: sudo*

    But it is failed because ansible trying switch to user before run
command.

This, the shell module, actually run "sudo /some/python/script" and that script run plain "/usr/local/blah.sh"

    I tried also:
shell: "*sudo* /usr/local/blah.sh"

    But this one hanging ansible, because he is waiting for sudo password.

    Is there any possibility to just run command with sudo and provide
password automatically ?

sudo do support -S for reading the password from stdin.