run cmd using password

60 views
Skip to first unread message

nage...@gmail.com

unread,
Aug 13, 2020, 5:08:14 PM8/13/20
to Ansible Project
  Hi Team,

i would like to run this cmd with sudo with vcf password how i can run the cmd with vcf user and password ?

how i can achieve this ? i am not getting proper answer from the google

Playbook:

---
- name: sddc_health
  hosts: sddc_mgr
  tasks:
   - name: heleth check
     command: sudo /opt/vmware/sddc-support/sos --health-check

host file

sddc_mgr ansible_user=vcf ansible_password='test1234!@#$' ansible_ssh_host=10.47.20.4



nage...@gmail.com

unread,
Aug 13, 2020, 5:35:44 PM8/13/20
to Ansible Project
Hi just modify the file, getting below error 

role task :

 name: SDDC Health
  command: sudo /opt/vmware/sddc-support/sos --health-check
  register: find_output
- debug:
      var: find_output
~

Playbook:


---
- name: sddc_health
  hosts: sddc_mgr
  become: yes
  become_user: root
  become_method: su
  roles:
     - role: sddc_health

error:

TASK [Gathering Facts] **********************************************************************************************************************************************************************************************************************
Thursday 13 August 2020  21:24:32 +0000 (0:00:01.683)       0:00:01.889 *******
fatal: [sddc_mgr]: FAILED! => {"msg": "Timeout (12s) waiting for privilege escalation prompt: "}



nage...@gmail.com

unread,
Aug 14, 2020, 9:08:48 AM8/14/20
to Ansible Project
Hi team,

any help greatly appreciated   ?

Luca 'remix_tj' Lorenzetto

unread,
Aug 14, 2020, 9:13:59 AM8/14/20
to ansible...@googlegroups.com
On Thu, Aug 13, 2020 at 11:35 PM nage...@gmail.com <nage...@gmail.com> wrote:
>
> Hi just modify the file, getting below error
>
> role task :
>
> name: SDDC Health
> command: sudo /opt/vmware/sddc-support/sos --health-check
> register: find_output
> - debug:
> var: find_output
> ~
>
> Playbook:
>
>
> ---
> - name: sddc_health
> hosts: sddc_mgr
> become: yes
> become_user: root
> become_method: su
> roles:
> - role: sddc_health
>

Hello, remove become_method: su, and leave the default value, which is
sudo. This will call your command with sudo
If you want to specify a different password for sudo, use the
variable: ansible_become_password.

docs here: https://docs.ansible.com/ansible/latest/user_guide/become.html

Luca

--
"E' assurdo impiegare gli uomini di intelligenza eccellente per fare
calcoli che potrebbero essere affidati a chiunque se si usassero delle
macchine"
Gottfried Wilhelm von Leibnitz, Filosofo e Matematico (1646-1716)

"Internet è la più grande biblioteca del mondo.
Ma il problema è che i libri sono tutti sparsi sul pavimento"
John Allen Paulos, Matematico (1945-vivente)

Luca 'remix_tj' Lorenzetto, http://www.remixtj.net , <lorenze...@gmail.com>

nage...@gmail.com

unread,
Aug 14, 2020, 9:34:16 AM8/14/20
to Ansible Project
Hi Luca,

Thank you,let me try that.

nage...@gmail.com

unread,
Aug 14, 2020, 1:40:45 PM8/14/20
to Ansible Project
worked thank you 
Reply all
Reply to author
Forward
0 new messages