Dear all,
I'm at a loss as to how to filter entries fom a dictionry based von
specific host variables. In the concrete case we have a long list of
possible NFS mounts which should be applied according to the hosts' class.
Our hostlist would be like:
host1 class=cluster
host2 class=cluster
host3 class=server
our dictionary of possible mounts would e.g. be:
---
/mnt/1:
name: /mnt/1
src: server:/exports/1
fstype: nfs
state: mounted
class:
- cluster
/mnt/2:
name: /mnt/2
src: server:/exports/2
fstype: nfs
state: mounted
class:
- cluster
- server
/mnt/3:
name: /mnt/3
src: server:/exports/3
fstype: nfs
state: mounted
class:
- cluster
...
I.e I'd like all three mounts to be available on hosts of the class
"cluster" and /mnt/2 (but not the other two mounts) on hosts of the
class "server".
The current playbook (which applies all mounts to all hosts) is
---
- hosts: '{{ target }}'
gather_facts: no
serial: 5
tasks:
- include_vars:
file: ./mounts-dict.yml
name: fs
- name: "Add NFS mounts"
mount:
name: "{{ item.value.name }}"
fstype: "{{ item.value.fstype }}"
src: "{{ item.value.src }}"
state: "{{ item.value.state }}"
with_dict: "{{ fs }}"
...
The playbook is run with `ansible-playbook ./nfs-mounts.yml
--extra-vars="target=<hostname>".
What I'd need is a syntax, which checks for each mount in the
dictionary, if one of it's (possibly multiple) classes matches the
(single) class of the server and then applies the mount. I could not
find a usable Jinja-Syntax which I could use together with `when`. I'd
appreciate any hint or pointer to achieve this task.
Thanks
frank
--
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/a0fbe52c-a1bc-f33e-985e-216dac495630%40drosera.ch.
For more options, visit https://groups.google.com/d/optout.