pre_install.yaml 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. ---
  2. - name: Check that hawkular_metrics_hostname is set
  3. fail: msg='the openshift_metrics_hawkular_hostname variable is required'
  4. when: openshift_metrics_hawkular_hostname is not defined
  5. - name: Check the value of openshift_metrics_cassandra_storage_type
  6. fail:
  7. msg: >
  8. openshift_metrics_cassandra_storage_type ({{ openshift_metrics_cassandra_storage_type }})
  9. is invalid, must be one of: emptydir, pv, dynamic
  10. when:
  11. - openshift_metrics_cassandra_storage_type not in openshift_metrics_cassandra_storage_types
  12. - not (openshift_metrics_heapster_standalone | bool)
  13. - name: list existing secrets
  14. command: >
  15. {{ openshift_client_binary }} -n {{ openshift_metrics_project }}
  16. --config={{ mktemp.stdout }}/admin.kubeconfig
  17. get secrets -o name
  18. register: metrics_secrets
  19. changed_when: false
  20. - name: Get namespace object
  21. oc_obj:
  22. state: list
  23. kind: namespace
  24. name: "{{ openshift_metrics_project }}"
  25. namespace: "{{ openshift_metrics_project }}"
  26. register: openshift_metrics_namespace_object
  27. - name: Get namespace annotations
  28. set_fact:
  29. openshift_metrics_namespace_annotations: >
  30. {{ openshift_metrics_namespace_object.results.results[0].metadata.annotations }}
  31. when:
  32. - openshift_metrics_namespace_object is defined
  33. - openshift_metrics_namespace_object.results is defined
  34. - openshift_metrics_namespace_object.results.results is defined
  35. - openshift_metrics_namespace_object.results.results[0] is defined
  36. - openshift_metrics_namespace_object.results.results[0].metadata is defined
  37. - name: Get namespace fsGroup
  38. set_fact:
  39. openshift_metrics_namespace_fsgroup: >
  40. {{ openshift_metrics_namespace_annotations['openshift.io/sa.scc.supplemental-groups'].split("/")[0] | trim }}
  41. when:
  42. - openshift_metrics_namespace_annotations is defined
  43. - openshift_metrics_namespace_annotations['openshift.io/sa.scc.supplemental-groups'] is defined
  44. - name: Get namespace userID
  45. set_fact:
  46. openshift_metrics_namespace_uid: >
  47. {{ openshift_metrics_namespace_annotations['openshift.io/sa.scc.uid-range'].split("/")[0] | trim }}
  48. when:
  49. - openshift_metrics_namespace_annotations is defined
  50. - openshift_metrics_namespace_annotations['openshift.io/sa.scc.uid-range'] is defined
  51. - name: Get namespace seLinuxOptions
  52. set_fact:
  53. openshift_metrics_namespace_selinux: >
  54. {{ openshift_metrics_namespace_annotations['openshift.io/sa.scc.mcs'] | trim }}
  55. when:
  56. - openshift_metrics_namespace_annotations is defined
  57. - openshift_metrics_namespace_annotations['openshift.io/sa.scc.mcs'] is defined
  58. - fail:
  59. msg: Cannot get annotations on {{ openshift_metrics_project }} namespace
  60. when: >
  61. openshift_metrics_namespace_uid is not defined or
  62. openshift_metrics_namespace_selinux is not defined or
  63. openshift_metrics_namespace_fsgroup is not defined