Skip to content

Instantly share code, notes, and snippets.

@IsoLinearCHiP
Created February 24, 2015 19:40
Show Gist options
  • Select an option

  • Save IsoLinearCHiP/98f78fdba5547b9077e3 to your computer and use it in GitHub Desktop.

Select an option

Save IsoLinearCHiP/98f78fdba5547b9077e3 to your computer and use it in GitHub Desktop.
registering output from shell, normal, with_items, with_dict
---
- 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