So basically my ESXi host is a bare-metal installation. The script that was
stated above is running from my Ubuntu VM in my own laptop.
On Wednesday, May 24, 2017 at 12:37:00 AM UTC+8, J Hawkesworth wrote:
>
>
> 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.
>
> Hope this helps,
>
> Jon
> On Monday, May 22, 2017 at 12:48:42 PM UTC+1, Bob Nian wrote:
>>
>> 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.
>>
>> This is how it look:
>> *script.ps1*
>>
>> Get-VMHost | Foreach {
>> {Stop-VMHostService -HostService ($_ | Get-VMHostService | Where
>> {$_.Key -eq $
>> }
>>
>> *playbook.yml*
>> ---
>> # This playbook tests the script module on ESXi hosts
>>
>> - name: Run powercli script
>> hosts: all
>> gather_facts: false
>> tasks:
>> - name: Run powercli script
>> script: script.ps1
>>
>> *Error*
>>
>>
>>
>> *fatal: [esxi-host]: FAILED! => {"changed": true, "failed": true, "rc":
>> 2, "stderr": "Shared connection to 192.168.1.190 closed.\r\n", "stdout":
>> "//.ansible/tmp/ansible-tmp-1495450802.21-237546974052981/script.ps1: line
>> 1: Get-VMHost: not
>> found\r\n//.ansible/tmp/ansible-tmp-1495450802.21-237546974052981/script.ps1:
>>
>> line 1: Foreach: not
>> found\r\n//.ansible/tmp/ansible-tmp-1495450802.21-237546974052981/script.ps1:
>>
>> line 2: syntax error: unexpected \"(\"\r\n", "stdout_lines":
>> ["//.ansible/tmp/ansible-tmp-1495450802.21-237546974052981/script.ps1: line
>> 1: Get-VMHost: not found",
>> "//.ansible/tmp/ansible-tmp-1495450802.21-237546974052981/script.ps1: line
>> 1: Foreach: not found",
>> "//.ansible/tmp/ansible-tmp-1495450802.21-237546974052981/script.ps1: line
>> 2: syntax error: unexpected \"(\""]} [WARNING]: Could not create retry file
>> '/etc/ansible/playbook.retry'.[Errno 13] Permission denied:
>> u'/etc/ansible/playbook.retry'*
>>
>
--
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/320045a1-7172-4c1e-8beb-fc87bc0b23a1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.