glusterfs_common.yml 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. ---
  2. - name: Make sure heketi-client is installed
  3. package:
  4. name: heketi-client
  5. state: present
  6. when:
  7. - not glusterfs_heketi_is_native | bool
  8. register: result
  9. until: result is succeeded
  10. - name: Verify heketi-cli is installed
  11. shell: "command -v {{ glusterfs_heketi_cli }} >/dev/null 2>&1 || { echo >&2 'ERROR: Make sure heketi-cli is available, then re-run the installer'; exit 1; }"
  12. changed_when: False
  13. when:
  14. - not glusterfs_heketi_is_native | bool
  15. - name: Verify target namespace exists
  16. oc_project:
  17. state: present
  18. name: "{{ glusterfs_namespace }}"
  19. node_selector: "{% if glusterfs_use_default_selector %}{{ omit }}{% endif %}"
  20. when: glusterfs_is_native or glusterfs_heketi_is_native or glusterfs_storageclass
  21. - name: Add namespace service accounts to privileged SCC
  22. oc_adm_policy_user:
  23. user: "system:serviceaccount:{{ glusterfs_namespace }}:{{ item }}"
  24. resource_kind: scc
  25. resource_name: privileged
  26. state: present
  27. with_items:
  28. - 'default'
  29. - 'router'
  30. when: glusterfs_is_native or glusterfs_heketi_is_native
  31. - import_tasks: glusterfs_deploy.yml
  32. when: glusterfs_is_native
  33. - name: Start glusterd (external)
  34. service:
  35. name: glusterd
  36. state: started
  37. enabled: yes
  38. delegate_to: "{{ item }}"
  39. with_items: "{{ glusterfs_nodes | default([]) }}"
  40. when:
  41. - not glusterfs_is_native | bool
  42. - import_tasks: heketi_setup.yml
  43. when: glusterfs_heketi_is_native
  44. # This must always be run. There are tasks further on in the play that require
  45. # require these variables to be properly set, even if the tasks are skipped, so
  46. # that Ansible can properly parse the tasks.
  47. - import_tasks: heketi_pod_check.yml
  48. - import_tasks: heketi_init_deploy.yml
  49. when:
  50. - glusterfs_heketi_is_native
  51. - glusterfs_heketi_deploy_is_missing
  52. - glusterfs_heketi_is_missing
  53. - import_tasks: heketi_load.yml
  54. when:
  55. - glusterfs_heketi_topology_load
  56. - import_tasks: heketi_init_db.yml
  57. when:
  58. - glusterfs_heketi_is_native
  59. - not glusterfs_heketi_deploy_is_missing
  60. - glusterfs_heketi_is_missing
  61. - glusterfs_heketi_topology_load
  62. - import_tasks: heketi_deploy.yml
  63. when:
  64. - glusterfs_heketi_is_native
  65. - glusterfs_heketi_is_missing
  66. - block:
  67. - name: Create heketi secret
  68. oc_secret:
  69. namespace: "{{ glusterfs_namespace }}"
  70. state: present
  71. name: "heketi-{{ glusterfs_name }}-admin-secret"
  72. type: "kubernetes.io/glusterfs"
  73. force: True
  74. contents:
  75. - path: key
  76. data: "{{ glusterfs_heketi_admin_key }}"
  77. when:
  78. - glusterfs_heketi_admin_key is defined
  79. - name: Generate GlusterFS StorageClass file
  80. template:
  81. src: "glusterfs-storageclass.yml.j2"
  82. dest: "{{ mktemp.stdout }}/glusterfs-storageclass.yml"
  83. - name: Create GlusterFS StorageClass
  84. oc_obj:
  85. state: present
  86. kind: storageclass
  87. name: "glusterfs-{{ glusterfs_name }}"
  88. files:
  89. - "{{ mktemp.stdout }}/glusterfs-storageclass.yml"
  90. when: glusterfs_storageclass
  91. - import_tasks: glusterblock_deploy.yml
  92. when: glusterfs_block_deploy
  93. - import_tasks: glusterblock_storageclass.yml
  94. when: glusterfs_block_storageclass
  95. - import_tasks: gluster_s3_deploy.yml
  96. when:
  97. - glusterfs_s3_deploy
  98. - glusterfs_s3_account is defined
  99. - glusterfs_s3_user is defined
  100. - glusterfs_s3_password is defined