Thank you, its worked:

---
- name: sddc_health
  hosts: sddc_mgr
  become: yes
  become_user: root
  become_method: su
  tasks:
    - name: sddc health
      command: /opt/vmware/sddc-support/sos --health-check
      register: find_output
    - debug:
        var: find_output
  vars:
    become_password: "{{ ansible_password }}"


On Friday, August 14, 2020 at 1:21:25 PM UTC-5 dick....@geant.org wrote:

> Hi 
>
> It seems there is a lot of wheel reinventing going on by using expect/sudo 
> to handle privilege escalation. 
> Instead use the already existing privilege escalation options:
>
> https://docs.ansible.com/ansible/latest/user_guide/become.html
>
>
>
> On Fri, 14 Aug 2020 at 19:57, nage...@gmail.com <nage...@gmail.com> wrote:
>
>> Oh sorry, please find the below details 
>>
>> host file 
>> [root@6683ffa58609 cpc-vcf]# cat hosts.ini
>> sddc_mgr ansible_user=vcf ansible_password='xxxxxxxxxxxxxxxxxx' 
>> ansible_ssh_host=10.47.20.4
>>
>> [root@6683ffa58609 cpc-vcf]#
>> Playbook:
>> ---
>> - name: sddc_health
>>   hosts: sddc_mgr
>>   tasks:
>>    - name: sddc health
>>      expect:
>>          command: sudo /opt/vmware/sddc-support/sos --health-check
>>          responses:
>>             (?i)[sudo] password for vcf: "{{ ansible_password }}"
>>
>>
>> On Friday, August 14, 2020 at 12:53:37 PM UTC-5 dick....@geant.org wrote:
>>
>>> You forgot to post the playbook you're using, and the inventory, and the 
>>> ansible configuration.
>>>
>>> On Fri, 14 Aug 2020 at 19:42, nage...@gmail.com <nage...@gmail.com> 
>>> wrote:
>>>
>>
>>>> Hi team,
>>>>
>>>> i am getting below error, pexpect already installed
>>>>
>>>> he full traceback is:
>>>> Traceback (most recent call last):
>>>>   File "/tmp/ansible_expect_payload_0bz7tQ/__main__.py", line 108, in 
>>>> <module>
>>>>     import pexpect
>>>> ImportError: No module named pexpect
>>>>
>>>> fatal: [sddc_mgr]: FAILED! => {
>>>>     "changed": false,
>>>>     "invocation": {
>>>>         "module_args": {
>>>>             "chdir": null,
>>>>             "command": "sudo /opt/vmware/sddc-support/sos 
>>>> --health-check",
>>>>             "creates": null,
>>>>             "echo": false,
>>>>             "removes": null,
>>>>             "responses": {
>>>>                 "(?i)[sudo] password for vcf": "xxxxxxxxxxxxxxxxxxxxx"
>>>>             },
>>>>             "timeout": 30
>>>>         }
>>>>     },
>>>>     "msg": "Failed to import the required Python library (pexpect) on 
>>>> lab.local.com's Python /usr/bin/python2.7. Please read module 
>>>> documentation and install in the appropriate location"
>>>>
>>>> [root@6683ffa58609 cpc-vcf]# pip show pexpect
>>>> DEPRECATION: Python 2.7 reached the end of its life on January 1st, 
>>>> 2020. Please upgrade your Python as Python 2.7 is no longer maintained. 
>>>> pip 
>>>> 21.0 will drop support for Python 2.7 in January 2021. More details about 
>>>> Python 2 support in pip, can be found at 
>>>> https://pip.pypa.io/en/latest/development/release-process/#python-2-support
>>>> Name: pexpect
>>>> Version: 4.8.0
>>>> Summary: Pexpect allows easy control of interactive console 
>>>> applications.
>>>> Home-page: https://pexpect.readthedocs.io/
>>>> Author: Noah Spurrier; Thomas Kluyver; Jeff Quast
>>>>
>>> Author-email: no...@noah.org, tho...@kluyver.me.uk, con...@jeffquast.com
>>>> License: ISC license
>>>> Location: /usr/lib/python2.7/site-packages
>>>> Requires: ptyprocess
>>>> Required-by:
>>>> [root@6683ffa58609 cpc-vcf]#
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> -- 
>>>>
>>>>
>>>> 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 view this discussion on the web visit 
>>>> https://groups.google.com/d/msgid/ansible-project/3010b803-5f63-4d76-87f5-a86143093722n%40googlegroups.com
>>>>  
>>>> <https://groups.google.com/d/msgid/ansible-project/3010b803-5f63-4d76-87f5-a86143093722n%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>> .
>>>>
>>>>
>>>> -- 
>>> Sent from a mobile device - please excuse the brevity, spelling and 
>>> punctuation.
>>>
>>>
>>>
>>
>>
>>
>>
>>
>>
>>
>> -- 
>>
>>
>> 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 view this discussion on the web visit 
>> https://groups.google.com/d/msgid/ansible-project/c54fb004-49cb-42bb-ac89-8d01f45c629cn%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/ansible-project/c54fb004-49cb-42bb-ac89-8d01f45c629cn%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>>
>> -- 
> Sent from a mobile device - please excuse the brevity, spelling and 
> punctuation.
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/2046a057-3068-4e7a-98b9-3daec9d96bb2n%40googlegroups.com.

Reply via email to