From 990d2a1358c46a06ce31aa69690ba21bb6163f56 Mon Sep 17 00:00:00 2001
From: Max Gautier <mg@max.gautier.name>
Date: Sat, 9 Nov 2024 15:21:20 +0100
Subject: [PATCH] Define a standard commandline for applying manifests

This is expected to be used in the command module this way:
command:
  cmd: "{{ kubectl_apply_stdin }}"
  stdin: <... rendered manifests > -> using the 'template' lookup plugin
  in most cases.

The advantages over the kube plugin module integrated in kubespray
(which this should replace eventually):
- way easier to modify to take advantage of new features (server-side
  apply for instance)
- no need for a separate template tasks + checking the result (which can
  introduce problem if the first playbook runs encounters an error).
---
 roles/kubernetes-apps/defaults/main.yml | 2 ++
 roles/kubernetes-apps/vars/main.yml     | 2 ++
 2 files changed, 4 insertions(+)
 create mode 100644 roles/kubernetes-apps/defaults/main.yml
 create mode 100644 roles/kubernetes-apps/vars/main.yml

diff --git a/roles/kubernetes-apps/defaults/main.yml b/roles/kubernetes-apps/defaults/main.yml
new file mode 100644
index 000000000..b794a98f4
--- /dev/null
+++ b/roles/kubernetes-apps/defaults/main.yml
@@ -0,0 +1,2 @@
+---
+namespace: kube-system
diff --git a/roles/kubernetes-apps/vars/main.yml b/roles/kubernetes-apps/vars/main.yml
new file mode 100644
index 000000000..88f4a3068
--- /dev/null
+++ b/roles/kubernetes-apps/vars/main.yml
@@ -0,0 +1,2 @@
+---
+kubectl_apply_stdin: "{{ kubectl }} apply -f - -n {{ namespace }}"
-- 
GitLab