Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $ ansible --version
- ansible 2.5.1
- config file = /home/ansible/ansible_devel/ansible.cfg
- configured module search path = [u'/home/ansible/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
- ansible python module location = /usr/lib/python2.7/site-packages/ansible
- executable location = /usr/bin/ansible
- python version = 2.7.13 (default, Jan 11 2017, 10:56:06) [GCC]
- ---
- - hosts:
- - localhost
- become: false
- gather_facts: False
- roles:
- pre_tasks:
- tasks:
- - name: "Merge firewall variables"
- set_fact:
- my_list: |
- {%- if my_list is not defined -%}
- {%- set tmp_my_list=[ 1 ] -%}
- {%- else -%}
- {%- set tmp_my_list=my_list -%}
- {%- endif -%}
- {%- set dummy=tmp_my_list.append(item) -%}
- {{ tmp_my_list }}
- with_items:
- - a
- - b
- - c
- - debug: msg="{{ my_list }}"
- $ ansible-playbook test6.yml
- PLAY [localhost] ***************************************************************************************************************************************************************
- TASK [Merge firewall variables] ************************************************************************************************************************************************
- ok: [localhost] => (item=a)
- ok: [localhost] => (item=b)
- ok: [localhost] => (item=c)
- TASK [debug] *******************************************************************************************************************************************************************
- ok: [localhost] => {
- "msg": [
- 1,
- "a",
- "b",
- "c"
- ]
- }
- PLAY RECAP *********************************************************************************************************************************************************************
- localhost : ok=2 changed=0 unreachable=0 failed=0
- $ ansible-playbook test6.yml
- PLAY [localhost] ***************************************************************************************************************************************************************
- TASK [Merge firewall variables] ************************************************************************************************************************************************
- ok: [localhost] => (item=a)
- ok: [localhost] => (item=b)
- ok: [localhost] => (item=c)
- TASK [debug] *******************************************************************************************************************************************************************
- ok: [localhost] => {
- "msg": [
- 1,
- "c"
- ]
- }
- PLAY RECAP *********************************************************************************************************************************************************************
- localhost : ok=2 changed=0 unreachable=0 failed=0
Add Comment
Please, Sign In to add comment