Re: [ansible-project] Re: File copy/Create folder on Windows server based upon json output from Powershell

2018-05-17 Thread Lee Drew
Cool. Thanks Jordan. Works a treat. On Thu, 17 May 2018, 7:13 PM Jordan Borean, wrote: > Yep, I would create a hashtable, convert that to JSON and output that. > That way you can parse that into Ansible easily and select whatever key you > want. This is how the PowerShell

[ansible-project] Re: File copy/Create folder on Windows server based upon json output from Powershell

2018-05-17 Thread Jordan Borean
Yep, I would create a hashtable, convert that to JSON and output that. That way you can parse that into Ansible easily and select whatever key you want. This is how the PowerShell modules work as well. Thanks Jordan -- You received this message because you are subscribed to the Google Groups

[ansible-project] Re: File copy/Create folder on Windows server based upon json output from Powershell

2018-05-16 Thread java_cat33
Updated - changed script to now add the two variables into a hashtable that is converted to json - assume this is the correct approach. This can be returned to the script_output registered in the play. On Thursday, May 17, 2018 at 4:49:07 PM UTC+12, java_cat33 wrote: > > Sorry - I've got

[ansible-project] Re: File copy/Create folder on Windows server based upon json output from Powershell

2018-05-16 Thread java_cat33
Sorry - I've got another question(s) related to this. I've modified the PS script to return 2 x json outputs, each assigned to a different PS variable. Each output contains a different file name. Is it possible to return two outputs to the playbook ran off the task that runs the PS script? Can

[ansible-project] Re: File copy/Create folder on Windows server based upon json output from Powershell

2018-05-14 Thread java_cat33
Nice - thanks Jordan. That's easier than what I've just done win_file: path: C:\inetpub\{{ script_filename.Name | regex_replace('.zip$','') }} Thanks again! On Tuesday, May 15, 2018 at 3:56:20 PM UTC+12, Jordan Borean wrote: > > Hey > > There are a few ways to do this, they usually

[ansible-project] Re: File copy/Create folder on Windows server based upon json output from Powershell

2018-05-14 Thread Jordan Borean
Hey There are a few ways to do this, they usually revolve around using filters to "filter" the value into something else. Ansible has a few filters available outside of the standard Jinja2 functions which can be found here

[ansible-project] Re: File copy/Create folder on Windows server based upon json output from Powershell

2018-05-14 Thread java_cat33
Jordan do you know how to strip the ".zip" off the file name? I've been looking at http://jinja.pocoo.org/docs/2.10/templates/#truncate but haven't cracked it yet. On Tuesday, May 15, 2018 at 2:17:32 PM UTC+12, java_cat33 wrote: > > Thanks Jordan! That code worked a treat - really appreciate

[ansible-project] Re: File copy/Create folder on Windows server based upon json output from Powershell

2018-05-14 Thread java_cat33
Thanks Jordan! That code worked a treat - really appreciate your assistance and detailed explanations below. On Tuesday, May 15, 2018 at 12:58:42 PM UTC+12, java_cat33 wrote: > > Firstly - sorry for the noob question. > > I've written a Powershell script that is run from a play that returns in

[ansible-project] Re: File copy/Create folder on Windows server based upon json output from Powershell

2018-05-14 Thread Jordan Borean
The issue you are seeing is that you are using the stdout_lines return value which is the stdout of the script that was run but split into a list on each newline. You want to use the stdout return value from the script which would be the full stdout of your json. The task's would look