Re: [ansible-project] Need help to find how to run root command with non-root user and escalated privilages

2018-05-22 Thread 'Kallu Srikanth' via Ansible Project

Brian, Actually it worked instead of removing -n i added "default: '-H -S" 
at the end of the file

Thank you very much, I really appreciate it 


On Monday, May 21, 2018 at 10:35:10 PM UTC-5, Brian Coca wrote:
>
> You seem to have a non standard/old sudo, change the default 
> become_flags as they seem to be causing the problem, specifically, 
> remove -n (default: '-H -S -n' 
> ) 
>
> -- 
> -- 
> Brian Coca 
>

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/43f9f0d6-09a3-4fbe-aac4-cfc3a3dc200f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Need help to find how to run root command with non-root user and escalated privilages

2018-05-22 Thread abhay srivastava
Are you able to do sudo without password

On Tue 22 May, 2018, 10:05 PM 'Kallu Srikanth' via Ansible Project, <
ansible-project@googlegroups.com> wrote:

>
> Hi Abhay i still have the error
>
> Code : -
> ---
> - hosts: dpie_prod
>   user: dpiesa
>   become: true
>   become_method: enable
>   tasks:
>   - name: install telnet
> yum: pkg=telnet state=present update_cache=true
>
> ERROR:
>
> fatal: [lind01]: FAILED! => {"changed": false, "module_stderr": "Shared
> connection to lind01.\r\n", "module_stdout": "sudo: illegal option
> `-n'\r\nusage: sudo -h | -K | -k | -L | -l | -V | -v\r\nusage: sudo
> [-bEHPS] [-p prompt] [-u username|#uid] [VAR=value]\r\n{-i | -s
> | }\r\nusage: sudo -e [-S] [-p prompt] [-u username|#uid] file
> ...\r\n", "msg": "MODULE FAILURE", "rc": 1}
>
> But I can run this successfully manually on a server like this without
> password
> #dpiesa@lind01:/home/dpiesa> sudo yum install telnet
>
> Also can become root like this
>
> dpiesa@lind01:/home/dpiesa> become
> root@lind01:/root>
> On Monday, May 21, 2018 at 10:59:42 PM UTC-5, abhay srivastava wrote:
>>
>> Try:
>>
>> - hosts: dpie_prod
>>   user: dpiesa
>>   become:  True
>>   tasks:
>>   - name: install telnet
>> yum: pkg=telnet state=installed update_cache=true
>> #command: sudo yum install telnet -y
>>
>>
>>
>>
>> On Sat, May 19, 2018 at 12:56 AM, 'Kallu Srikanth' via Ansible Project <
>> ansible...@googlegroups.com> wrote:
>>
>>> Hi,
>>>
>>> I highly appreciate if anybody can help, please
>>>
>>> ###  playbook  ##
>>>
>>> - hosts: dpie_prod
>>>   user: dpiesa
>>>   tasks:
>>>   - name: install telnet
>>> yum: pkg=telnet state=installed update_cache=true
>>> #command: sudo yum install telnet -y
>>> become: yes
>>> become_user: root
>>> become_method: sudo
>>>
>>> The above does not work and throws this error
>>>
>>> TASK [install telnet]
>>> 
>>>  [WARNING]: Module invocation had junk after the JSON data: usage: sudo
>>> -e [-S] [-p prompt] [-u username|#uid] file ...
>>>
>>> fatal: [lind01.corp.acxiom.net]: FAILED! => {"changed": false,
>>> "module_stderr": "Shared connection to lind01.corp.acxiom.net
>>> closed.\r\n", "module_stdout": "sudo: illegal option `-n'\r\nusage: sudo -h
>>> | -K | -k | -L | -l | -V | -v\r\nusage: sudo [-bEHPS] [-p prompt] [-u
>>> username|#uid] [VAR=value]\r\n{-i | -s | }\r\nusage:
>>> sudo -e [-S] [-p prompt] [-u username|#uid] file ...\r\n", "msg": "MODULE
>>> FAILURE", "rc": 1}
>>> to retry, use: --limit
>>> @/home/dpiesa/playbooks/install_telnet.retry
>>>
>>>
>>> ##
>>>
>>> But below works
>>>
>>> - hosts: dpie_prod
>>>   user: dpiesa
>>>   tasks:
>>>   - name: install telnet
>>> command: sudo yum install telnet -y
>>>
>>>
>>> 
>>>
>>> [dpiesa@cwypatch06 playbooks]$ ansible --version
>>> ansible 2.5.2
>>>   config file = /etc/ansible/ansible.cfg
>>>   configured module search path =
>>> [u'/home/dpiesa/.ansible/plugins/modules',
>>> u'/usr/share/ansible/plugins/modules']
>>>   ansible python module location =
>>> /usr/lib/python2.7/site-packages/ansible
>>>   executable location = /bin/ansible
>>>   python version = 2.7.5 (default, Aug  4 2017, 00:39:18) [GCC 4.8.5
>>> 20150623 (Red Hat 4.8.5-16)]
>>>
>>>
>>> I think I am not using become options correctly can somebody help ??
>>>
>>> Thank you.
>>>
>>> --
>>> 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 ansible-proje...@googlegroups.com.
>>> To post to this group, send email to ansible...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/ansible-project/2de5f3d4-b9b8-45be-b0c2-8941e4c55c52%40googlegroups.com
>>> 
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>>
>> --
>> Regards,
>> Abhay Srivastava
>> ---
>> Mob-9160512000
>>
> --
> 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 ansible-project+unsubscr...@googlegroups.com.
> To post to this group, send email to ansible-project@googlegroups.com.
> To view this discussion on the web visit
> 

Re: [ansible-project] Need help to find how to run root command with non-root user and escalated privilages

2018-05-22 Thread 'Kallu Srikanth' via Ansible Project

Hi Abhay i still have the error

Code : -
---
- hosts: dpie_prod
  user: dpiesa
  become: true
  become_method: enable
  tasks:
  - name: install telnet
yum: pkg=telnet state=present update_cache=true

ERROR: 

fatal: [lind01]: FAILED! => {"changed": false, "module_stderr": "Shared 
connection to lind01.\r\n", "module_stdout": "sudo: illegal option 
`-n'\r\nusage: sudo -h | -K | -k | -L | -l | -V | -v\r\nusage: sudo 
[-bEHPS] [-p prompt] [-u username|#uid] [VAR=value]\r\n{-i | -s 
| }\r\nusage: sudo -e [-S] [-p prompt] [-u username|#uid] file 
...\r\n", "msg": "MODULE FAILURE", "rc": 1}

But I can run this successfully manually on a server like this without 
password 
#dpiesa@lind01:/home/dpiesa> sudo yum install telnet

Also can become root like this

dpiesa@lind01:/home/dpiesa> become
root@lind01:/root>
On Monday, May 21, 2018 at 10:59:42 PM UTC-5, abhay srivastava wrote:
>
> Try:
>
> - hosts: dpie_prod
>   user: dpiesa
>   become:  True
>   tasks:
>   - name: install telnet
> yum: pkg=telnet state=installed update_cache=true
> #command: sudo yum install telnet -y
> 
>
>
>
> On Sat, May 19, 2018 at 12:56 AM, 'Kallu Srikanth' via Ansible Project <
> ansible...@googlegroups.com > wrote:
>
>> Hi, 
>>
>> I highly appreciate if anybody can help, please
>>
>> ###  playbook  ##
>>
>> - hosts: dpie_prod
>>   user: dpiesa
>>   tasks:
>>   - name: install telnet
>> yum: pkg=telnet state=installed update_cache=true
>> #command: sudo yum install telnet -y
>> become: yes
>> become_user: root
>> become_method: sudo
>>
>> The above does not work and throws this error
>>
>> TASK [install telnet] 
>> 
>>  [WARNING]: Module invocation had junk after the JSON data: usage: sudo 
>> -e [-S] [-p prompt] [-u username|#uid] file ...
>>
>> fatal: [lind01.corp.acxiom.net]: FAILED! => {"changed": false, 
>> "module_stderr": "Shared connection to lind01.corp.acxiom.net 
>> closed.\r\n", "module_stdout": "sudo: illegal option `-n'\r\nusage: sudo -h 
>> | -K | -k | -L | -l | -V | -v\r\nusage: sudo [-bEHPS] [-p prompt] [-u 
>> username|#uid] [VAR=value]\r\n{-i | -s | }\r\nusage: 
>> sudo -e [-S] [-p prompt] [-u username|#uid] file ...\r\n", "msg": "MODULE 
>> FAILURE", "rc": 1}
>> to retry, use: --limit 
>> @/home/dpiesa/playbooks/install_telnet.retry
>>
>>
>> ##
>>
>> But below works
>>
>> - hosts: dpie_prod
>>   user: dpiesa
>>   tasks:
>>   - name: install telnet
>> command: sudo yum install telnet -y
>>
>>
>> 
>>
>> [dpiesa@cwypatch06 playbooks]$ ansible --version
>> ansible 2.5.2
>>   config file = /etc/ansible/ansible.cfg
>>   configured module search path = 
>> [u'/home/dpiesa/.ansible/plugins/modules', 
>> u'/usr/share/ansible/plugins/modules']
>>   ansible python module location = 
>> /usr/lib/python2.7/site-packages/ansible
>>   executable location = /bin/ansible
>>   python version = 2.7.5 (default, Aug  4 2017, 00:39:18) [GCC 4.8.5 
>> 20150623 (Red Hat 4.8.5-16)]
>>
>>
>> I think I am not using become options correctly can somebody help ??
>>
>> Thank you.
>>
>> -- 
>> 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 ansible-proje...@googlegroups.com .
>> To post to this group, send email to ansible...@googlegroups.com 
>> .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/ansible-project/2de5f3d4-b9b8-45be-b0c2-8941e4c55c52%40googlegroups.com
>>  
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> -- 
> Regards,
> Abhay Srivastava
> ---
> Mob-9160512000
>

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/573867fd-3869-4395-a0d1-7c20fb415e7c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Need help to find how to run root command with non-root user and escalated privilages

2018-05-22 Thread 'Kallu Srikanth' via Ansible Project
Not sure how can I specifically remove this -n 

Below is my code/error/other info if you can help, please 

Code : -
---
- hosts: dpie_prod
  user: dpiesa
  become: yes
  become_method: enable
  tasks:
  - name: install telnet
yum: pkg=telnet state=present update_cache=true

ERROR: 

fatal: [lind01]: FAILED! => {"changed": false, "msg": "You need to be root 
to perform this command.\n", "rc": 1, "results": ["Loaded plugins: 
fastestmirror, package_upload, product-id, search-disabled-\n  
: repos, security, subscription-manager\n"]}

But I can run this successfully manually on a server like this without 
password 
#dpiesa@lind01:/home/dpiesa> sudo yum install telnet

Also can become root like this

dpiesa@lind01:/home/dpiesa> become
root@lind01:/root>



On Monday, May 21, 2018 at 10:35:10 PM UTC-5, Brian Coca wrote:
>
> You seem to have a non standard/old sudo, change the default 
> become_flags as they seem to be causing the problem, specifically, 
> remove -n (default: '-H -S -n' 
> ) 
>
> -- 
> -- 
> Brian Coca 
>

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/f6dd1c80-7dfb-4090-a3f6-2cfda49f56c5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Need help to find how to run root command with non-root user and escalated privilages

2018-05-21 Thread abhay srivastava
Try:

- hosts: dpie_prod
  user: dpiesa
  become:  True
  tasks:
  - name: install telnet
yum: pkg=telnet state=installed update_cache=true
#command: sudo yum install telnet -y




On Sat, May 19, 2018 at 12:56 AM, 'Kallu Srikanth' via Ansible Project <
ansible-project@googlegroups.com> wrote:

> Hi,
>
> I highly appreciate if anybody can help, please
>
> ###  playbook  ##
>
> - hosts: dpie_prod
>   user: dpiesa
>   tasks:
>   - name: install telnet
> yum: pkg=telnet state=installed update_cache=true
> #command: sudo yum install telnet -y
> become: yes
> become_user: root
> become_method: sudo
>
> The above does not work and throws this error
>
> TASK [install telnet] **
> 
> **
>  [WARNING]: Module invocation had junk after the JSON data: usage: sudo -e
> [-S] [-p prompt] [-u username|#uid] file ...
>
> fatal: [lind01.corp.acxiom.net]: FAILED! => {"changed": false,
> "module_stderr": "Shared connection to lind01.corp.acxiom.net
> closed.\r\n", "module_stdout": "sudo: illegal option `-n'\r\nusage: sudo -h
> | -K | -k | -L | -l | -V | -v\r\nusage: sudo [-bEHPS] [-p prompt] [-u
> username|#uid] [VAR=value]\r\n{-i | -s | }\r\nusage:
> sudo -e [-S] [-p prompt] [-u username|#uid] file ...\r\n", "msg": "MODULE
> FAILURE", "rc": 1}
> to retry, use: --limit @/home/dpiesa/playbooks/
> install_telnet.retry
>
> 
> 
> ##
>
> But below works
>
> - hosts: dpie_prod
>   user: dpiesa
>   tasks:
>   - name: install telnet
> command: sudo yum install telnet -y
>
> 
> 
> 
>
> [dpiesa@cwypatch06 playbooks]$ ansible --version
> ansible 2.5.2
>   config file = /etc/ansible/ansible.cfg
>   configured module search path = [u'/home/dpiesa/.ansible/plugins/modules',
> u'/usr/share/ansible/plugins/modules']
>   ansible python module location = /usr/lib/python2.7/site-
> packages/ansible
>   executable location = /bin/ansible
>   python version = 2.7.5 (default, Aug  4 2017, 00:39:18) [GCC 4.8.5
> 20150623 (Red Hat 4.8.5-16)]
>
>
> I think I am not using become options correctly can somebody help ??
>
> Thank you.
>
> --
> 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 ansible-project+unsubscr...@googlegroups.com.
> To post to this group, send email to ansible-project@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/ansible-project/2de5f3d4-b9b8-45be-b0c2-8941e4c55c52%40googlegroups.
> com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Regards,
Abhay Srivastava
---
Mob-9160512000

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAPKgz8WjUHardGxCm5inSdxQRMh6Yw6cBc_GWEVWhp%3DrfGnUkg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Need help to find how to run root command with non-root user and escalated privilages

2018-05-21 Thread David Villasmil
I think if you set 'become' then you don't need to use sudo.
Also, why don't you use the module to install packages instead of executing
yum?
http://docs.ansible.com/ansible/latest/modules/yum_module.html

Example:

- name: install one specific version of Apache
  yum:
name: httpd-2.2.29-1.4.amzn1
state: present

On Tue, May 22, 2018, 05:35 Brian Coca  wrote:

> You seem to have a non standard/old sudo, change the default
> become_flags as they seem to be causing the problem, specifically,
> remove -n (default: '-H -S -n'
> )
>
> --
> --
> Brian Coca
>
> --
> 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 ansible-project+unsubscr...@googlegroups.com.
> To post to this group, send email to ansible-project@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/CACVha7dTfoP38R2wh8itmi1OsyV9-8wrOO686FYjLbNZ%3DEFJ9Q%40mail.gmail.com
> .
> 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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAFGRPVr5DsZP_NrSwR7rZ0EL3y1dLh4XdKQ6j9FgnQiH5wRjeQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Need help to find how to run root command with non-root user and escalated privilages

2018-05-21 Thread Brian Coca
You seem to have a non standard/old sudo, change the default
become_flags as they seem to be causing the problem, specifically,
remove -n (default: '-H -S -n'
)

-- 
--
Brian Coca

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CACVha7dTfoP38R2wh8itmi1OsyV9-8wrOO686FYjLbNZ%3DEFJ9Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Need help to find how to run root command with non-root user and escalated privilages

2018-05-18 Thread 'Kallu Srikanth' via Ansible Project
Hi, 

I highly appreciate if anybody can help, please

###  playbook  ##

- hosts: dpie_prod
  user: dpiesa
  tasks:
  - name: install telnet
yum: pkg=telnet state=installed update_cache=true
#command: sudo yum install telnet -y
become: yes
become_user: root
become_method: sudo

The above does not work and throws this error

TASK [install telnet] 

 [WARNING]: Module invocation had junk after the JSON data: usage: sudo -e 
[-S] [-p prompt] [-u username|#uid] file ...

fatal: [lind01.corp.acxiom.net]: FAILED! => {"changed": false, 
"module_stderr": "Shared connection to lind01.corp.acxiom.net closed.\r\n", 
"module_stdout": "sudo: illegal option `-n'\r\nusage: sudo -h | -K | -k | 
-L | -l | -V | -v\r\nusage: sudo [-bEHPS] [-p prompt] [-u username|#uid] 
[VAR=value]\r\n{-i | -s | }\r\nusage: sudo -e [-S] [-p 
prompt] [-u username|#uid] file ...\r\n", "msg": "MODULE FAILURE", "rc": 1}
to retry, use: --limit @/home/dpiesa/playbooks/install_telnet.retry

##

But below works

- hosts: dpie_prod
  user: dpiesa
  tasks:
  - name: install telnet
command: sudo yum install telnet -y



[dpiesa@cwypatch06 playbooks]$ ansible --version
ansible 2.5.2
  config file = /etc/ansible/ansible.cfg
  configured module search path = 
[u'/home/dpiesa/.ansible/plugins/modules', 
u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/site-packages/ansible
  executable location = /bin/ansible
  python version = 2.7.5 (default, Aug  4 2017, 00:39:18) [GCC 4.8.5 
20150623 (Red Hat 4.8.5-16)]


I think I am not using become options correctly can somebody help ??

Thank you.

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/2de5f3d4-b9b8-45be-b0c2-8941e4c55c52%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.