--- - name: Create temp directory for doing work in on target command: mktemp -td openshift-cluster-monitoring-ansible-XXXXXX register: mktemp changed_when: False - name: Copy files to temp directory copy: src: "{{ item }}" dest: "{{ mktemp.stdout }}/{{ item }}" with_items: - cluster-monitoring-operator.yaml - name: Copy admin client config command: > cp {{ openshift.common.config_base }}/master/admin.kubeconfig {{ mktemp.stdout }}/admin.kubeconfig changed_when: false - name: Add monitoring project oc_project: state: present name: openshift-monitoring description: Openshift Monitoring node_selector: "" - name: Label monitoring namespace oc_label: state: present kind: namespace name: openshift-monitoring labels: - key: openshift.io/cluster-monitoring value: "true" - name: Apply the cluster monitoring operator template shell: > {{ openshift_client_binary }} process -n openshift-monitoring -f "{{ mktemp.stdout }}/{{ item }}" --param OPERATOR_IMAGE="{{ openshift_cluster_monitoring_operator_image }}" --param PROMETHEUS_OPERATOR_IMAGE="{{ openshift_cluster_monitoring_operator_prometheus_operator_repo }}" --param ALERTMANAGER_IMAGE="{{ openshift_cluster_monitoring_operator_alertmanager_repo }}" --param PROMETHEUS_IMAGE="{{ openshift_cluster_monitoring_operator_prometheus_repo }}" --param PROMETHEUS_CONFIG_RELOADER_IMAGE="{{ openshift_cluster_monitoring_operator_prometheus_reloader_repo }}" --param CONFIG_RELOADER_IMAGE="{{ openshift_cluster_monitoring_operator_configmap_reloader_repo }}" --param ALERTMANAGER_CONFIG="{{ openshift_cluster_monitoring_operator_alertmanager_config | b64encode }}" --param CLUSTER_ID="{{ openshift_cluster_monitoring_operator_cluster_id }}" --param PROMETHEUS_STORAGE_CAPACITY="{{ openshift_cluster_monitoring_operator_prometheus_storage_capacity }}" --param ALERTMANAGER_STORAGE_CAPACITY="{{ openshift_cluster_monitoring_operator_alertmanager_storage_capacity }}" --config={{ mktemp.stdout }}/admin.kubeconfig | {{ openshift_client_binary }} apply --config={{ mktemp.stdout }}/admin.kubeconfig -f - with_items: - cluster-monitoring-operator.yaml - name: Wait for the ServiceMonitor CRD to be created command: "{{ openshift_client_binary }} get crd servicemonitors.monitoring.coreos.com -n openshift-monitoring --config={{ mktemp.stdout }}/admin.kubeconfig" register: crd until: crd.rc == 0 delay: 30 retries: 30 - name: Delete temp directory file: name: "{{ mktemp.stdout }}" state: absent changed_when: False