Created
February 18, 2018 20:53
-
-
Save VireshDoshi/8dc42b02c38a71e2e3908aed1b85ae73 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 jinja2-map]$ ansible-playbook -i "localhost," ./j2-map-playbook.yml | |
PLAY [localhost] ********************************************************************************************************************************** | |
TASK [establish the first name from the mps dictionary] ******************************************************************************************* | |
ok: [localhost] => { | |
"msg": [ | |
"Tony", | |
"Theresa", | |
"Nigel" | |
] | |
} | |
TASK [establish the last name from the mps dictionary] ******************************************************************************************** | |
ok: [localhost] => { | |
"msg": [ | |
"Blair", | |
"May", | |
"Farage" | |
] | |
} | |
TASK [change to UPPER CASE from the mps dictionary] *********************************************************************************************** | |
ok: [localhost] => { | |
"msg": [ | |
"{U'PARTY': U'LABOUR', U'FIRST_NAME': U'TONY', U'LAST_NAME': U'BLAIR'}", | |
"{U'PARTY': U'CONSERVATIVE', U'FIRST_NAME': U'THERESA', U'LAST_NAME': U'MAY'}", | |
"{U'PARTY': U'UKIP', U'FIRST_NAME': U'NIGEL', U'LAST_NAME': U'FARAGE'}" | |
] | |
} | |
TASK [change last name to UPPER CASE from the mps dictionary] ************************************************************************************* | |
ok: [localhost] => { | |
"msg": [ | |
"BLAIR", | |
"MAY", | |
"FARAGE" | |
] | |
} |
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 | |
connection: local | |
gather_facts: no | |
vars: | |
mps: | |
- first_name: Tony | |
last_name: Blair | |
party: labour | |
- first_name: Theresa | |
last_name: May | |
party: conservative | |
- first_name: Nigel | |
last_name: Farage | |
party: UKIP | |
tasks: | |
- name: establish the first name from the mps dictionary | |
debug: msg={{ mps | map(attribute='first_name') | list }} | |
- name: establish the last name from the mps dictionary | |
debug: msg={{ mps | map(attribute='last_name') | list }} | |
- name: change to UPPER CASE from the mps dictionary | |
debug: msg={{ mps | map('upper') | list }} | |
- name: change last name to UPPER CASE from the mps dictionary | |
debug: msg={{ mps | map(attribute='last_name') | map('upper') | list }} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment