Skip to content

Instantly share code, notes, and snippets.

@halberom
Created May 28, 2014 09:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save halberom/9ff6a085210fed45b75b to your computer and use it in GitHub Desktop.
Save halberom/9ff6a085210fed45b75b to your computer and use it in GitHub Desktop.
passing var to role arg
# /tmp/foo
bar
PLAY [all] ********************************************************************
TASK: [register a fact] *******************************************************
changed: [localhost]
PLAY [all] ********************************************************************
TASK: [tmp | do something] ****************************************************
ok: [localhost] => {
"item": "",
"myvar": "bar"
}
PLAY RECAP ********************************************************************
localhost : ok=2 changed=1 unreachable=0 failed=0
# /etc/ansible/roles/tmp/tasks/main.yml
---
- name: do something
debug: var=myvar
# /etc/ansible/tmp.yml
---
- hosts: all
gather_facts: no
tasks:
- name: register a fact
command: cat /tmp/foo
register: output
- hosts: all
gather_facts: no
roles:
- { role: tmp, myvar: "{{ output.stdout }}" }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment