Refactor playbook_microk8s.yml and ansible-apply.yaml
Simplify playbook_microk8s.yml by removing duplicate lines and whitespace changes. Update ansible-apply.yaml to include a scheduled job for Terraform Apply.
This commit is contained in:
@@ -124,7 +124,7 @@
|
||||
- k8s::iac
|
||||
|
||||
- name: Get new config SHA1
|
||||
set_fact:
|
||||
ansible.builtin.set_fact:
|
||||
patched_kubeconfig_sha1: "{{ patched_kubeconfig_yaml | to_nice_yaml | sha1 }}"
|
||||
tags:
|
||||
- k8s::iac
|
||||
@@ -136,6 +136,6 @@
|
||||
dest: "{{ k8s_kubeconfig }}"
|
||||
owner: "{{ k8s_iac_user }}"
|
||||
mode: "0600"
|
||||
when: kubeconfig_exists.stat.exists == false or patched_kubeconfig_sha1 != kubeconfig_exists.stat.checksum
|
||||
when: not kubeconfig_exists.stat.exists or patched_kubeconfig_sha1 != kubeconfig_exists.stat.checksum
|
||||
tags:
|
||||
- k8s::iac
|
||||
- k8s::iac
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
- name: Check if secret exists
|
||||
ansible.builtin.shell: |
|
||||
set -o pipefail
|
||||
microk8s.kubectl -n {{ item.namespace | default('default') }} get secret | grep {{ item.username }}-token | wc -l | awk '{ print $1 }'
|
||||
microk8s.kubectl -n {{ item.namespace | default('default') }} get secret | grep {{ item.username }}-token | wc -l | awk '{ print $1 }'
|
||||
args:
|
||||
executable: /bin/bash
|
||||
register: secret_exists
|
||||
@@ -41,7 +41,7 @@
|
||||
- name: Get the secret name
|
||||
ansible.builtin.shell: |
|
||||
set -o pipefail
|
||||
microk8s.kubectl -n {{ item.namespace | default('default') }} get secret | grep {{ item.username }}-token | awk '{ print $1 }'
|
||||
microk8s.kubectl -n {{ item.namespace | default('default') }} get secret | grep {{ item.username }}-token | awk '{ print $1 }'
|
||||
args:
|
||||
executable: /bin/bash
|
||||
register: secret_name
|
||||
@@ -53,7 +53,7 @@
|
||||
- name: Describe the secret and extract the token
|
||||
ansible.builtin.shell: |
|
||||
set -o pipefail
|
||||
microk8s.kubectl -n {{ item.namespace | default('default') }} describe secret {{ secret_name.stdout }} | grep token: | awk '{ print $2 }'
|
||||
microk8s.kubectl -n {{ item.namespace | default('default') }} describe secret {{ secret_name.stdout }} | grep token: | awk '{ print $2 }'
|
||||
args:
|
||||
executable: /bin/bash
|
||||
register: token
|
||||
@@ -103,7 +103,7 @@
|
||||
- k8s::users
|
||||
|
||||
- name: Get new config SHA1
|
||||
set_fact:
|
||||
ansible.builtin.set_fact:
|
||||
patched_kubeconfig_sha1: "{{ patched_kubeconfig_yaml | to_nice_yaml | sha1 }}"
|
||||
tags:
|
||||
- k8s::users
|
||||
@@ -115,6 +115,6 @@
|
||||
dest: "{{ user_registered.home }}/.kube/config"
|
||||
owner: "{{ item.username }}"
|
||||
mode: "0600"
|
||||
when: kubeconfig_exists.stat.exists == false or patched_kubeconfig_sha1 != kubeconfig_exists.stat.checksum
|
||||
when: not kubeconfig_exists.stat.exists or patched_kubeconfig_sha1 != kubeconfig_exists.stat.checksum
|
||||
tags:
|
||||
- k8s::users
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
---
|
||||
apiVersion: apiserver.config.k8s.io/v1
|
||||
kind: EncryptionConfiguration
|
||||
resources:
|
||||
- resources:
|
||||
- secrets
|
||||
providers:
|
||||
- aescbc:
|
||||
keys:
|
||||
- name: k8s-crypto
|
||||
secret: {{ secret }}
|
||||
- identity: {}
|
||||
Reference in New Issue
Block a user