url requires slash at end regex_replace filter

10 views
Skip to first unread message

jepper

unread,
May 31, 2016, 6:40:29 PM5/31/16
to Ansible Project
I'm trying to create a template which contains a URL and must always have a / on the end. So if jenkins_master_url is 'https://xyz.com' ansible must add a /

If someone could help me with the regex_replace I'd be most grateful:

<buildServerUrl>{{ jenkins_master_url|regex_replace('??') }}</buildServerUrl>

Karl E. Jorgensen

unread,
Jun 1, 2016, 6:57:04 AM6/1/16
to ansible...@googlegroups.com
Hi
How about:

<buildServerUrl>{{ jenkins_master_url + (jenkins_master_url.endswith('/')?'/':'') }}</buildServerUrl>

?

Hope this help

--
Karl
Reply all
Reply to author
Forward
0 new messages