Getting an error while patch the esxi host. Please help…
fatal: [localhost]: FAILED! => {“changed”: false, “cmd”: “esxcli software vib install -d /vmfs/volumes/datastore_10.115.81.40/VMware-ESXi-7.0U3n-21930508-depot.zip”, “msg”: “[Errno 2] No such file or directory: b’esxcli’”, “rc”: 2, “stderr”: “”, “stderr_lines”: , “stdout”: “”, “stdout_lines”: }
tasks:
name: ESXi enter maintenance
register: status
vmware_maintenancemode:
hostname: “{{ vcenter_hostname }}”
username: “{{ vcenter_username }}”
password: “{{ vcenter_password }}”
esxi_hostname: “{{ esxi_ip_address }}”
#esxi_password: “{{ esxi_passwd }}”
evacuate: yes
validate_certs: no
timeout: 3600
state: present
delegate_to: localhost
debug: var=status.msg
name: ESXi Install Update
command: “esxcli software vib install -d /vmfs/volumes/datastore_10.115.81.40/VMware-ESXi-7.0U3n-21930508-depot.zip”
register: vib
debug:
msg: vib
kurokobo
(kurokobo)
April 23, 2024, 12:17pm
2
This [localhost]
means that the task is invoked to localhost
instead of your ESXi. You should specify the target node of this task to your ESXi, by changing hosts
on your playbook or delegate_to
on the task.
i tried changing local host to my esxi host ip x.x.x.x but different error now
TASK [ESXi enter maintenance] ***************************************************************************************************************************************************
fatal: [localhost → x.x.x.x]: UNREACHABLE! => {“changed”: false, “msg”: “Failed to connect to the host via ssh: root@x.x.x.x: Permission denied (publickey,keyboard-interactive).”, “unreachable”: true}
tasks:
name: ESXi enter maintenance
register: status
vmware_maintenancemode:
hostname: “{{ vcenter_hostname }}”
username: “{{ vcenter_username }}”
password: “{{ vcenter_password }}”
esxi_hostname: “{{ esxi_ip_address }}”
#esxi_password: “{{ esxi_passwd }}”
evacuate: yes
validate_certs: no
timeout: 3600
state: present
delegate_to: x.x.x.x
debug: var=status.msg
name: ESXi Install Update
command: “esxcli software vib install -d /vmfs/volumes/datastore_x.x.x.x/VMware-ESXi-7.0U3n-21930508-depot.zip”
kurokobo
(kurokobo)
April 23, 2024, 2:21pm
4
The delegate_to: localhost
for the task ESXi enter maintenance
should not be changed. My comment is for the task ESXi Install Update
.
Also you have to enable SSH service on ESXi.
To enable SSH service, you can do it by hand or use community.vmware.vmware_host_service_manager .
After SSH enable via play book but still below error.
i could see host going into MM and ssh also looks good.
TASK [ESXi Install Update] ******************************************************************************************************************************************************
fatal: [localhost]: FAILED! => {“changed”: false, “cmd”: “esxcli software vib install -d /vmfs/volumes/datastore_10.115.81.40/VMware-ESXi-7.0U3n-21930508-depot.zip”, “msg”: “[Errno 2] No such file or directory: b’esxcli’”, “rc”: 2, “stderr”: “”, “stderr_lines”: , “stdout”: “”, “stdout_lines”: }
Please find my play book mentioned below.,
hosts: localhost
gather_facts: no
vars:
vcenter_hostname: “x.x.x.x”
vcenter_username: “administrator@vsphere.local”
vcenter_password: “xxxxxxxxxxxxxx”
esxi_ip_address: “x.x.x.x”
esxi_passwd: “xxxxxxxxxxxxxxxx”
tasks:
name: ESXi enter maintenance
register: status
vmware_maintenancemode:
hostname: “{{ vcenter_hostname }}”
username: “{{ vcenter_username }}”
password: “{{ vcenter_password }}”
esxi_hostname: “{{ esxi_ip_address }}”
#esxi_password: “{{ esxi_passwd }}”
evacuate: yes
validate_certs: no
timeout: 3600
state: present
delegate_to: localhost
debug: var=status.msg
name: Enable TSM-SSH service
register: status
vmware_host_service_manager:
hostname: “{{ vcenter_hostname }}”
username: “{{ vcenter_username }}”
password: “{{ vcenter_password }}”
esxi_hostname: “{{ esxi_ip_address }}”
validate_certs: no
service_name: TSM-SSH
state: present
service_policy: off
delegate_to: localhost
name: ESXi Install Update
command: “esxcli software vib install -d /vmfs/volumes/datastore_x.x.x.x/VMware-ESXi-7.0U3n-21930508-depot.zip”
register: vib
debug:
msg: vib
kurokobo
(kurokobo)
April 23, 2024, 3:47pm
6
Please read my comment above again
This [localhost] means that the task is invoked to localhost instead of your ESXi. You should specify the target node of this task to your ESXi, by changing hosts on your playbook or delegate_to on the task.
1 Like
kurokobo
(kurokobo)
April 23, 2024, 4:09pm
7
The appropriate target node for each task depends on the modules used in the task.
The delegate_to
is used when you want to change the target node of the task from the target nodes which specified by the hosts
in the playbook.
1 Like
Nope still not working …getting below error
fatal: [localhost]: FAILED! => {“changed”: true, “cmd”: “/bin/esxcli software vib install -d /vmfs/volumes/datastore_x.x.x.x/VMware-ESXi-7.0U3n-21930508-depot.zip”, “delta”: “0:00:00.010569”, “end”: “2024-04-24 09:17:58.494133”, “msg”: “non-zero return code”, “rc”: 127, “start”: “2024-04-24 09:17:58.483564”, “stderr”: “/bin/sh: 1: /bin/esxcli: not found”, “stderr_lines”: [“/bin/sh: 1: /bin/esxcli: not found”], “stdout”: “”, “stdout_lines”: }
kurokobo
(kurokobo)
April 24, 2024, 4:32am
9
Hey have you read my comment? My English may have been poor, but I do not want to repeat the same comments any more.
hi…Please read the error once again …the error reports something different not for the localhost issue. I tired all the steps … If you have any idea please reply or else ignore.
msg": “[Errno 2] No such file or directory: b’esxcli’”, “rc”: 2, “stderr”: “”, “stderr_lines”: , “stdout”: “”, “stdout_lines”: }
kurokobo
(kurokobo)
April 24, 2024, 4:54am
11
From the beginning, before I care about the content of the error message, I see the problem with [localhost]
next to fatal:
:
This means that your task is trying to run esxicli
on localhost
with SSH or local connection.
I don’t think this is correct for your task, and that’s why I repeatedly mentioned hosts
and delegate_to
.
If the No such file or directory
error is truly came from ESXi, the line fatal
should start with the ESXi hostname or IP address as follows:
fatal: [<ESXI_HOSTNAME_OR_IP_ADDRESS>]: FAILED! => {“changed”: true, ...
or if the task is delegated to ESXi,
fatal: [localhost -> <ESXI_HOSTNAME_OR_IP_ADDRESS>]: FAILED! => {“changed”: true, ...
mariolenz
(Mario Lenz)
April 24, 2024, 3:46pm
12
I’ve started with ESX 2.5 nearly 20 years ago and I’m also maintaining community.vmware
.
That said, we’re using this collection heavily at work. But I would never use it to update ESXi hosts. I don’t think Ansible is the right tool to do this. Use vCenter Lifecycle Manager for this.
mariolenz
(Mario Lenz)
April 25, 2024, 6:37am
13
If you want to run esxcli commands, maybe you should have a look at Get-EsxCli . We use PowerCLI a lot where Ansible doesn’t feel like the right tool (or community.vmware
simply lacks the functionality we need).