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 2 x variables in the play be registered for this task? Not just script_result? Another option would be to create a separate script - each script returns a different string that is parsed to playbook......... or create a hashtable...... @ { file1 = string1; file2 = string 2} - then convert this to json? Assuming the hashtable is the recommended approach - the returns json could then be searched for the relevant key name? On Tuesday, May 15, 2018 at 4:20:44 PM UTC+12, java_cat33 wrote: > > 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 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 >> https://docs.ansible.com/ansible/latest/user_guide/playbooks_filters.html. >> In your case you want to use the splitext to split the path between the >> path/filename and the extension like so; >> >> src: C:\Temp\{{ (script_filename.Name|splitext)[0] }} >> >> What we do here is pass the value of script_filename.Name to the filter >> splitext and that ultimately returns a value, in this case returns a tuple >> of (path without extension, extension). We don't want the extension so we >> only get the first element from the return value and because it is a 0 >> based index, 0 is the first element. >> >> Thanks >> >> Jordan >> > -- 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 ansible-project+unsubscr...@googlegroups.com. To post to this group, send email to ansible-project@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/9ca2db6c-1f0f-4915-8bde-90600e145572%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.