tasks:
- name: Do Something
shell: "echo 'present: {{ item.netid }}'"
with_items:
- "{{ staff }}"
when: item.state == 'present'
$ ansible-playbook tst.yml
PLAY ***************************************************************************
TASK [setup] *******************************************************************
ok: [localhost]
TASK [Do Something] ************************************************************
changed: [localhost] => (item={u'comment': u'Chris Short', u'state': u'present', u'uid': 12345, u'netid': u'user001'})
skipping: [localhost] => (item={u'comment': u'Bob Jones', u'state': u'absent', u'uid': 12346, u'netid': u'user002'})
PLAY RECAP *********************************************************************
localhost : ok=2 changed=1 unreachable=0 failed=0