Responsive Ad Area

Share This Post

test

How to run ansible task with multiple array variables?

There is host_vars/my_host.yml file wich include array variables:

---
my_array_variable_1: '"arr1_el1" "arr1_el2"'
my_array_variable_2: '"arr2_el1" 
my_array_variable_3: '"file1" "file2"'

There is task main.yml that doesn’t work as I suppose:


- name: my task.
  shell: |
    echo "{{ my_array_variable_1[] }} {{ my_array_variable_2[] }}" >>/home/user/{{ my_array_variable_3[] }}

1) Ho I can get this result:

# cat /home/user/file1
arr1_el1
arr2_el1
# cat /home/user/file2
arr1_el2
arr2_el1

2) Ho I can get this result:

# cat /home/user/file1
arr1_el1
arr1_el2
arr2_el1
# cat /home/user/file2
arr1_el2
arr1_el2
arr2_el1

3) Ho I can get this result:

# cat /home/user/file1
arr1_el1
arr2_el1
# cat /home/user/file2
arr1_el2 

I’m searching, but can’t find clear example neither ansible official docs nor via search engines.
Please help with result or get url to revelant documentation or example.

Regards


How to run ansible task with multiple array variables?
How to run ansible task with multiple array variables?
test
{$excerpt:n}

Share This Post

Leave a Reply

Your email address will not be Publishedd. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Skip to toolbar