Created
February 24, 2015 19:40
-
-
Save IsoLinearCHiP/98f78fdba5547b9077e3 to your computer and use it in GitHub Desktop.
registering output from shell, normal, with_items, with_dict
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: all | |
| gather_facts: no | |
| connection: local | |
| sudo: no | |
| tasks: | |
| # single | |
| - shell: /bin/echo foo | |
| register: somevar_single | |
| - debug: var=somevar_single | |
| - debug: msg={{ somevar_single.stdout }} | |
| # list | |
| - shell: /bin/echo {{ item }} | |
| register: somevar_list | |
| with_items: | |
| - foo | |
| - bar | |
| - debug: var=somevar_list | |
| - debug: msg={{ somevar_list.results[0].stdout }} | |
| # dictionary | |
| - shell: /bin/echo "{{ item.key }} is {{ item.value }}" | |
| register: somevar_dict | |
| with_dict: | |
| foo: "fu" | |
| bar: "baz" | |
| - debug: var=somevar_dict | |
| - debug: msg="{{ somevar_dict.results[0].stdout }}" # the quotes are important here, since we output more than one word here! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment