This is my ansible inventory file:
[slurm_master]
slurm-gpu-0 ansible_host=192.168.0.24 ansible_connection=local
[slurm_compute]
slurm-gpu-1 ansible_host=192.168.0.200 cpus=16 gpus=2
slurm-gpu-2 ansible_host=192.168.0.124 cpus=1 gpus=0
[slurm_partition_gpu]
slurm-gpu-1
[slurm_partition_gpu:vars]
allow_accounts=['whitelist','gpu_users']
default_partition=no
[slurm_partition_debug]
slurm-gpu-1
slurm-gpu-2
[slurm_partition_debug:vars]
allow_accounts=['whitelist']
default_partition='yes'
[allnodes:children]
slurm_master
slurm_compute
[allnodes:vars]
slurm_partitions=['slurm_partition_gpu','slurm_partition_debug']
I have 2 partitions - "slurm_partition_gpu" and "slurm_partition_debug".
All partitions have the properties *"allow_accounts"* and
*"default_partition"*. So obviously these variables have the same name
across partitions. Also a host is common to both partitions (groups). When
I try to access these using variables using hostvars the variable evaluates
(incorrectly) to the first occurrence in the host file. For example, inside
jinja2 templating:
{{ hostvars[groups['slurm_partition_debug'][0]].allow_accounts }}
results in:
['whitelist','gpu_users']
instead of expected:
['whitelist']
This is obviously because it is looking for "slurm-gpu-1.allow_accounts"
and because slurm-gpu-1 is present in both partitions (groups) it is going
for the first occurrence instead of discriminating between partitions.
How do I get ansible to recognize that the variable is in a *different
group* even though it is associated with the *same host name*? I would like
to take advantage of the fact that even though the variables and host are
same, the group name is unique and hence would like to use the group name
to access the variables.
--
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 ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/14f0a25f-f0d3-4f95-8ffd-fd143348529d%40googlegroups.com.