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/985122a5-a935-4c0b-9b1d-107e85be312e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to