So I have an on-line form in ansible tower that lets people pick a group to
included in. I'm trying to set it up so they can pick multiple groups, but
I'm having a tough time writing the logical checks I need.
In any other programming language I could load the array and write a for
loop to go through every element and if one of them doesn't exist, rewrite
a binary variable that would be used in further logical checks. Something
like this:
groups = [group1, group2, group3, ... ]
does_not_exist_check_variable = 0
for i = 1:length(groups)
if group(i) does not exist
does_not_exist_check_variable = 1
end if
end
In ansible, the closest thing I can find to a for loop is with_item which
in all of the text I've read so far implies that the command is to be used
to supplement certain items into a configuration one after another. I've
attempted to recreate my for loop and if statements like this:
- name: Create dne_check variable
set_fact: dne_check = 0
- name: Get groups names
shell: item.value.access.find('{{ group_names }}')
register: all_group_names
- name: Check for blank group names
set_fact: dne_check = 1
with_items:" {{all_group_names}}"
when: item == -1
But it complains about my syntax at the last when statement. Any help on
the matter would be greatly appreciated.
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/ed54a82f-0bb6-4797-a152-597ea9b00a0f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.