# run cmd using password

**URL:** <https://forum.ansible.com/t/run-cmd-using-password/33610>\
**Category:** Ansible Project\
**Created:** [August 13, 2020, 9:08pm UTC](https://forum.ansible.com/t/run-cmd-using-password/33610 "2020-08-13T21:08:14Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nagesh\_sheregar](https://avatars.discourse-cdn.com/v4/letter/n/3ec8ea/32.png) [@Nagesh\_sheregar](https://forum.ansible.com/u/Nagesh_sheregar)\
**Post date:** [August 13, 2020, 9:08pm UTC](https://forum.ansible.com/t/run-cmd-using-password/33610/1 "2020-08-13T21:08:14Z")

</div>

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:

---

<div class="post-metadata">

**Author:** ![Nagesh\_sheregar](https://avatars.discourse-cdn.com/v4/letter/n/3ec8ea/32.png) [@Nagesh\_sheregar](https://forum.ansible.com/u/Nagesh_sheregar)\
**Post date:** [August 13, 2020, 9:35pm UTC](https://forum.ansible.com/t/run-cmd-using-password/33610/2 "2020-08-13T21:35:44Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Nagesh\_sheregar](https://avatars.discourse-cdn.com/v4/letter/n/3ec8ea/32.png) [@Nagesh\_sheregar](https://forum.ansible.com/u/Nagesh_sheregar)\
**Post date:** [August 14, 2020, 1:08pm UTC](https://forum.ansible.com/t/run-cmd-using-password/33610/3 "2020-08-14T13:08:48Z")

</div>

Hi team,

any help greatly appreciated ?

---

<div class="post-metadata">

**Author:** ![Luca\_remix\_tj\_Lorenz](https://avatars.discourse-cdn.com/v4/letter/l/ea666f/32.png) [@Luca\_remix\_tj\_Lorenz](https://forum.ansible.com/u/Luca_remix_tj_Lorenz)\
**Post date:** [August 14, 2020, 1:13pm UTC](https://forum.ansible.com/t/run-cmd-using-password/33610/4 "2020-08-14T13:13:26Z")

</div>

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](https://docs.ansible.com/ansible/latest/user_guide/become.html)

Luca

---

<div class="post-metadata">

**Author:** ![Nagesh\_sheregar](https://avatars.discourse-cdn.com/v4/letter/n/3ec8ea/32.png) [@Nagesh\_sheregar](https://forum.ansible.com/u/Nagesh_sheregar)\
**Post date:** [August 14, 2020, 1:34pm UTC](https://forum.ansible.com/t/run-cmd-using-password/33610/5 "2020-08-14T13:34:16Z")

</div>

Hi Luca,

Thank you,let me try that.

---

<div class="post-metadata">

**Author:** ![Nagesh\_sheregar](https://avatars.discourse-cdn.com/v4/letter/n/3ec8ea/32.png) [@Nagesh\_sheregar](https://forum.ansible.com/u/Nagesh_sheregar)\
**Post date:** [August 14, 2020, 5:40pm UTC](https://forum.ansible.com/t/run-cmd-using-password/33610/6 "2020-08-14T17:40:45Z")

</div>

worked thank you
