summaryrefslogtreecommitdiff
path: root/roles/kubernetes/decorations
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2022-08-19 23:12:06 +0200
committerChristian Pointner <equinox@spreadspace.org>2022-08-19 23:12:06 +0200
commit2e17e55783c109e917d8b0f14c5de05632f44761 (patch)
treef913f8b762e6e5bace08f3ab89459bc677666daa /roles/kubernetes/decorations
parentkubernetes: add support for ansible managed node annotations,labels and taints (diff)
kubernetes/decorations: replace '/' with '%' in stamp file names
Diffstat (limited to 'roles/kubernetes/decorations')
-rw-r--r--roles/kubernetes/decorations/tasks/annotations.yml10
-rw-r--r--roles/kubernetes/decorations/tasks/labels.yml10
-rw-r--r--roles/kubernetes/decorations/tasks/taints.yml8
3 files changed, 14 insertions, 14 deletions
diff --git a/roles/kubernetes/decorations/tasks/annotations.yml b/roles/kubernetes/decorations/tasks/annotations.yml
index 9b47ecbf..0c0438f6 100644
--- a/roles/kubernetes/decorations/tasks/annotations.yml
+++ b/roles/kubernetes/decorations/tasks/annotations.yml
@@ -7,7 +7,7 @@
register: kubectl_list_annotations
- set_fact:
- current_annotations: "{{ kubectl_list_annotations.stdout | from_json }}"
+ current_annotations: "{{ kubectl_list_annotations.stdout | ternary(kubectl_list_annotations.stdout, '[]') | from_json }}"
- name: add annotations to node
delegate_to: "{{ groups['_kubernetes_primary_controlplane_node_'] | first }}"
@@ -22,7 +22,7 @@
loop_control:
label: "{{ item.key }}={{ item.value }}"
copy:
- dest: "/etc/kubernetes/decorations/annotations/{{ item.key }}"
+ dest: "/etc/kubernetes/decorations/annotations/{{ item.key | replace('/', '%') }}"
content: "{{ item.value }}"
- name: get list of managed labels
@@ -32,13 +32,13 @@
- name: remove superflous annotations from node
delegate_to: "{{ groups['_kubernetes_primary_controlplane_node_'] | first }}"
- loop: "{{ managed_annotations.files | map(attribute='path') | map('basename') }}"
+ loop: "{{ managed_annotations.files | map(attribute='path') | map('basename') | replace('%', '/') }}"
when: "item not in kubernetes_node_annotations"
command: kubectl --kubeconfig /etc/kubernetes/admin.conf annotate --overwrite node '{{ kubernetes_node_name }}' '{{ item }}-'
- name: remove stamp files for superflous annotations
- loop: "{{ managed_annotations.files | map(attribute='path') | map('basename') }}"
+ loop: "{{ managed_annotations.files | map(attribute='path') | map('basename') | replace('%', '/') }}"
when: "item not in kubernetes_node_annotations"
file:
- path: "/etc/kubernetes/decorations/annotations/{{ item }}"
+ path: "/etc/kubernetes/decorations/annotations/{{ item | replace('/', '%') }}"
state: absent
diff --git a/roles/kubernetes/decorations/tasks/labels.yml b/roles/kubernetes/decorations/tasks/labels.yml
index 1517616e..fdc5e5c1 100644
--- a/roles/kubernetes/decorations/tasks/labels.yml
+++ b/roles/kubernetes/decorations/tasks/labels.yml
@@ -7,7 +7,7 @@
register: kubectl_list_labels
- set_fact:
- current_labels: "{{ kubectl_list_labels.stdout | from_json }}"
+ current_labels: "{{ kubectl_list_labels.stdout | ternary(kubectl_list_labels.stdout, '[]') | from_json }}"
- name: add labels to node
delegate_to: "{{ groups['_kubernetes_primary_controlplane_node_'] | first }}"
@@ -22,7 +22,7 @@
loop_control:
label: "{{ item.key }}={{ item.value }}"
copy:
- dest: "/etc/kubernetes/decorations/labels/{{ item.key }}"
+ dest: "/etc/kubernetes/decorations/labels/{{ item.key | replace('/', '%') }}"
content: "{{ item.value }}"
- name: get list of managed labels
@@ -32,13 +32,13 @@
- name: remove superflous labels from node
delegate_to: "{{ groups['_kubernetes_primary_controlplane_node_'] | first }}"
- loop: "{{ managed_labels.files | map(attribute='path') | map('basename') }}"
+ loop: "{{ managed_labels.files | map(attribute='path') | map('basename') | replace('%', '/') }}"
when: "item not in kubernetes_node_labels"
command: kubectl --kubeconfig /etc/kubernetes/admin.conf label --overwrite node '{{ kubernetes_node_name }}' '{{ item }}-'
- name: remove stamp files for superflous labels
- loop: "{{ managed_labels.files | map(attribute='path') | map('basename') }}"
+ loop: "{{ managed_labels.files | map(attribute='path') | map('basename') | replace('%', '/') }}"
when: "item not in kubernetes_node_labels"
file:
- path: "/etc/kubernetes/decorations/labels/{{ item }}"
+ path: "/etc/kubernetes/decorations/labels/{{ item | replace('/', '%') }}"
state: absent
diff --git a/roles/kubernetes/decorations/tasks/taints.yml b/roles/kubernetes/decorations/tasks/taints.yml
index fd60ef88..fd027942 100644
--- a/roles/kubernetes/decorations/tasks/taints.yml
+++ b/roles/kubernetes/decorations/tasks/taints.yml
@@ -22,7 +22,7 @@
loop_control:
label: "{{ item.key }}={{ item.value }}"
copy:
- dest: "/etc/kubernetes/decorations/taints/{{ item.key }}"
+ dest: "/etc/kubernetes/decorations/taints/{{ item.key | replace('/', '%') }}"
content: "{{ item.value }}"
- name: get list of managed taints
@@ -32,13 +32,13 @@
- name: remove superflous taints from node
delegate_to: "{{ groups['_kubernetes_primary_controlplane_node_'] | first }}"
- loop: "{{ managed_taints.files | map(attribute='path') | map('basename') }}"
+ loop: "{{ managed_taints.files | map(attribute='path') | map('basename') | replace('%', '/') }}"
when: "item not in kubernetes_node_taints"
command: kubectl --kubeconfig /etc/kubernetes/admin.conf taint --overwrite node '{{ kubernetes_node_name }}' '{{ item }}-'
- name: remove stamp files for superflous taints
- loop: "{{ managed_taints.files | map(attribute='path') | map('basename') }}"
+ loop: "{{ managed_taints.files | map(attribute='path') | map('basename') | replace('%', '/') }}"
when: "item not in kubernetes_node_taints"
file:
- path: "/etc/kubernetes/decorations/taints/{{ item }}"
+ path: "/etc/kubernetes/decorations/taints/{{ item | replace('/', '%') }}"
state: absent