Created
February 18, 2018 21:08
-
-
Save VireshDoshi/213e90cc172bbf8489bf0cf2cadc0e3a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[vdo023@localhost selectattr]$ ansible-playbook -i "localhost," ./selectattr-playbook.yml | |
PLAY [localhost] ********************************************************************************************************************************** | |
TASK [extract the emails for users without a password] ******************************************************************************************** | |
ok: [localhost] | |
TASK [debug message] ****************************************************************************************************************************** | |
ok: [localhost] => ([email protected]) => { | |
"changed": false, | |
"item": "[email protected]", | |
"msg": "email this user [email protected] and ask them to set a password" | |
} | |
ok: [localhost] => ([email protected]) => { | |
"changed": false, | |
"item": "[email protected]", | |
"msg": "email this user [email protected] and ask them to set a password" | |
} | |
PLAY RECAP **************************************************************************************************************************************** | |
localhost : ok=2 changed=0 unreachable=0 failed=0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- hosts: localhost | |
gather_facts: False | |
connection: local | |
vars: | |
users: | |
- name: john | |
email: [email protected] | |
- name: jane | |
email: [email protected] | |
- name: fred | |
email: [email protected] | |
password: 123!abc | |
tasks: | |
- name: extract the emails for users without a password | |
set_fact: | |
emails: "{{ users | selectattr('password', 'undefined') | map(attribute='email') | list }}" | |
- name: debug message | |
debug: | |
msg: "email this user {{ item }} and ask them to set a password" | |
with_items: "{{ emails }}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment