Another way to state my requirement:

Form a list of values of `destination`. And, in `rules` where `destination` 
and `path` occur together, ignore `destination` and take up corresponding 
value of `path`. My desired output:

logf_dest:
   - /logs/apache-servers/*.log
   - /logs/apache-servers/access.log
   - /logs/apache-servers/error.log
   - /logs/apache-servers/other.log
   - /logs/web/dyn.log
   - /logs/web/activity.log
   - /logs/mx/mail.log
   - /logs/network/*.log

Thanks.

On Wednesday, 20 March 2019 05:02:00 UTC+5:30, Ashok wrote:
>
> 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/52f166d7-3ab4-4e3e-9266-99e8a6b21bf0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to