change root password - ned help

inventory file

[esx]
esx1
esx2
esx3
[esx:vars]
ansible_python_interpreter=/usr/bin/python3

but when i put static value into the main.yml file it works

Hi Tony,

answer file

esxi_hostname: '{{ inventory_hostname }}'

^ you are setting esxi_hostname to inventory_hostname.

esxi_root_user: 'root'
esxi_root_pass: 'xxx'
new_esx_local_root_user: 'root'
new_esx_local_root_pass: 'yyy'

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

playbook file

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

^ you connect to localhost, so inventory_hostname = localhost

Ansible does not care which hosts are in your inventory, inventory_hostname is
always the host the task is run on/for.

  tasks:
    - name: "change root pass"
      community.vmware.vmware_local_user_manager:
       hostname: " {{ esxi_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

try something like:

- hosts: esx
  tasks:
    - name: foo
      bar:
        baz: blah
      delegate_to: localhost

Then the task should be run once for each host, but always on localhost.

Sebastian

thanks I got it working now w this