topology.json.j2 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. {
  2. "clusters": [
  3. {%- set clusters = {} -%}
  4. {%- for node in glusterfs_nodes -%}
  5. {%- set cluster = hostvars[node].glusterfs_cluster if 'glusterfs_cluster' in hostvars[node] else '1' -%}
  6. {%- if cluster in clusters -%}
  7. {%- set _dummy = clusters[cluster].append(node) -%}
  8. {%- else -%}
  9. {%- set _dummy = clusters.update({cluster: [ node, ]}) -%}
  10. {%- endif -%}
  11. {%- endfor -%}
  12. {%- for cluster in clusters -%}
  13. {
  14. "nodes": [
  15. {%- for node in clusters[cluster] -%}
  16. {
  17. "node": {
  18. "hostnames": {
  19. "manage": [
  20. {%- if 'glusterfs_hostname' in hostvars[node] -%}
  21. "{{ hostvars[node].glusterfs_hostname }}"
  22. {%- elif 'openshift' in hostvars[node] -%}
  23. "{{ hostvars[node].openshift.node.nodename }}"
  24. {%- else -%}
  25. "{{ node }}"
  26. {%- endif -%}
  27. ],
  28. "storage": [
  29. {%- if 'glusterfs_ip' in hostvars[node] -%}
  30. "{{ hostvars[node].glusterfs_ip }}"
  31. {%- else -%}
  32. "{{ hostvars[node].openshift.common.ip }}"
  33. {%- endif -%}
  34. ]
  35. },
  36. "zone": {{ hostvars[node].glusterfs_zone | default(1) }}
  37. },
  38. "devices": [
  39. {%- for device in hostvars[node].glusterfs_devices -%}
  40. "{{ device }}"{% if not loop.last %},{% endif %}
  41. {%- endfor -%}
  42. ]
  43. }{% if not loop.last %},{% endif %}
  44. {%- endfor -%}
  45. ]
  46. }{% if not loop.last %},{% endif %}
  47. {%- endfor -%}
  48. ]
  49. }