If its all working maybe no need to change but you might want to get your script to write a log file to disk and then use the fetch module (which also works against windows) to pull the results back onto your ansible controller.
Jon On Friday, October 27, 2017 at 7:24:52 AM UTC+1, [email protected] wrote: > > 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/7dde2c12-f896-48a5-8623-b477b9eb8f3d%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
