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 [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/e5b4d6f9-b896-4aa7-a2bd-1a0680e0bbb2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to