summaryrefslogtreecommitdiffstats
path: root/roles/openshift_metrics/tasks
diff options
context:
space:
mode:
authorJeff Cantrill <jcantril@redhat.com>2017-01-13 12:19:55 -0500
committerJeff Cantrill <jcantril@redhat.com>2017-01-17 11:45:04 -0500
commite96de3d7eb0b0ce6a8df96d4e3afa02f0859b94b (patch)
treec3155cf0b7642f743cda51331b492dc23c9fe424 /roles/openshift_metrics/tasks
parent868e800a1325a726c24afc752033434a80d13b2d (diff)
downloadopenshift-e96de3d7eb0b0ce6a8df96d4e3afa02f0859b94b.tar.gz
openshift-e96de3d7eb0b0ce6a8df96d4e3afa02f0859b94b.tar.bz2
openshift-e96de3d7eb0b0ce6a8df96d4e3afa02f0859b94b.tar.xz
openshift-e96de3d7eb0b0ce6a8df96d4e3afa02f0859b94b.zip
properly set changes when oc apply
Diffstat (limited to 'roles/openshift_metrics/tasks')
-rw-r--r--roles/openshift_metrics/tasks/install_metrics.yaml16
-rw-r--r--roles/openshift_metrics/tasks/oc_apply.yaml31
-rw-r--r--roles/openshift_metrics/tasks/start_metrics.yaml2
3 files changed, 41 insertions, 8 deletions
diff --git a/roles/openshift_metrics/tasks/install_metrics.yaml b/roles/openshift_metrics/tasks/install_metrics.yaml
index e550f6e8d..67d22cbc3 100644
--- a/roles/openshift_metrics/tasks/install_metrics.yaml
+++ b/roles/openshift_metrics/tasks/install_metrics.yaml
@@ -1,9 +1,9 @@
---
-- name: check that hawkular_metrics_hostname is set
+- name: Check that hawkular_metrics_hostname is set
fail: msg='the openshift_metrics_hawkular_hostname variable is required'
when: openshift_metrics_hawkular_hostname is not defined
-- name: check the value of openshift_metrics_cassandra_storage_type
+- name: Check the value of openshift_metrics_cassandra_storage_type
fail:
msg: >
openshift_metrics_cassandra_storage_type ({{ openshift_metrics_cassandra_storage_type }})
@@ -20,11 +20,13 @@
loop_control:
loop_var: include_file
-- name: create objects
- command: >
- {{ openshift.common.client_binary }} -n {{ openshift_metrics_project }}
- --config={{ mktemp.stdout }}/admin.kubeconfig
- apply -f {{ item }}
+- name: Create objects
+ include: oc_apply.yaml
+ vars:
+ kubeconfig: "{{ mktemp.stdout }}/admin.kubeconfig"
+ namespace: "{{ openshift_metrics_project }}"
+ file_name: "{{ item }}"
+ file_content: "{{ lookup('file',item) | from_yaml }}"
with_fileglob:
- "{{ mktemp.stdout }}/templates/*.yaml"
diff --git a/roles/openshift_metrics/tasks/oc_apply.yaml b/roles/openshift_metrics/tasks/oc_apply.yaml
new file mode 100644
index 000000000..c9154f206
--- /dev/null
+++ b/roles/openshift_metrics/tasks/oc_apply.yaml
@@ -0,0 +1,31 @@
+---
+- name: Checking generation of {{file_content.kind}} {{file_content.metadata.name}}
+ command: >
+ {{ openshift.common.client_binary }}
+ --config={{ kubeconfig }}
+ get {{file_content.kind}} {{file_content.metadata.name}}
+ -o jsonpath='{.metadata.resourceVersion}'
+ -n {{namespace}}
+ register: generation_init
+ changed_when: no
+
+- name: Applying {{file_name}}
+ command: >
+ {{ openshift.common.client_binary }} --config={{ kubeconfig }}
+ apply -f {{ file_name }}
+ -n {{ openshift_metrics_project }}
+ register: generation_apply
+ failed_when: "'error' in generation_apply.stderr"
+ changed_when: no
+
+- name: Determine change status of {{file_content.kind}} {{file_content.metadata.name}}
+ command: >
+ {{ openshift.common.client_binary }} --config={{ kubeconfig }}
+ get {{file_content.kind}} {{file_content.metadata.name}}
+ -o jsonpath='{.metadata.resourceVersion}'
+ -n {{namespace}}
+ register: version_changed
+ vars:
+ init_version: "{{ (generation_init is defined) | ternary(generation_init.stdout, '0') }}"
+ failed_when: "'error' in version_changed.stderr"
+ changed_when: version_changed.stdout | int > init_version | int
diff --git a/roles/openshift_metrics/tasks/start_metrics.yaml b/roles/openshift_metrics/tasks/start_metrics.yaml
index 31f303c86..c4cae4aff 100644
--- a/roles/openshift_metrics/tasks/start_metrics.yaml
+++ b/roles/openshift_metrics/tasks/start_metrics.yaml
@@ -43,7 +43,7 @@
-o name
-n {{openshift_metrics_project}}
register: metrics_heapster_rc
- check_mode: no
+ changed_when: no
- name: Start Heapster
include: scale.yaml