tasks:
- set_fact: foo="[ 'one', 'two', 'three' ]"
- debug: var=foo
- set_fact: foo="{{foo}} + [ 'four' ]"
- debug: var=foo tasks:
- set_fact: foo="[ 'one' ]"
- debug: var=foo
- set_fact: foo="{{foo}} + [ '{{item}}' ]"
with_items: [ "two", "three" ]
- debug: var=foo tasks:
- name: set foo fact to an array
set_fact: foo="[ 'one' ]"
- debug: var=foo
- set_fact: foo="{{foo}} + [ 'two' ]"
- set_fact: foo="{{foo}} + [ 'three' ]"
- debug: var=foo--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/ca8f953f-6935-48da-9e4f-e02a6a0f95df%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
[root@]# ansible --version
ansible 1.9.2
[root@]# date
Tue Dec 6 22:14:59 CET 2016
[root@]# ansible-playbook play03.yml
PLAY [localhost] **************************************************************
TASK: [set_fact foo="[ 'one' ]"] **********************************************
ok: [localhost]
TASK: [debug var=foo] *********************************************************
ok: [localhost] => {
"var": {
"foo": [
"one"
]
}
}
TASK: [set_fact foo="{{foo}} + [ '{{item}}' ]"] *******************************
ok: [localhost] => (item=two)
ok: [localhost] => (item=three)
TASK: [debug var=foo] *********************************************************
ok: [localhost] => {
"var": {
"foo": [
"one",
"three"
]
}
}
PLAY RECAP ********************************************************************
Playbook run UUID: 0edf4886-bbf9-11e6-9392-005056a3151a
(vagrant) [vagrant@atrebla:vagrant] ansible --version
ansible 2.2.0.0
config file =
configured module search path = Default w/o overrides
(vagrant) [vagrant@atrebla:vagrant] ansible-playbook loop.yml
PLAY [Test set_facts for loop.] ************************************************
TASK [setup] *******************************************************************
ok: [localhost]
TASK [set_fact] ****************************************************************
ok: [localhost]
TASK [debug] *******************************************************************
ok: [localhost] => {
"foo": [
"one"
]
}
TASK [set_fact] ****************************************************************
ok: [localhost] => (item=two)
ok: [localhost] => (item=three)
TASK [debug] *******************************************************************
ok: [localhost] => {
"foo": [
"one",
"two",
"three"
]
}
PLAY RECAP *********************************************************************
localhost : ok=5 changed=0 unreachable=0 failed=0
--
You received this message because you are subscribed to a topic in the Google Groups "Ansible Project" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ansible-project/S2YPj-HJOlM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/35997488-2ddd-4a6a-9d3f-900c6e2cb782%40googlegroups.com.