# change root password - ned help

**URL:** <https://forum.ansible.com/t/change-root-password-ned-help/34108>\
**Category:** Ansible Project\
**Created:** [October 26, 2020, 5:34pm UTC](https://forum.ansible.com/t/change-root-password-ned-help/34108 "2020-10-26T17:34:50Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tony\_Wong](https://avatars.discourse-cdn.com/v4/letter/t/3ab097/32.png) [@Tony\_Wong](https://forum.ansible.com/u/Tony_Wong)\
**Post date:** [October 26, 2020, 5:34pm UTC](https://forum.ansible.com/t/change-root-password-ned-help/34108/1 "2020-10-26T17:34:50Z")

</div>

inventory file

[esx]  
esx1  
esx2  
esx3  
[esx:vars]  
ansible\_python\_interpreter=/usr/bin/python3

---

<div class="post-metadata">

**Author:** ![Tony\_Wong](https://avatars.discourse-cdn.com/v4/letter/t/3ab097/32.png) [@Tony\_Wong](https://forum.ansible.com/u/Tony_Wong)\
**Post date:** [October 26, 2020, 5:36pm UTC](https://forum.ansible.com/t/change-root-password-ned-help/34108/2 "2020-10-26T17:36:36Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Sebastian\_Meyer](https://avatars.discourse-cdn.com/v4/letter/s/779978/32.png) [@Sebastian\_Meyer](https://forum.ansible.com/u/Sebastian_Meyer)\
**Post date:** [October 27, 2020, 11:37am UTC](https://forum.ansible.com/t/change-root-password-ned-help/34108/3 "2020-10-27T11:37:13Z")

</div>

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"  
> &nbsp;&nbsp;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.

> &nbsp;&nbsp;tasks:  
> &nbsp;&nbsp;&nbsp;&nbsp;- name: "change root pass"  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;community.vmware.vmware\_local\_user\_manager:  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;hostname: " {{ esxi\_hostname }}"  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;username: " {{ esxi\_root\_user }}"  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;password: " {{ esxi\_root\_pass }}"  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;local\_user\_name: "{{ new\_esx\_local\_root\_user }}"  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;local\_user\_password: "{{ new\_esx\_local\_root\_pass }}"  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;state: present  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;validate\_certs: no
> 
> &nbsp;&nbsp;&nbsp;&nbsp;- name: print results  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;debug: msg=" {{ result }}"  
> &nbsp;&nbsp;vars\_files:  
> &nbsp;&nbsp;&nbsp;&nbsp;- answerfile.yml

try something like:

- hosts: esx  
&nbsp;&nbsp;tasks:  
&nbsp;&nbsp;&nbsp;&nbsp;- name: foo  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;bar:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;baz: blah  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;delegate\_to: localhost

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

Sebastian

---

<div class="post-metadata">

**Author:** ![Tony\_Wong](https://avatars.discourse-cdn.com/v4/letter/t/3ab097/32.png) [@Tony\_Wong](https://forum.ansible.com/u/Tony_Wong)\
**Post date:** [October 27, 2020, 1:26pm UTC](https://forum.ansible.com/t/change-root-password-ned-help/34108/4 "2020-10-27T13:26:48Z")

</div>

thanks I got it working now w this
