Get indice in variable

11 views
Skip to first unread message

ryad9...@gmail.com

unread,
Mar 5, 2019, 3:53:08 AM3/5/19
to Ansible Project
Hy all,

I have this task :

- set_fact:
      liste_appli: "{{ item.split(',')[3:] }}"
  with_lines: cat /home/ansible/ssh_manager/clef_applicatives.csv
  when: (item.split(',')[1] == ansible_user) and (item.split(',')[2] == inventory_hostname)
  delegate_to: localhost

And i have this task who count number of element in variable liste_appli:

- set_fact:
    long_liste: "{{ liste_appli | length }}"

But content of long_liste is only one number, or i want that this variable content all indice of my variable liste_appli.

Exemple :

liste_appli = "valeur1", "valeur2", "valeur3"

long_liste = [0,1,2]

Someone have idea ?

Thank you very much guy !!

Regards

ryad9...@gmail.com

unread,
Mar 5, 2019, 5:37:46 AM3/5/19
to Ansible Project
Solved,
Reply all
Reply to author
Forward
0 new messages