Hi all...
I have the below vars:
client_destinations:
apache-servers:
pre_cmd: '$template custom,"/logs/apache-servers/%source%.log"'
rules:
- var: '$syslogfacility-text'
operator: 'contains'
search: 'local5'
destination: '-?custom'
path: '/logs/apache-servers/*.log'
- var: '$syslogtag'
search: 'apache-access:'
operator: 'contains'
destination: '/logs/apache-servers/access.log'
- var: '$syslogtag'
search: 'apache-error:'
operator: 'contains'
destination: '/logs/apache-servers/error.log'
- destination: '/logs/apache-servers/other.log'
I have the below Jinja2 code *embedded in a playbook*:
- name: Create new log dest
set_fact:
log_dest2: |
[
{% for group in client_destinations.keys() %}
{% set group_dest = client_destinations[group] %}
{% for dest in group_dest.rules %}
{% if dest.destination matches '^-?' %}
'{{ dest.path }}',
{% else %}
'{{ dest.destination }}',
{% endif %}
{% endfor %}
{% endfor %}
]
WIth *"if" *statement in the Jinja2 code, I'm trying to match any
`destination` (in above vars) that *begins *with *-?*. I've tried the
operator *matches* and *starts with*. Nothing works.
( What works is only this - * {% if dest.destination == '-?custom' %}* )
How do I use regex here to achieve the match?
Thanks in advance.
--
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/c3c96e1b-bbcf-4723-b15c-461f4b7b683e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.