main.yml 2.9 KB

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