Hi all...
I've a list of dicts like the below:
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'
old-web:
rules:
- var: '$syslogfacility-text'
operator: '=='
search: 'local3'
destination: '/logs/web/dyn.log'
- var: '$syslogfacility-text'
operator: '=='
search: 'local2'
destination: '/logs/web/activity.log'
mx-catchall:
rules:
- destination: '/logs/mx/mail.log'
switches:
pre_cmd: '$template network,"/logs/network/%source%.log"'
rules:
- destination: '-?network'
path: '/logs/network/*.log'
I need to form a "list" of values of `destination` (which are mostly
file-paths). But, in case of `rules` that have non-file path values (like
'-?custom', '-?network') in `destination`, I need to ignore this value, and
instead, get the value of `path`. So far, I have come up with a task that
generates `logf_dest`, a "list", ignoring non-file paths:
- name: Collect log destinations
set_fact:
logf_dest: "{{ client_destinations.values() |
map(attribute='rules') | list | flatten | map(attribute='destination') |
reject('match', '-[?]') | list }}"
The downside to this is that while it successfully ignores `destination`
that has non-file path values, it doesn't include the corresponding value
of `path` in place of the ignored `destination` value. How do I achieve
this?
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/bc742620-2239-4d4f-bf68-0a9947689d13%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.