For reference, this is a continuation of:!topic/ansible-project/XhU9iPXjjcw

Can you use multiple when statements in a loop? or is there a different way 
to approach this without having to write out a task for each item?  Take 
the following for example.  I know the syntax is wrong, but it gives you a 
better idea of what I mean.

    - name: Insert audit rules
        path: "/etc/audit/audit.rules"
        line: "{{ item.line }}"
        regexp: "{{ item.regexp }}"
        state: present
        insertafter: EOF
      notify: Restart auditd
        - { line: '-w /home/GOMER/Scripts -p w -k copperfield', regexp: 
'.*GOMER.*Scripts.*' }
          when: directories.results.0.stat.exists
        - { line: '-w /home/PYLE/Scripts -p w -k copperfield', regexp: 
'.*PYLE*Scripts.*' }  
          when: directories.results.1.stat.exists

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 post to this group, send email to
To view this discussion on the web visit
For more options, visit

Reply via email to