glusterfs_common.yml 3.3 KB

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