main.yml 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. - name: "Ensure group {{ gluster_vol_group }} exists"
  2. include_role:
  3. name: add_group
  4. vars:
  5. add_group_groups: "{{ gluster_vol_group }}"
  6. - name: Mount the data dev
  7. include_role:
  8. name: mount
  9. vars:
  10. mount_path: "{{ gluster_vol_datadir }}"
  11. mount_owner: "{{ gluster_vol_owner }}"
  12. mount_group: "{{ gluster_vol_group }}"
  13. mount_mode: "{{ gluster_vol_perms }}"
  14. mount_dev: "{{ gluster_vol_dev }}"
  15. mount_fs: xfs
  16. register: gluster_vol_mounted
  17. when: gluster_vol_dev is defined
  18. - name: Notice volume device changes
  19. debug: msg="Gluster device mounted @ {{ gluster_vol_datadir }}"
  20. notify: gluster_vol_restart
  21. when: gluster_vol_mounted.changed
  22. - name: Init volume paths
  23. file:
  24. path: "{{ item }}"
  25. owner: "{{ gluster_vol_owner }}"
  26. group: "{{ gluster_vol_group }}"
  27. mode: "{{ gluster_vol_perms }}"
  28. state: directory
  29. loop: [ "{{ gluster_vol_datadir }}", "{{ gluster_vol_brick }}" ]
  30. - name: "Create {{ gluster_vol_name }}"
  31. gluster.gluster.gluster_volume:
  32. state: present
  33. start_on_create: false
  34. replicas: "{{ gluster_vol_replicas }}"
  35. name: "{{ gluster_vol_name }}"
  36. bricks: "{{ gluster_vol_brick }}"
  37. cluster: "{{ gluster_vol_cluster }}"
  38. # This seems to be busted in the module
  39. #options:
  40. # {
  41. # client.ssl: "{{ gluster_vol_ssl }}",
  42. # server.ssl: "{{ gluster_vol_ssl }}",
  43. # ssl.certificate-depth: "{{ gluster_vol_cert_depth }}",
  44. # auth.ssl-allow: "{ gluster_vol_ssl_allow }}",
  45. # ssl.cipher-list: "{{ gluster_vol_ciphers }}"
  46. # }
  47. run_once: true
  48. register: gluster_vol_create
  49. notify: gluster_vol_restart
  50. - name: Build options for {{ gluster_vol_name }}
  51. set_fact:
  52. gluster_vol_options:
  53. {
  54. client.ssl: "{{ gluster_vol_ssl }}",
  55. server.ssl: "{{ gluster_vol_ssl }}",
  56. auth.ssl-allow: "{{ gluster_vol_ssl_allow }}",
  57. ssl.certificate-depth: "{{ gluster_vol_cert_depth }}",
  58. ssl.cipher-list: "{{ gluster_vol_ciphers }}",
  59. }
  60. when: gluster_vol_options is not defined
  61. - name: Set options for {{ gluster_vol_name }}
  62. include_tasks: options.yml
  63. loop: "{{ gluster_vol_options | dict2items }}"
  64. - name: Set handler volume (because Ansible sucks)
  65. set_fact:
  66. gluster_vol_handler: "{{ gluster_vol_name }}"
  67. - name: Handlers break
  68. meta: flush_handlers
  69. - name: "Ensure {{ gluster_vol_name }} is started"
  70. gluster.gluster.gluster_volume:
  71. state: started
  72. name: "{{ gluster_vol_name }}"
  73. register: gluster_vol_started
  74. run_once: true
  75. - name: Give it a second...
  76. wait_for:
  77. timeout: 1
  78. when: gluster_vol_started.changed
  79. - name: Check for sensible status for volume {{ gluster_vol_name }}
  80. command:
  81. argv:
  82. - gluster
  83. - volume
  84. - status
  85. - "{{ gluster_vol_name }}"
  86. register: gluster_vol_status
  87. changed_when: false
  88. failed_when: >-
  89. gluster_vol_status.rc != 0 or
  90. 'is not started' in gluster_vol_status.stderr or
  91. '4915' not in gluster_vol_status.stdout
  92. run_once: true