Skip to content

Instantly share code, notes, and snippets.

@halberom
Created May 28, 2014 10:34
Show Gist options
  • Save halberom/4dce510435f9757daf22 to your computer and use it in GitHub Desktop.
Save halberom/4dce510435f9757daf22 to your computer and use it in GitHub Desktop.
call role with arg, set_fact
# /etc/ansible/roles/tmp/tasks/main.yml
---
- name: do something with passed var
debug: var=myothervar
- name: do something with set_fact var
debug: var=myvar
PLAY [all] ********************************************************************
TASK: [register a fact] *******************************************************
ok: [localhost]
PLAY [all] ********************************************************************
TASK: [tmp | do something with passed var] ************************************
ok: [localhost] => {
"item": "",
"myothervar": [
"one",
2,
"three"
]
}
TASK: [tmp | do something with set_fact var] **********************************
ok: [localhost] => {
"item": "",
"myvar": [
"one",
2,
"three"
]
}
PLAY RECAP ********************************************************************
localhost : ok=3 changed=0 unreachable=0 failed=0
# /etc/ansible/tmp.yml
---
- hosts: all
gather_facts: no
tasks:
- name: register a fact
set_fact: myvar="['one',2,'three']"
- hosts: all
gather_facts: no
roles:
- { role: tmp, myothervar: "{{ myvar }}" }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment