Hi,

I've solved this. I thought too complicated. Instead of iterating through 
all members of a group and then fetch the hostvars from each, I now execute 
the task for each member of the group and delegate the action to a specific 
host.

Am Freitag, 29. Mai 2020 22:06:49 UTC+2 schrieb René Gessinger:
>
> Hi,
>
> I want to do this code in ansible:
> foreach($host in $group) {
>   foreach($var in $host.hostvars) {
>     echo $var.key
>     echo $var.value
>   }
> }
>
> The playbook should iterate over all hosts in a specific group. Then it 
> should use a specific variable in hostvars as a list and for every item it 
> should execute a task.
>
> This one is my inventory:
> # GROUPS
>
> #GLOBAL
> [k8:children]
> k8_master
> k8_worker
>
>
> [k8_master]
> vsrvk8c01 k8_label = [ role=master ]
> vsrvk8c02 k8_label = [ role=master ]
>
> [k8_worker]
> vsrvk8w01 k8_label = [ role=worker, loc=1, tier=0 ]
> vsrvk8w02 k8_label = [ role=worker, tier=1, location=US ]
> vsrvk8w03 k8_label = [ role=worker, cap=af ]
>
> I want to label each Kubernetes Node with the correct labels. How can I 
> archive this? Unfortunately, I don't know the correct approach.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-devel/c734e463-2d49-4ec9-9e7f-19f6904dce6c%40googlegroups.com.

Reply via email to