summaryrefslogtreecommitdiffstats
path: root/roles/openshift_logging/tasks/patch_configmap_file.yaml
diff options
context:
space:
mode:
authorEric Wolinetz <ewolinet@redhat.com>2017-10-25 20:45:34 -0500
committerEric Wolinetz <ewolinet@redhat.com>2018-01-02 11:16:04 -0600
commit8cb27ae800df71ee816852df56cd2c861a0f0a0a (patch)
tree9a3f000d6bb886296912df6de0ececdfe7783a53 /roles/openshift_logging/tasks/patch_configmap_file.yaml
parent332764e4541d8c922f2589a533bb56b2a2419ac1 (diff)
downloadopenshift-8cb27ae800df71ee816852df56cd2c861a0f0a0a.tar.gz
openshift-8cb27ae800df71ee816852df56cd2c861a0f0a0a.tar.bz2
openshift-8cb27ae800df71ee816852df56cd2c861a0f0a0a.tar.xz
openshift-8cb27ae800df71ee816852df56cd2c861a0f0a0a.zip
Updating logging_facts to be able to pull values from config maps yaml files, use diffs to keep custom changes, white list certain settings when creating diffs
Diffstat (limited to 'roles/openshift_logging/tasks/patch_configmap_file.yaml')
-rw-r--r--roles/openshift_logging/tasks/patch_configmap_file.yaml35
1 files changed, 35 insertions, 0 deletions
diff --git a/roles/openshift_logging/tasks/patch_configmap_file.yaml b/roles/openshift_logging/tasks/patch_configmap_file.yaml
new file mode 100644
index 000000000..30087fe6a
--- /dev/null
+++ b/roles/openshift_logging/tasks/patch_configmap_file.yaml
@@ -0,0 +1,35 @@
+---
+## The purpose of this task file is to get a patch that is based on the diff
+## between configmap_current_file and configmap_new_file. The module
+## logging_patch takes the paths of two files to compare and also a list of
+## variables whose line we exclude from the diffs.
+## We then patch the new configmap file so that we can build a configmap
+## using that file later. We then use oc apply to idempotenly modify any
+## existing configmap.
+
+## The following variables are expected to be provided when including this task:
+# __configmap_output -- This is provided to us from patch_configmap_files.yaml
+# it is a dict of the configmap where configmap_current_file exists
+# configmap_current_file -- The name of the data file in the __configmap_output
+# configmap_new_file -- The path to the file that we intend to oc apply later
+# we apply our generated patch to this file.
+# configmap_protected_lines -- The list of variables to exclude from the diff
+
+- copy:
+ content: "{{ __configmap_output.results.results[0]['data'][configmap_current_file] }}"
+ dest: "{{ tempdir }}/current.yml"
+
+- logging_patch:
+ original_file: "{{ tempdir }}/current.yml"
+ new_file: "{{ configmap_new_file }}"
+ whitelist: "{{ configmap_protected_lines | default([]) }}"
+ register: patch_output
+
+- copy:
+ content: "{{ patch_output.raw_patch }}\n"
+ dest: "{{ tempdir }}/patch.patch"
+ when: patch_output.raw_patch | length > 0
+
+- command: >
+ patch --force --quiet -u "{{ configmap_new_file }}" "{{ tempdir }}/patch.patch"
+ when: patch_output.raw_patch | length > 0