I want to make a specific loop but don't know the way how to do it

57 views
Skip to first unread message

Julien

unread,
Jul 26, 2018, 10:39:37 AM7/26/18
to Ansible Project
Hi,

Today i'm writting a play and i want to do a specific loop but i dont know to do it, here is the explanation:


I've created a survey on Tower that is defining the {{ tma_name }} var, this var should have one, or multiple entries like the default answer





After this i've created this play:

- name: Creating User Roles groups (1)
  win_domain_group:
    name: GRP-{{ quadri_name }}-{{ tma_name }}-GLS
    organizational_unit: "{{ user_roles_ou }}"
    domain_server: "{{ hds_entity }}"
    scope: domainlocal
    state: absent


The thing i want to do is if there is multiple data in the {{ tma_name }} var, it will replay the module with all {{ tma_name }} vars like a simple [with_items: - this - is - an - example]
I don't know the way of to do this, (maybe my survey type is bad?)

Thank you
Best Regards
Julien.

Patrick Hunt

unread,
Jul 30, 2018, 12:58:00 PM7/30/18
to Ansible Project
If I am understanding correctly it seems as if you could use a loop.  Something like:

- name: creating user roles groups (1)
  win_domain_group:
    name: GRP-{{ quadri_name }}- {{ item }}-GLS
    organizationl_unit:  "{{ user_roles_ou }}"
    domain_server: "{{ hds_entity }}"
    scope: domainlocal
    state: absent
  loop: "{{ tma_name }}"


Julien

unread,
Jul 31, 2018, 4:52:09 AM7/31/18
to Ansible Project
Hello Patrick, thanks for replying

I've forgot some information in my post

{{ tma_name }} have multiple data and {{ hds_entity }} too. The thing that i want to do is for each {{ hds_entity }}, check all {{ tma_name }}

Here is the scheme:

entity1 => tma1, tma2, tma3
entity2 => tma1, tma2, tma3
entity3 => tma1, tma2, tma3

This is the loop that i want to do,

Sorry for this mistake

Best Regards,
Julien

Julien

unread,
Jul 31, 2018, 4:54:02 AM7/31/18
to Ansible Project
And I have one other question,

What kind of variable do the survey type "textarea" return? List ? Dictionnary?

Julien

Julien

unread,
Aug 3, 2018, 5:26:26 AM8/3/18
to Ansible Project
I always need a solution :) up

Virt uass

unread,
Mar 13, 2019, 10:07:01 AM3/13/19
to Ansible Project
Hey,

The solution is to use with_nested instead of with_items

Bye :)
Reply all
Reply to author
Forward
0 new messages