install.yaml 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. ---
  2. - name: Create temp directory for doing work in on target
  3. command: mktemp -td openshift-cluster-monitoring-ansible-XXXXXX
  4. register: mktemp
  5. changed_when: False
  6. - name: Copy files to temp directory
  7. copy:
  8. src: "{{ item }}"
  9. dest: "{{ mktemp.stdout }}/{{ item }}"
  10. with_items:
  11. - cluster-monitoring-operator.yaml
  12. - name: Copy admin client config
  13. command: >
  14. cp {{ openshift.common.config_base }}/master/admin.kubeconfig {{ mktemp.stdout }}/admin.kubeconfig
  15. changed_when: false
  16. - name: Add monitoring project
  17. oc_project:
  18. state: present
  19. name: openshift-monitoring
  20. description: Openshift Monitoring
  21. node_selector: ""
  22. - name: Label monitoring namespace
  23. oc_label:
  24. state: present
  25. kind: namespace
  26. name: openshift-monitoring
  27. labels:
  28. - key: openshift.io/cluster-monitoring
  29. value: "true"
  30. - name: Apply the cluster monitoring operator template
  31. shell: >
  32. {{ openshift_client_binary }} process -n openshift-monitoring -f "{{ mktemp.stdout }}/{{ item }}"
  33. --param OPERATOR_IMAGE="{{ openshift_cluster_monitoring_operator_image }}"
  34. --param PROMETHEUS_OPERATOR_IMAGE="{{ openshift_cluster_monitoring_operator_prometheus_operator_repo }}"
  35. --param ALERTMANAGER_IMAGE="{{ openshift_cluster_monitoring_operator_alertmanager_repo }}"
  36. --param PROMETHEUS_IMAGE="{{ openshift_cluster_monitoring_operator_prometheus_repo }}"
  37. --param PROMETHEUS_CONFIG_RELOADER_IMAGE="{{ openshift_cluster_monitoring_operator_prometheus_reloader_repo }}"
  38. --param CONFIG_RELOADER_IMAGE="{{ openshift_cluster_monitoring_operator_configmap_reloader_repo }}"
  39. --param ALERTMANAGER_CONFIG="{{ openshift_cluster_monitoring_operator_alertmanager_config | b64encode }}"
  40. --param CLUSTER_ID="{{ openshift_cluster_monitoring_operator_cluster_id }}"
  41. --param PROMETHEUS_STORAGE_CAPACITY="{{ openshift_cluster_monitoring_operator_prometheus_storage_capacity }}"
  42. --param ALERTMANAGER_STORAGE_CAPACITY="{{ openshift_cluster_monitoring_operator_alertmanager_storage_capacity }}"
  43. --config={{ mktemp.stdout }}/admin.kubeconfig
  44. | {{ openshift_client_binary }} apply --config={{ mktemp.stdout }}/admin.kubeconfig -f -
  45. with_items:
  46. - cluster-monitoring-operator.yaml
  47. - name: Wait for the ServiceMonitor CRD to be created
  48. command: "{{ openshift_client_binary }} get crd servicemonitors.monitoring.coreos.com -n openshift-monitoring --config={{ mktemp.stdout }}/admin.kubeconfig"
  49. register: crd
  50. until: crd.rc == 0
  51. delay: 30
  52. retries: 30
  53. - name: Delete temp directory
  54. file:
  55. name: "{{ mktemp.stdout }}"
  56. state: absent
  57. changed_when: False