heketi_setup.yml 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. ---
  2. - name: Create heketi service account
  3. oc_serviceaccount:
  4. namespace: "{{ glusterfs_namespace }}"
  5. name: "heketi-{{ glusterfs_name }}-service-account"
  6. state: present
  7. - name: Add heketi service account to privileged SCC
  8. oc_adm_policy_user:
  9. namespace: "{{ glusterfs_namespace }}"
  10. user: "system:serviceaccount:{{ glusterfs_namespace }}:heketi-{{ glusterfs_name }}-service-account"
  11. resource_kind: scc
  12. resource_name: privileged
  13. state: present
  14. - name: Allow heketi service account to view/edit pods
  15. oc_adm_policy_user:
  16. namespace: "{{ glusterfs_namespace }}"
  17. user: "system:serviceaccount:{{ glusterfs_namespace }}:heketi-{{ glusterfs_name }}-service-account"
  18. resource_kind: role
  19. resource_name: edit
  20. state: present
  21. - import_tasks: heketi_pod_check.yml
  22. - name: Generate heketi config file
  23. template:
  24. src: "heketi.json.j2"
  25. dest: "{{ mktemp.stdout }}/heketi.json"
  26. - import_tasks: get_heketi_key.yml
  27. - name: Generate heketi admin key
  28. set_fact:
  29. glusterfs_heketi_admin_key: "{{ 32 | lib_utils_oo_generate_secret }}"
  30. when: glusterfs_heketi_admin_key is undefined
  31. - name: Generate heketi user key
  32. set_fact:
  33. glusterfs_heketi_user_key: "{{ 32 | lib_utils_oo_generate_secret }}"
  34. until:
  35. - glusterfs_heketi_user_key is defined
  36. - glusterfs_heketi_user_key != glusterfs_heketi_admin_key
  37. delay: 1
  38. retries: 10
  39. when: glusterfs_heketi_user_key is undefined
  40. - name: Copy heketi private key
  41. copy:
  42. src: "{{ glusterfs_heketi_ssh_keyfile | default(omit) }}"
  43. content: "{{ '' if glusterfs_heketi_ssh_keyfile is undefined else omit }}"
  44. dest: "{{ mktemp.stdout }}/private_key"
  45. - name: Create heketi config secret
  46. oc_secret:
  47. namespace: "{{ glusterfs_namespace }}"
  48. state: present
  49. name: "heketi-{{ glusterfs_name }}-config-secret"
  50. force: True
  51. files:
  52. - name: heketi.json
  53. path: "{{ mktemp.stdout }}/heketi.json"
  54. - name: private_key
  55. path: "{{ mktemp.stdout }}/private_key"