Thanks for the replies. This is now solved like this:
host_vars
log: C:\\Program Files (x86)\\Test
roles
- name: Test script
script: "{{ role_path }}/files/test.ps1 {{ links }} *\'{{ log }}\*'"
register: result
- set_fact: test="{{ result.stdout | from_json }}"
- name: Json output
local_action: copy content="{{ vars[item] }}" dest=
"/home/user/ansible/test-{{ item }}-{{ ansible_date_time.date }}.json"
with_items:
- test
As to the json part, yes I am already converting pscustomobjects to json
via ConvertTo-Json, but ansible I had to tell ansible that I only want the
powershell json result returned. Not all the ansible debug info.
Den torsdag den 26. oktober 2017 kl. 21.27.36 UTC+2 skrev J Hawkesworth:
>
> Also, what are you trying to do? It's worth looking at the existing
> windows modules and seeing if they do some of what need.
>
> Powershell has a ConvertTo-Json cmdlet that might well simplify your code,
> but it's worth trying to use the modules as things like idempotency and the
> ability to use check mode become useful once you have got a few things
> automated.
>
> Hope this helps as well,
>
> 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/6bcd40f2-661f-4051-b37f-846d627f9acb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.