Nested variables and Regex...

25 views
Skip to first unread message

re...@charbonneau.de

unread,
Jul 7, 2017, 6:01:12 AM7/7/17
to Ansible Project
Dear community,

sorry that I have to bother you but I don't get it.

My goal is to create a nested variables which consists of a static text and two other variables. The thing is, the two variables may contain characters that should be "removed".

This is my (java) regex: [\s\,\.\;\-\_]+

And I wanted to do something like that:

elasticsearchclustername: "es{{ server_hostname | regex_replace('([\\s\\,\\.\\;\\-\\_]+)') }}{{ software_version | regex_replace('([\\s\\,\\.\\;\\-\\_]+)') }}"

After that I use the new variable (elasticsearchclustername) within different jinja2 templates. But that is when I get an "recursive loop detected in template" error.

I really hate regex and I would appreciate any input.

Thanks in advance.

René
Message has been deleted

Daniel JD

unread,
Jul 7, 2017, 3:10:19 PM7/7/17
to Ansible Project
Here you go:

elasticsearchclustername: "es{{ (server_hostname + software_version) | regex_replace('[ .,;-]+', '') }}"

re...@charbonneau.de

unread,
Jul 10, 2017, 5:03:40 AM7/10/17
to Ansible Project
Thanks for helping me out. :)

Sadly it looks like that the construct itself is the issue and not the regex. After I resolved the "recursive loop detected in template" issue, I ran into another one. I have to dig into that one first to resolve this entirely.

Nevertheless thanks for your help. :)
Reply all
Reply to author
Forward
0 new messages