You'll still need to get powershell to return json to standard out, 
otherwise ansible will not be able to understand what happened when your 
module ran.

Matt Martz's example above is about as simple as a module could be - the 
Exit-Json cmdlet returns the $result object as JSON.

Hope this helps,

Jon

On Monday, October 24, 2016 at 2:30:53 PM UTC+1, Raj wrote:
>
> Yes, if this works on Linux host (I am using rhel7) that would be great. 
> Please note that my control server (ansible server) and powershell host are 
> different. 
> The module as simple as this is not working:
>
> #!/usr/bin/powershell
> # WANT_JSON
> # POWERSHELL_COMMON
>
> "some test text" | Out-File /tmp/testfile.txt
>
> Getting following error:
> FAILED! => {
>     "changed": false,
>     "failed": true,
>     "invocation": {
>         "module_name": "mymodule2.ps1"
>     },
>     "module_stderr": "",
>     "module_stdout": "\u001b[?1h\u001b=",
>     "msg": "MODULE FAILURE",
>     "parsed": false
> }
>
> But file actually created with some encoded string on the target host:
> $ cat /tmp/testfile.txt
> ▒▒some test text
>
>
>
>
> On Sunday, October 23, 2016 at 11:37:32 AM UTC-5, Trond Hindenes wrote:
>>
>> I tested this using Ubuntu shortly after the PowerShell beta for Linux 
>> was out, and did not have any problems. Simply put, it should work. Let me 
>> know if you're still blocked by this and I can fire up a test vm tomorrow 
>> to verify.
>>
>>
>>
>>
>> On Sunday, October 23, 2016 at 9:45:17 AM UTC+2, J Hawkesworth wrote:
>>>
>>> I know I am a bit late to this thread, and I guess it is possible you 
>>> have a lot of powercli written already, but it might be worth your while 
>>> investigating the existing vsphere and wmware modules.
>>>
>>> Jon
>>>
>>

-- 
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/a0c8915d-d400-422d-94f6-95a6c1ce784e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to