Skip to content

Instantly share code, notes, and snippets.

@jgornick
Last active August 13, 2017 14:31
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jgornick/0586deadad6bb2693f03 to your computer and use it in GitHub Desktop.
Save jgornick/0586deadad6bb2693f03 to your computer and use it in GitHub Desktop.
Ansible: with_items and selectattr equalto
---
- name: with_items and selectattr equalto
hosts: 127.0.0.1
connection: local
sudo: no
vars:
users:
- username: user1
state: present
name: User 1
keys:
- pub-key-01
groups:
- www-data
- username: user2
state: present
name: User 2
keys:
- pub-key-02
groups:
- admin
tasks:
- debug: >
var=item
with_items: >
users | selectattr("username", "equalto", "user1") | list
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment