feat(ansible): Add addon support (#836)
This commit is contained in:
1 parent
8af4377aa3
commit
34527bd3e2
41 files changed
+502
-118
No files matched your search
@@ -0,0 +1,63 @@
|
||||
---
|
||||
- name: Set addon facts
|
||||
ansible.builtin.set_fact:
|
||||
addon_name: grafana
|
||||
addon_namespace: monitoring
|
||||
|
||||
- name: Ensure directories exist for {{ addon_namespace }}/{{ addon_name }}
|
||||
when: item.state == 'directory'
|
||||
ansible.builtin.file:
|
||||
path: "{{ repository_path }}/kubernetes/apps/{{ addon_namespace }}/{{ addon_name }}/{{ item.path }}"
|
||||
state: directory
|
||||
mode: "0755"
|
||||
with_community.general.filetree: ["../templates/addons/{{ addon_name }}/"]
|
||||
|
||||
- name: Template unencrypted files for {{ addon_namespace }}/{{ addon_name }}
|
||||
when: item.state == 'file' and 'sops' not in item.path
|
||||
ansible.builtin.template:
|
||||
src: "{{ item.src }}"
|
||||
dest: "{{ repository_path }}/kubernetes/apps/{{ addon_namespace }}/{{ addon_name }}/{{ item.path | replace('.j2', '') }}"
|
||||
mode: "0755"
|
||||
with_community.general.filetree: ["../templates/addons/{{ addon_name }}/"]
|
||||
|
||||
# https://github.com/ansible-collections/community.sops/issues/153
|
||||
- name: Template encrypted files for {{ addon_namespace }}/{{ addon_name }}
|
||||
block:
|
||||
- name: Rename Sops configuration file
|
||||
ansible.builtin.copy:
|
||||
src: "{{ repository_path }}/.sops.yaml"
|
||||
dest: "{{ repository_path }}/.sops.yaml.orig"
|
||||
mode: "0755"
|
||||
- name: Remove Sops configuration file
|
||||
ansible.builtin.file:
|
||||
path: "{{ repository_path }}/.sops.yaml"
|
||||
state: absent
|
||||
- name: Template encrypted files
|
||||
when: item.state == 'file' and 'sops' in item.path
|
||||
community.sops.sops_encrypt:
|
||||
path: "{{ repository_path }}/kubernetes/apps/{{ addon_namespace }}/{{ addon_name }}/{{ item.path | replace('.j2', '') }}"
|
||||
encrypted_regex: ^(data|stringData)$
|
||||
age: ["{{ bootstrap_age_public_key }}"]
|
||||
content_yaml: "{{ lookup('ansible.builtin.template', item.src) | from_yaml }}"
|
||||
mode: "0755"
|
||||
force: true
|
||||
with_community.general.filetree: ["../templates/addons/{{ addon_name }}/"]
|
||||
- name: Restore Sops configuration file
|
||||
ansible.builtin.copy:
|
||||
src: "{{ repository_path }}/.sops.yaml.orig"
|
||||
dest: "{{ repository_path }}/.sops.yaml"
|
||||
mode: "0755"
|
||||
- name: Remove backed up Sops configuration file
|
||||
ansible.builtin.file:
|
||||
path: "{{ repository_path }}/.sops.yaml.orig"
|
||||
state: absent
|
||||
rescue:
|
||||
- name: Restore Sops configuration file
|
||||
ansible.builtin.copy:
|
||||
src: "{{ repository_path }}/.sops.yaml.orig"
|
||||
dest: "{{ repository_path }}/.sops.yaml"
|
||||
mode: "0755"
|
||||
- name: Remove backed up Sops configuration file
|
||||
ansible.builtin.file:
|
||||
path: "{{ repository_path }}/.sops.yaml.orig"
|
||||
state: absent
|
||||
@@ -0,0 +1,63 @@
|
||||
---
|
||||
- name: Set addon facts
|
||||
ansible.builtin.set_fact:
|
||||
addon_name: hajimari
|
||||
addon_namespace: default
|
||||
|
||||
- name: Ensure directories exist for {{ addon_namespace }}/{{ addon_name }}
|
||||
when: item.state == 'directory'
|
||||
ansible.builtin.file:
|
||||
path: "{{ repository_path }}/kubernetes/apps/{{ addon_namespace }}/{{ addon_name }}/{{ item.path }}"
|
||||
state: directory
|
||||
mode: "0755"
|
||||
with_community.general.filetree: ["../templates/addons/{{ addon_name }}/"]
|
||||
|
||||
- name: Template unencrypted files for {{ addon_namespace }}/{{ addon_name }}
|
||||
when: item.state == 'file' and 'sops' not in item.path
|
||||
ansible.builtin.template:
|
||||
src: "{{ item.src }}"
|
||||
dest: "{{ repository_path }}/kubernetes/apps/{{ addon_namespace }}/{{ addon_name }}/{{ item.path | replace('.j2', '') }}"
|
||||
mode: "0755"
|
||||
with_community.general.filetree: ["../templates/addons/{{ addon_name }}/"]
|
||||
|
||||
# https://github.com/ansible-collections/community.sops/issues/153
|
||||
- name: Template encrypted files for {{ addon_namespace }}/{{ addon_name }}
|
||||
block:
|
||||
- name: Rename Sops configuration file
|
||||
ansible.builtin.copy:
|
||||
src: "{{ repository_path }}/.sops.yaml"
|
||||
dest: "{{ repository_path }}/.sops.yaml.orig"
|
||||
mode: "0755"
|
||||
- name: Remove Sops configuration file
|
||||
ansible.builtin.file:
|
||||
path: "{{ repository_path }}/.sops.yaml"
|
||||
state: absent
|
||||
- name: Template encrypted files
|
||||
when: item.state == 'file' and 'sops' in item.path
|
||||
community.sops.sops_encrypt:
|
||||
path: "{{ repository_path }}/kubernetes/apps/{{ addon_namespace }}/{{ addon_name }}/{{ item.path | replace('.j2', '') }}"
|
||||
encrypted_regex: ^(data|stringData)$
|
||||
age: ["{{ bootstrap_age_public_key }}"]
|
||||
content_yaml: "{{ lookup('ansible.builtin.template', item.src) | from_yaml }}"
|
||||
mode: "0755"
|
||||
force: true
|
||||
with_community.general.filetree: ["../templates/addons/{{ addon_name }}/"]
|
||||
- name: Restore Sops configuration file
|
||||
ansible.builtin.copy:
|
||||
src: "{{ repository_path }}/.sops.yaml.orig"
|
||||
dest: "{{ repository_path }}/.sops.yaml"
|
||||
mode: "0755"
|
||||
- name: Remove backed up Sops configuration file
|
||||
ansible.builtin.file:
|
||||
path: "{{ repository_path }}/.sops.yaml.orig"
|
||||
state: absent
|
||||
rescue:
|
||||
- name: Restore Sops configuration file
|
||||
ansible.builtin.copy:
|
||||
src: "{{ repository_path }}/.sops.yaml.orig"
|
||||
dest: "{{ repository_path }}/.sops.yaml"
|
||||
mode: "0755"
|
||||
- name: Remove backed up Sops configuration file
|
||||
ansible.builtin.file:
|
||||
path: "{{ repository_path }}/.sops.yaml.orig"
|
||||
state: absent
|
||||
@@ -0,0 +1,63 @@
|
||||
---
|
||||
- name: Set addon facts
|
||||
ansible.builtin.set_fact:
|
||||
addon_name: kube-prometheus-stack
|
||||
addon_namespace: monitoring
|
||||
|
||||
- name: Ensure directories exist for {{ addon_namespace }}/{{ addon_name }}
|
||||
when: item.state == 'directory'
|
||||
ansible.builtin.file:
|
||||
path: "{{ repository_path }}/kubernetes/apps/{{ addon_namespace }}/{{ addon_name }}/{{ item.path }}"
|
||||
state: directory
|
||||
mode: "0755"
|
||||
with_community.general.filetree: ["../templates/addons/{{ addon_name }}/"]
|
||||
|
||||
- name: Template unencrypted files for {{ addon_namespace }}/{{ addon_name }}
|
||||
when: item.state == 'file' and 'sops' not in item.path
|
||||
ansible.builtin.template:
|
||||
src: "{{ item.src }}"
|
||||
dest: "{{ repository_path }}/kubernetes/apps/{{ addon_namespace }}/{{ addon_name }}/{{ item.path | replace('.j2', '') }}"
|
||||
mode: "0755"
|
||||
with_community.general.filetree: ["../templates/addons/{{ addon_name }}/"]
|
||||
|
||||
# https://github.com/ansible-collections/community.sops/issues/153
|
||||
- name: Template encrypted files for {{ addon_namespace }}/{{ addon_name }}
|
||||
block:
|
||||
- name: Rename Sops configuration file
|
||||
ansible.builtin.copy:
|
||||
src: "{{ repository_path }}/.sops.yaml"
|
||||
dest: "{{ repository_path }}/.sops.yaml.orig"
|
||||
mode: "0755"
|
||||
- name: Remove Sops configuration file
|
||||
ansible.builtin.file:
|
||||
path: "{{ repository_path }}/.sops.yaml"
|
||||
state: absent
|
||||
- name: Template encrypted files
|
||||
when: item.state == 'file' and 'sops' in item.path
|
||||
community.sops.sops_encrypt:
|
||||
path: "{{ repository_path }}/kubernetes/apps/{{ addon_namespace }}/{{ addon_name }}/{{ item.path | replace('.j2', '') }}"
|
||||
encrypted_regex: ^(data|stringData)$
|
||||
age: ["{{ bootstrap_age_public_key }}"]
|
||||
content_yaml: "{{ lookup('ansible.builtin.template', item.src) | from_yaml }}"
|
||||
mode: "0755"
|
||||
force: true
|
||||
with_community.general.filetree: ["../templates/addons/{{ addon_name }}/"]
|
||||
- name: Restore Sops configuration file
|
||||
ansible.builtin.copy:
|
||||
src: "{{ repository_path }}/.sops.yaml.orig"
|
||||
dest: "{{ repository_path }}/.sops.yaml"
|
||||
mode: "0755"
|
||||
- name: Remove backed up Sops configuration file
|
||||
ansible.builtin.file:
|
||||
path: "{{ repository_path }}/.sops.yaml.orig"
|
||||
state: absent
|
||||
rescue:
|
||||
- name: Restore Sops configuration file
|
||||
ansible.builtin.copy:
|
||||
src: "{{ repository_path }}/.sops.yaml.orig"
|
||||
dest: "{{ repository_path }}/.sops.yaml"
|
||||
mode: "0755"
|
||||
- name: Remove backed up Sops configuration file
|
||||
ansible.builtin.file:
|
||||
path: "{{ repository_path }}/.sops.yaml.orig"
|
||||
state: absent
|
||||
@@ -0,0 +1,63 @@
|
||||
---
|
||||
- name: Set addon facts
|
||||
ansible.builtin.set_fact:
|
||||
addon_name: kubernetes-dashboard
|
||||
addon_namespace: monitoring
|
||||
|
||||
- name: Ensure directories exist for {{ addon_namespace }}/{{ addon_name }}
|
||||
when: item.state == 'directory'
|
||||
ansible.builtin.file:
|
||||
path: "{{ repository_path }}/kubernetes/apps/{{ addon_namespace }}/{{ addon_name }}/{{ item.path }}"
|
||||
state: directory
|
||||
mode: "0755"
|
||||
with_community.general.filetree: ["../templates/addons/{{ addon_name }}/"]
|
||||
|
||||
- name: Template unencrypted files for {{ addon_namespace }}/{{ addon_name }}
|
||||
when: item.state == 'file' and 'sops' not in item.path
|
||||
ansible.builtin.template:
|
||||
src: "{{ item.src }}"
|
||||
dest: "{{ repository_path }}/kubernetes/apps/{{ addon_namespace }}/{{ addon_name }}/{{ item.path | replace('.j2', '') }}"
|
||||
mode: "0755"
|
||||
with_community.general.filetree: ["../templates/addons/{{ addon_name }}/"]
|
||||
|
||||
# https://github.com/ansible-collections/community.sops/issues/153
|
||||
- name: Template encrypted files for {{ addon_namespace }}/{{ addon_name }}
|
||||
block:
|
||||
- name: Rename Sops configuration file
|
||||
ansible.builtin.copy:
|
||||
src: "{{ repository_path }}/.sops.yaml"
|
||||
dest: "{{ repository_path }}/.sops.yaml.orig"
|
||||
mode: "0755"
|
||||
- name: Remove Sops configuration file
|
||||
ansible.builtin.file:
|
||||
path: "{{ repository_path }}/.sops.yaml"
|
||||
state: absent
|
||||
- name: Template encrypted files
|
||||
when: item.state == 'file' and 'sops' in item.path
|
||||
community.sops.sops_encrypt:
|
||||
path: "{{ repository_path }}/kubernetes/apps/{{ addon_namespace }}/{{ addon_name }}/{{ item.path | replace('.j2', '') }}"
|
||||
encrypted_regex: ^(data|stringData)$
|
||||
age: ["{{ bootstrap_age_public_key }}"]
|
||||
content_yaml: "{{ lookup('ansible.builtin.template', item.src) | from_yaml }}"
|
||||
mode: "0755"
|
||||
force: true
|
||||
with_community.general.filetree: ["../templates/addons/{{ addon_name }}/"]
|
||||
- name: Restore Sops configuration file
|
||||
ansible.builtin.copy:
|
||||
src: "{{ repository_path }}/.sops.yaml.orig"
|
||||
dest: "{{ repository_path }}/.sops.yaml"
|
||||
mode: "0755"
|
||||
- name: Remove backed up Sops configuration file
|
||||
ansible.builtin.file:
|
||||
path: "{{ repository_path }}/.sops.yaml.orig"
|
||||
state: absent
|
||||
rescue:
|
||||
- name: Restore Sops configuration file
|
||||
ansible.builtin.copy:
|
||||
src: "{{ repository_path }}/.sops.yaml.orig"
|
||||
dest: "{{ repository_path }}/.sops.yaml"
|
||||
mode: "0755"
|
||||
- name: Remove backed up Sops configuration file
|
||||
ansible.builtin.file:
|
||||
path: "{{ repository_path }}/.sops.yaml.orig"
|
||||
state: absent
|
||||
@@ -0,0 +1,21 @@
|
||||
---
|
||||
|
||||
- name: Process addon hajimari
|
||||
when: hajimari.enabled | default (false)
|
||||
ansible.builtin.include_tasks: hajimari.yaml
|
||||
|
||||
- name: Process addon grafana
|
||||
when: grafana.enabled | default (false)
|
||||
ansible.builtin.include_tasks: grafana.yaml
|
||||
|
||||
- name: Process addon kubernetes-dashboard
|
||||
when: kubernetes_dashboard.enabled | default (false)
|
||||
ansible.builtin.include_tasks: kubernetes_dashboard.yaml
|
||||
|
||||
- name: Process addon kube-prometheus-stack
|
||||
when: kube_prometheus_stack.enabled | default (false)
|
||||
ansible.builtin.include_tasks: kube_prometheus_stack.yaml
|
||||
|
||||
- name: Process addon weave-gitops
|
||||
when: weave_gitops.enabled | default (false)
|
||||
ansible.builtin.include_tasks: weave_gitops.yaml
|
||||
@@ -0,0 +1,63 @@
|
||||
---
|
||||
- name: Set addon facts
|
||||
ansible.builtin.set_fact:
|
||||
addon_name: weave-gitops
|
||||
addon_namespace: flux-system
|
||||
|
||||
- name: Ensure directories exist for {{ addon_namespace }}/{{ addon_name }}
|
||||
when: item.state == 'directory'
|
||||
ansible.builtin.file:
|
||||
path: "{{ repository_path }}/kubernetes/apps/{{ addon_namespace }}/{{ addon_name }}/{{ item.path }}"
|
||||
state: directory
|
||||
mode: "0755"
|
||||
with_community.general.filetree: ["../templates/addons/{{ addon_name }}/"]
|
||||
|
||||
- name: Template unencrypted files for {{ addon_namespace }}/{{ addon_name }}
|
||||
when: item.state == 'file' and 'sops' not in item.path
|
||||
ansible.builtin.template:
|
||||
src: "{{ item.src }}"
|
||||
dest: "{{ repository_path }}/kubernetes/apps/{{ addon_namespace }}/{{ addon_name }}/{{ item.path | replace('.j2', '') }}"
|
||||
mode: "0755"
|
||||
with_community.general.filetree: ["../templates/addons/{{ addon_name }}/"]
|
||||
|
||||
# https://github.com/ansible-collections/community.sops/issues/153
|
||||
- name: Template encrypted files for {{ addon_namespace }}/{{ addon_name }}
|
||||
block:
|
||||
- name: Rename Sops configuration file
|
||||
ansible.builtin.copy:
|
||||
src: "{{ repository_path }}/.sops.yaml"
|
||||
dest: "{{ repository_path }}/.sops.yaml.orig"
|
||||
mode: "0755"
|
||||
- name: Remove Sops configuration file
|
||||
ansible.builtin.file:
|
||||
path: "{{ repository_path }}/.sops.yaml"
|
||||
state: absent
|
||||
- name: Template encrypted files
|
||||
when: item.state == 'file' and 'sops' in item.path
|
||||
community.sops.sops_encrypt:
|
||||
path: "{{ repository_path }}/kubernetes/apps/{{ addon_namespace }}/{{ addon_name }}/{{ item.path | replace('.j2', '') }}"
|
||||
encrypted_regex: ^(data|stringData)$
|
||||
age: ["{{ bootstrap_age_public_key }}"]
|
||||
content_yaml: "{{ lookup('ansible.builtin.template', item.src) | from_yaml }}"
|
||||
mode: "0755"
|
||||
force: true
|
||||
with_community.general.filetree: ["../templates/addons/{{ addon_name }}/"]
|
||||
- name: Restore Sops configuration file
|
||||
ansible.builtin.copy:
|
||||
src: "{{ repository_path }}/.sops.yaml.orig"
|
||||
dest: "{{ repository_path }}/.sops.yaml"
|
||||
mode: "0755"
|
||||
- name: Remove backed up Sops configuration file
|
||||
ansible.builtin.file:
|
||||
path: "{{ repository_path }}/.sops.yaml.orig"
|
||||
state: absent
|
||||
rescue:
|
||||
- name: Restore Sops configuration file
|
||||
ansible.builtin.copy:
|
||||
src: "{{ repository_path }}/.sops.yaml.orig"
|
||||
dest: "{{ repository_path }}/.sops.yaml"
|
||||
mode: "0755"
|
||||
- name: Remove backed up Sops configuration file
|
||||
ansible.builtin.file:
|
||||
path: "{{ repository_path }}/.sops.yaml.orig"
|
||||
state: absent
|
||||
Reference in new issue
Block a user