Guest User

Untitled

a guest
May 22nd, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.80 KB | None | 0 0
  1. $ ansible --version
  2. ansible 2.5.1
  3. config file = /home/ansible/ansible_devel/ansible.cfg
  4. configured module search path = [u'/home/ansible/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  5. ansible python module location = /usr/lib/python2.7/site-packages/ansible
  6. executable location = /usr/bin/ansible
  7. python version = 2.7.13 (default, Jan 11 2017, 10:56:06) [GCC]
  8.  
  9. ---
  10. - hosts:
  11. - localhost
  12. become: false
  13. gather_facts: False
  14. roles:
  15. pre_tasks:
  16. tasks:
  17.  
  18. - name: "Merge firewall variables"
  19. set_fact:
  20. my_list: |
  21. {%- if my_list is not defined -%}
  22. {%- set tmp_my_list=[ 1 ] -%}
  23. {%- else -%}
  24. {%- set tmp_my_list=my_list -%}
  25. {%- endif -%}
  26. {%- set dummy=tmp_my_list.append(item) -%}
  27. {{ tmp_my_list }}
  28. with_items:
  29. - a
  30. - b
  31. - c
  32.  
  33. - debug: msg="{{ my_list }}"
  34.  
  35. $ ansible-playbook test6.yml
  36.  
  37. PLAY [localhost] ***************************************************************************************************************************************************************
  38.  
  39. TASK [Merge firewall variables] ************************************************************************************************************************************************
  40. ok: [localhost] => (item=a)
  41. ok: [localhost] => (item=b)
  42. ok: [localhost] => (item=c)
  43.  
  44. TASK [debug] *******************************************************************************************************************************************************************
  45. ok: [localhost] => {
  46. "msg": [
  47. 1,
  48. "a",
  49. "b",
  50. "c"
  51. ]
  52. }
  53.  
  54. PLAY RECAP *********************************************************************************************************************************************************************
  55. localhost : ok=2 changed=0 unreachable=0 failed=0
  56.  
  57. $ ansible-playbook test6.yml
  58.  
  59.  
  60. PLAY [localhost] ***************************************************************************************************************************************************************
  61.  
  62. TASK [Merge firewall variables] ************************************************************************************************************************************************
  63. ok: [localhost] => (item=a)
  64. ok: [localhost] => (item=b)
  65. ok: [localhost] => (item=c)
  66.  
  67. TASK [debug] *******************************************************************************************************************************************************************
  68. ok: [localhost] => {
  69. "msg": [
  70. 1,
  71. "c"
  72. ]
  73. }
  74.  
  75. PLAY RECAP *********************************************************************************************************************************************************************
  76. localhost : ok=2 changed=0 unreachable=0 failed=0
Add Comment
Please, Sign In to add comment