Created
February 12, 2021 10:44
-
-
Save luckylittle/ccbcb502488b6c97fd9505671da3f58e to your computer and use it in GitHub Desktop.
Configuring garbage collection in OCP3, an example of appending to YAML in Ansible
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --- | |
| # Configuring garbage collection in OCP3, an example of appending to YAML in Ansible | |
| # Lucian Maly - Red Hat, Inc. | |
| - name: Configuring garbage collection in OCP3 | |
| hosts: masters[0] | |
| gather_facts: no | |
| tasks: | |
| - name: 1.0 | ocp3-garbage-collection.yml | Download the content of a ConfigMap | |
| shell: | | |
| oc extract cm/node-config-compute --to=/root --confirm=true -n openshift-node | |
| - name: 1.1 | ocp3-garbage-collection.yml | Read the node-config.yaml | |
| slurp: | |
| path: /root/node-config.yaml | |
| register: r_myfile | |
| - name: 1.2 | ocp3-garbage-collection.yml | Extract the data of node-config.yaml | |
| set_fact: | |
| mydata: "{{ r_myfile['content'] | b64decode | from_yaml }}" | |
| - name: 1.3 | ocp3-garbage-collection.yml | Append new garbage collection options to Kubelet | |
| set_fact: | |
| mydata: "{{ mydata | combine(kubelet, recursive=True) }}" | |
| vars: | |
| kubelet: | |
| kubeletArguments: | |
| minimum-container-ttl-duration: | |
| - "0" | |
| maximum-dead-containers-per-container: | |
| - "1" | |
| maximum-dead-containers: | |
| - "240" | |
| - name: 1.4 | ocp3-garbage-collection.yml | Cleanup of the original remote file node-config.yaml | |
| file: | |
| path: /root/node-config.yaml | |
| state: absent | |
| - name: 1.5 | ocp3-garbage-collection.yml | Write back to a file | |
| copy: | |
| content: '{{ mydata | to_nice_yaml }}' | |
| dest: /root/node-config.yaml | |
| - name: 1.6 | ocp3-garbage-collection.yml | Apply/update the existing ConfigMap in openshift-node | |
| shell: | | |
| oc create configmap node-config-compute --from-file=/root/node-config.yaml -n openshift-node --dry-run -o yaml | oc apply -f - | |
| - name: 1.7 | ocp3-garbage-collection.yml | Cleanup of the new remote file node-config.yaml | |
| file: | |
| path: /root/node-config.yaml | |
| state: absent |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment