Is it possible to use powercli in Ansible? This is because I am trying to harden an EXSi host but I am trying simpler code first which is disabling SSH service. I’ve created two files, one is for my powercli script and another is a .yml file. However, I encountered an error.
is esxi-host a windows machine? I’m guessing a bit here but it looks to me like powershell isn’t processing the script you are sending to this machine.
I suggest rather than ‘hosts: all’ you define some groups in your inventory and put all the windows hosts in a separate group, and set up the windows-specific connection parameters there.
Also worth considering using the vmware_* modules, which will talk to your vcenter hosts and manage many of the things you might otherwise manage via powercli.
I think you will almost certainly need to delegate the script task to a machine which has powercli installed on it. I think the bare metal esxi host is unlikely to have powercli installed on it.
I am going to say again that it is well worth taking a look at the vmware_guest module (and associated VMware modules). You just delegate the VMware modules to your vcenter and declare what you want in your playbooks and roles, meaning no need to switch into powercli syntax when you need something doing in vsphere.
This is because I’ve to harden my vSphere esxi host using script (powercli) and thus I will be using ansible to automate the script. However, after reading through the vmware_guest module, it seems like the module does not have that relation to what I am doing. Is there anyway that I can incorporate powercli scripts to ansible or is there any module that has some sort of relation of esxi hardening?
Try PowerCLI 10.0 from the Linux box or if you want to use the Windows version of PowerCLI, delegate your tasks to your Windows machine that has PowerCLI installed.
Hi All, I want to do ESXi upgrade by using Ansible from Scratch. Does anyone has sample playbooks for disabling alarm, VMs migration,put hosts in maintenance mode, remove from vCenter and upgrade process then reconnect to vcenter. I’m new to Ansible and very hard to find some sample playbooks for VMs migration from one host to anohter host.
I am maintainer of VMware Ansible modules. I would strongly recommend to use existing VMware Ansible modules since they are tested and works well with existing setups. For current use case like disabling firewall, you can use vmware_host_service_manager module. You can check this stackoverflow answer - https://stackoverflow.com/a/48293497/1075324 for more details.
Yes, It is possible to run powercli scripts against given ESXi. You need to use a Windows machine as a delegate host since powercli will reside and run on that same host. So long story short
Ansible controller will communicate to Windows machine as a delegate host and then that windows machine will communicate to ESXi host.