Extracting list members with test in list attribute

Skip to first unread message

Darren S.

Jan 12, 2019, 4:14:29 PM1/12/19
to pocoo-libs
Hoping for a hand with this, I haven't been able to get the logic right.

I have the following YAML list:

  - name: admin1
    state: present
    full_name: Admin 1
    groups: [sudo]
  - name: admin2
    state: present
    full_name: Admin 2
    groups: []
  - name: paul
    state: present
    full_name: Paul
    groups: [kids]
    locked: true
  - name: munin
    state: present
    full_name: Munin
    groups: [sudo, kids]
    locked: false

I'm trying to extact a list of kids' account names, i.e. list of users that have 'kids' in their groups attribute (which is itself a list). For the above data, the desired outcome is to produce the following list to work with:


I tried to fit this into map() and selectattr() approaches but couldn't figure out how to structure a test to evaluate inclusion of a value in a list.

- Darren
Reply all
Reply to author
0 new messages