install.yaml 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. ---
  2. - name: Ensure that Cluster Monitoring Operator has nodes to run on
  3. import_role:
  4. name: openshift_control_plane
  5. tasks_from: ensure_nodes_matching_selector.yml
  6. vars:
  7. openshift_master_ensure_nodes_selector: "{{ openshift_cluster_monitoring_operator_node_selector | map_to_pairs }}"
  8. openshift_master_ensure_nodes_service: Cluster Monitoring Operator
  9. - name: Create temp directory for doing work in on target
  10. command: mktemp -td openshift-cluster-monitoring-ansible-XXXXXX
  11. register: mktemp
  12. changed_when: False
  13. - set_fact:
  14. tempdir: "{{ mktemp.stdout }}"
  15. - name: Copy files to temp directory
  16. copy:
  17. src: "{{ item }}"
  18. dest: "{{ tempdir }}/{{ item }}"
  19. with_items:
  20. - cluster-monitoring-operator.yaml
  21. - name: Create templates subdirectory
  22. file:
  23. state: directory
  24. path: "{{ tempdir }}/{{ item }}"
  25. mode: 0755
  26. changed_when: False
  27. with_items:
  28. - templates
  29. - name: Copy admin client config
  30. command: >
  31. cp {{ openshift.common.config_base }}/master/admin.kubeconfig {{ mktemp.stdout }}/admin.kubeconfig
  32. changed_when: false
  33. - name: Add monitoring project
  34. oc_project:
  35. state: present
  36. name: openshift-monitoring
  37. description: Openshift Monitoring
  38. node_selector: ""
  39. - name: Label monitoring namespace
  40. oc_label:
  41. state: present
  42. kind: namespace
  43. name: openshift-monitoring
  44. labels:
  45. - key: openshift.io/cluster-monitoring
  46. value: "true"
  47. - when: os_sdn_network_plugin_name == 'redhat/openshift-ovs-multitenant'
  48. block:
  49. - name: Waiting for netnamespace openshift-monitoring to be ready
  50. oc_obj:
  51. kind: netnamespace
  52. name: openshift-monitoring
  53. state: list
  54. register: get_output
  55. until: not get_output.results.stderr is defined
  56. retries: 30
  57. delay: 1
  58. changed_when: false
  59. - name: Make openshift-monitoring project network global
  60. command: >
  61. {{ openshift_client_binary }} --config={{ mktemp.stdout }}/admin.kubeconfig adm pod-network make-projects-global openshift-monitoring
  62. - name: Apply the cluster monitoring operator ServiceAccount, Roles and Alertmanager config
  63. shell: >
  64. {{ openshift_client_binary }} process -n openshift-monitoring -f "{{ mktemp.stdout }}/{{ item }}"
  65. --param ALERTMANAGER_CONFIG="{{ openshift_cluster_monitoring_operator_alertmanager_config | b64encode }}"
  66. --param NAMESPACE="{{ openshift_cluster_monitoring_operator_namespace }}"
  67. --config={{ mktemp.stdout }}/admin.kubeconfig
  68. | {{ openshift_client_binary }} apply --config={{ mktemp.stdout }}/admin.kubeconfig -f -
  69. with_items:
  70. - cluster-monitoring-operator.yaml
  71. - name: Process cluster-monitoring-operator configmap template
  72. template:
  73. src: cluster-monitoring-operator-config.j2
  74. dest: "{{ tempdir }}/templates/cluster-monitoring-operator-config.yaml"
  75. changed_when: no
  76. - name: Create cluster-monitoring-operator configmap
  77. oc_obj:
  78. state: present
  79. name: "cluster-monitoring-config"
  80. namespace: "{{ openshift_cluster_monitoring_operator_namespace }}"
  81. kind: configmap
  82. files:
  83. - "{{ tempdir }}/templates/cluster-monitoring-operator-config.yaml"
  84. delete_after: true
  85. - name: Process cluster-monitoring-operator deployment template
  86. template:
  87. src: cluster-monitoring-operator-deployment.j2
  88. dest: "{{ tempdir }}/templates/cluster-monitoring-operator-deployment.yaml"
  89. vars:
  90. namespace: "{{ openshift_cluster_monitoring_operator_namespace }}"
  91. - name: Create cluster-monitoring-operator deployment
  92. oc_obj:
  93. state: present
  94. name: "cluster-monitoring-operator"
  95. namespace: "{{ openshift_cluster_monitoring_operator_namespace }}"
  96. kind: deployment
  97. files:
  98. - "{{ tempdir }}/templates/cluster-monitoring-operator-deployment.yaml"
  99. delete_after: true
  100. - name: Wait for the ServiceMonitor CRD to be created
  101. command: "{{ openshift_client_binary }} get crd servicemonitors.monitoring.coreos.com -n openshift-monitoring --config={{ mktemp.stdout }}/admin.kubeconfig"
  102. register: crd
  103. until: crd.rc == 0
  104. delay: 30
  105. retries: 30
  106. - name: Delete temp directory
  107. file:
  108. name: "{{ mktemp.stdout }}"
  109. state: absent
  110. changed_when: False