need a playbook to change esxi root pass

164 views
Skip to first unread message

Tony Wong

unread,
Oct 23, 2020, 11:28:52 PM10/23/20
to Ansible Project

How do I change the root password on all esxi hosts with a pb?

Tony Wong

unread,
Oct 24, 2020, 9:53:41 AM10/24/20
to Ansible Project
Need help on this please.

my inventory file


[esx]
esx1
esx2
esx3

--------------------------

playbook

---
- name: change root esxi password
  community.vmware.vmware_local_user_manager:
     hostname: '{{ esx_host }}'
     username: root
     password: '{{ esx_root_pass }}'


what else do i need?

Tony Wong

unread,
Oct 24, 2020, 8:07:11 PM10/24/20
to Ansible Project

this is error I get now

The full traceback is:
Traceback (most recent call last):
  File "/tmp/ansible_community.vmware.vmware_local_user_manager_payload_4mdm01xz/ansible_community.vmware.vmware_local_user_manager_payload.zip/ansible_collections/community/vmware/plugins/module_utils/vmware.py", line 25, in <module>
    import requests
ImportError: No module named 'requests'
fatal: [esxhost]: FAILED! => {
    "changed": false,
    "invocation": {
        "module_args": {
            "hostname": "esxhost",
            "local_user_description": null,
            "local_user_name": "root",
            "local_user_password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "port": 443,
            "proxy_host": null,
            "proxy_port": null,
            "state": "present",
            "username": "root",
            "validate_certs": false
        }
    },
    "msg": "Failed to import the required Python library (requests) on esxhost s Python /usr/bin/python3. Please read module documentation and install in the appropriate location. If the required library is installed, but Ansible is using the wrong Python interpreter, please consult the documentation on ansible_python_interpreter"
}

PLAY RECAP ***********************************************************************************************************************************************************************************************
esxhost        : ok=1    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0

Tony Wong

unread,
Oct 24, 2020, 8:07:55 PM10/24/20
to Ansible Project


my playbook

---
- name: "change the root password"
  hosts: all
  tasks:
    - name: "change root pass"
      community.vmware.vmware_local_user_manager:
       hostname: "{{ inventory_hostname }}"
       local_user_name: "{{ esx_local_root_user }}"
       local_user_password: "{{ esx_local_root_pass }}"
       password: "{{ esxi_root_pass }}"
       username: "{{ esxi_root_user }}"
       validate_certs: "n"
  vars_files:
    - answerfile.yml

vinoth kumar

unread,
Oct 25, 2020, 10:55:09 AM10/25/20
to ansible...@googlegroups.com
You need to have pip module to run in target hosts. You might have installed pip package on local host . You can simply run this on localhost . It will work . Make exsi hosts on loop

//Vinoth 

--
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/9bfc856c-8218-47f8-a8ba-ced16e351c57n%40googlegroups.com.

Tony Wong

unread,
Oct 25, 2020, 12:50:59 PM10/25/20
to Ansible Project
but I have all the pip /pip3 python packages installed already

there isnt anything I can install on a remote esxi host

Dick Visser

unread,
Oct 25, 2020, 1:46:28 PM10/25/20
to ansible...@googlegroups.com
I think you need to run this against localhost (i.e. the controlnode)
as this is where you have pyvmomi installed.
The ESXi host name should go as the argument in the task itself.
> To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/f8eaf51b-2913-4ad5-8992-376e49c218f1n%40googlegroups.com.



--
Dick Visser
Trust & Identity Service Operations Manager
GÉANT

Tony Wong

unread,
Oct 26, 2020, 10:58:26 AM10/26/20
to Ansible Project
yes! That did it. Thank you

---
- name: "change the root password"
  hosts: localhost

  tasks:
    - name: "change root pass"
      community.vmware.vmware_local_user_manager:
       hostname: "myesxhost"
       username: "root"
       password: "xxxxxx"
       local_user_name: "root"
       local_user_password: "yyyyyy"
       state: present
       validate_certs: no

but when I change it to read from answer file it not working.

any idea?

---
- name: "change the root password"
  hosts: localhost

  tasks:
    - name: "change root pass"
      community.vmware.vmware_local_user_manager:
       hostname: "{{ inventory_hostname }}"
       username: " {{ esxi_root_user }}"
       password: " {{ esxi_root_pass }}"
       local_user_name: "{{ new_esx_local_root_user }}"
       local_user_password: "{{ new_esx_local_root_pass }}"
       state: present
       validate_certs: no

    - name: print results
      debug: msg=" {{ result }}"
  vars_files:
    - answerfile.yml
Reply all
Reply to author
Forward
0 new messages