0
votes

Let's assume i have a role glusterfs which configures a GlusterFS cluster on hosts glusterfs-servers.

Furthermore i have a role storage-clients which wants to mount a volume from this GlusterFS cluster on hosts storage-clients.

So to ensure that the GlusterFS cluster is successfully setup, I added the following to role/storage-clients/meta/main.yml:

---
dependencies:
  - { role: glusterfs, hosts: glusterfs-servers }

But this causes ansible to run the glusterfs role on the hosts in storage-clients which obviously fails.

I have the glusterfs role before the storage-clients role in my playbook, but i wanted to ensure that my roles are as fault-proof as possible.

How is this possible?

1

1 Answers

0
votes

Role's dependencies are applied to the same host, as the main role.

If you need to setup some safety nets, add some checking tasks to your storage-clients role. For example:

- name: Ensure glusterfs servers are ready
  script: check_glusterfs.sh
  delegate_to: '{{ item }}'
  with_items: '{{ groups["glusterfs-servers"] | default([]) }}'
  run_once: yes