feat(ansible): Add addon support (#836)

This commit is contained in:
Devin Buhl authored and GitHub committed 2023-07-06 14:21:32 -04:00
1 parent 8af4377aa3
commit 34527bd3e2
41 files changed
+473 -89

No files matched your search

+2
View File
@@ -43,3 +43,5 @@ tasks:
desc: Configure repository from Ansible vars desc: Configure repository from Ansible vars
dir: "{{.TEMPLATE_DIR}}" dir: "{{.TEMPLATE_DIR}}"
cmd: ansible-playbook configure.yaml cmd: ansible-playbook configure.yaml
env:
ANSIBLE_DISPLAY_SKIPPED_HOSTS: "false"
+15
View File
@@ -5,7 +5,19 @@
vars_files: vars_files:
- defaults/main.yaml - defaults/main.yaml
- vars/config.yaml - vars/config.yaml
- vars/addons.yaml
tasks: tasks:
- name: Get absolute path to this Git repository # noqa: command-instead-of-module
ansible.builtin.command: git rev-parse --show-toplevel
changed_when: false
check_mode: false
register: repository
failed_when: repository.rc != 0
- name: Set facts
ansible.builtin.set_fact:
repository_path: "{{ repository.stdout }}"
- name: Verify configuration - name: Verify configuration
ansible.builtin.include_tasks: tasks/validation/main.yaml ansible.builtin.include_tasks: tasks/validation/main.yaml
@@ -17,3 +29,6 @@
- name: Template Kubernetes configuration - name: Template Kubernetes configuration
ansible.builtin.include_tasks: tasks/kubernetes/main.yaml ansible.builtin.include_tasks: tasks/kubernetes/main.yaml
- name: Template Kubernetes addon configuration
ansible.builtin.include_tasks: tasks/addons/main.yaml
+63
View File
@@ -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
+63
View File
@@ -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
+21
View File
@@ -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
+63
View File
@@ -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
+26 -24
View File
@@ -1,15 +1,8 @@
--- ---
- name: Get absolute path to this Git repository # noqa: command-instead-of-module
ansible.builtin.command: git rev-parse --show-toplevel
changed_when: false
check_mode: false
register: repository_path
failed_when: repository_path.rc != 0
- name: Template Ansible configuration - name: Template Ansible configuration
ansible.builtin.template: ansible.builtin.template:
src: "{{ item.src }}" src: "{{ item.src }}"
dest: "{{ repository_path.stdout }}/{{ item.dest }}" dest: "{{ repository_path }}/{{ item.dest }}"
mode: "0755" mode: "0755"
loop: loop:
- src: templates/ansible/supplemental.yaml.j2 - src: templates/ansible/supplemental.yaml.j2
@@ -18,34 +11,43 @@
dest: ./ansible/inventory/hosts.yaml dest: ./ansible/inventory/hosts.yaml
# https://github.com/ansible-collections/community.sops/issues/153 # https://github.com/ansible-collections/community.sops/issues/153
- name: Backup sops configuration file - name: Template Ansible encrypted files
block:
- name: Rename Sops configuration file
ansible.builtin.copy: ansible.builtin.copy:
src: "{{ repository_path.stdout }}/.sops.yaml" src: "{{ repository_path }}/.sops.yaml"
dest: "{{ repository_path.stdout }}/.sops.yaml.orig" dest: "{{ repository_path }}/.sops.yaml.orig"
mode: "0755" mode: "0755"
- name: Remove sops configuration file - name: Remove Sops configuration file
ansible.builtin.file: ansible.builtin.file:
path: "{{ repository_path.stdout }}/.sops.yaml" path: "{{ repository_path }}/.sops.yaml"
state: absent state: absent
- name: Template encrypted node secrets
- name: Template out node secrets
community.sops.sops_encrypt: community.sops.sops_encrypt:
path: "{{ repository_path.stdout }}/ansible/inventory/host_vars/{{ item.name }}.sops.yaml" path: "{{ repository_path }}/ansible/inventory/host_vars/{{ item.name }}.sops.yaml"
age: ["{{ bootstrap_age_public_key }}"] age: ["{{ bootstrap_age_public_key }}"]
content_yaml: "{{ lookup('ansible.builtin.template', 'templates/ansible/node.sops.yaml.j2', template_vars=dict(password=item.password)) | from_yaml }}" content_yaml: "{{ lookup('ansible.builtin.template', 'templates/ansible/node.sops.yaml.j2', template_vars=dict(password=item.password)) | from_yaml }}"
mode: "0755" mode: "0755"
force: true force: true
loop: "{{ bootstrap_hosts.master + bootstrap_hosts.worker | default([]) }}" loop: "{{ bootstrap_nodes.master + bootstrap_nodes.worker | default([]) }}"
loop_control: loop_control:
label: "{{ item.address }}" label: "{{ item.address }}"
- name: Restore Sops configuration file
# https://github.com/ansible-collections/community.sops/issues/153
- name: Restore sops configuration file
ansible.builtin.copy: ansible.builtin.copy:
src: "{{ repository_path.stdout }}/.sops.yaml.orig" src: "{{ repository_path }}/.sops.yaml.orig"
dest: "{{ repository_path.stdout }}/.sops.yaml" dest: "{{ repository_path }}/.sops.yaml"
mode: "0755" mode: "0755"
- name: Remove backup sops configuration file - name: Remove backed up Sops configuration file
ansible.builtin.file: ansible.builtin.file:
path: "{{ repository_path.stdout }}/.sops.yaml.orig" 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 state: absent
+33 -33
View File
@@ -1,58 +1,58 @@
--- ---
- name: Get absolute path to this Git repository # noqa: command-instead-of-module
ansible.builtin.command: git rev-parse --show-toplevel
changed_when: false
check_mode: false
register: repository_path
failed_when: repository_path.rc != 0
- name: Ensure Kubernetes directories exist - name: Ensure Kubernetes directories exist
when: item.state == 'directory'
ansible.builtin.file: ansible.builtin.file:
path: "{{ repository_path.stdout }}/kubernetes/{{ item.path }}" path: "{{ repository_path }}/kubernetes/{{ item.path }}"
state: directory state: directory
mode: "0755" mode: "0755"
with_community.general.filetree: with_community.general.filetree: ["../templates/kubernetes/"]
- ../templates/kubernetes/
when: item.state == 'directory'
- name: Template Kubernetes unencrypted files - name: Template Kubernetes unencrypted files
when: item.state == 'file' and 'sops' not in item.path
ansible.builtin.template: ansible.builtin.template:
src: "{{ item.src }}" src: "{{ item.src }}"
dest: "{{ repository_path.stdout }}/kubernetes/{{ item.path | replace('.j2', '') }}" dest: "{{ repository_path }}/kubernetes/{{ item.path | replace('.j2', '') }}"
with_community.general.filetree: mode: "0755"
- ../templates/kubernetes/ with_community.general.filetree: ["../templates/kubernetes/"]
when: item.state == 'file' and 'sops' not in item.path
# https://github.com/ansible-collections/community.sops/issues/153 # https://github.com/ansible-collections/community.sops/issues/153
- name: Backup sops configuration file - name: Template Kubernetes encrypted files
block:
- name: Rename Sops configuration file
ansible.builtin.copy: ansible.builtin.copy:
src: "{{ repository_path.stdout }}/.sops.yaml" src: "{{ repository_path }}/.sops.yaml"
dest: "{{ repository_path.stdout }}/.sops.yaml.orig" dest: "{{ repository_path }}/.sops.yaml.orig"
mode: "0755" mode: "0755"
- name: Remove sops configuration file - name: Remove Sops configuration file
ansible.builtin.file: ansible.builtin.file:
path: "{{ repository_path.stdout }}/.sops.yaml" path: "{{ repository_path }}/.sops.yaml"
state: absent state: absent
- name: Template Kubernetes encrypted files
- name: Template Kubernetes unencrypted files when: item.state == 'file' and 'sops' in item.path
community.sops.sops_encrypt: community.sops.sops_encrypt:
path: "{{ repository_path.stdout }}/kubernetes/{{ item.path | replace('.j2', '') }}" path: "{{ repository_path }}/kubernetes/{{ item.path | replace('.j2', '') }}"
encrypted_regex: ^(data|stringData)$ encrypted_regex: ^(data|stringData)$
age: ["{{ bootstrap_age_public_key }}"] age: ["{{ bootstrap_age_public_key }}"]
content_yaml: "{{ lookup('ansible.builtin.template', item.src) | from_yaml }}" content_yaml: "{{ lookup('ansible.builtin.template', item.src) | from_yaml }}"
mode: "0755" mode: "0755"
force: true force: true
with_community.general.filetree: with_community.general.filetree: ["../templates/kubernetes/"]
- ../templates/kubernetes/ - name: Restore Sops configuration file
when: item.state == 'file' and 'sops' in item.path
# https://github.com/ansible-collections/community.sops/issues/153
- name: Restore sops configuration file
ansible.builtin.copy: ansible.builtin.copy:
src: "{{ repository_path.stdout }}/.sops.yaml.orig" src: "{{ repository_path }}/.sops.yaml.orig"
dest: "{{ repository_path.stdout }}/.sops.yaml" dest: "{{ repository_path }}/.sops.yaml"
mode: "0755" mode: "0755"
- name: Remove backup sops configuration file - name: Remove backed up Sops configuration file
ansible.builtin.file: ansible.builtin.file:
path: "{{ repository_path.stdout }}/.sops.yaml.orig" 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 state: absent
+2 -9
View File
@@ -1,13 +1,6 @@
--- ---
- name: Get absolute path to this Git repository # noqa: command-instead-of-module - name: Template Sops configuration file
ansible.builtin.command: git rev-parse --show-toplevel
changed_when: false
check_mode: false
register: repository_path
failed_when: repository_path.rc != 0
- name: Template out sops configuration file
ansible.builtin.template: ansible.builtin.template:
src: "templates/.sops.yaml.j2" src: "templates/.sops.yaml.j2"
dest: "{{ repository_path.stdout }}/.sops.yaml" dest: "{{ repository_path }}/.sops.yaml"
mode: "0755" mode: "0755"
+7 -7
View File
@@ -2,10 +2,10 @@
- name: Verify master node count - name: Verify master node count
ansible.builtin.assert: ansible.builtin.assert:
that: that:
- "{{ bootstrap_hosts.master | length > 0 }}" - "{{ bootstrap_nodes.master | length > 0 }}"
- "{{ bootstrap_hosts.master | length is odd }}" - "{{ bootstrap_nodes.master | length is odd }}"
success_msg: "Master node count {{ bootstrap_hosts.master | length }} is correct." success_msg: "Master node count {{ bootstrap_nodes.master | length }} is correct."
fail_msg: "Master node count {{ bootstrap_hosts.master | length }} is not greater than 0 or is not odd." fail_msg: "Master node count {{ bootstrap_nodes.master | length }} is not greater than 0 or is not odd."
- name: Verify node CIDR - name: Verify node CIDR
ansible.builtin.assert: ansible.builtin.assert:
@@ -68,7 +68,7 @@
success_msg: "Node address {{ item.address }} is different than k8s_gateway, ingress-nginx or kube-vip." success_msg: "Node address {{ item.address }} is different than k8s_gateway, ingress-nginx or kube-vip."
fail_msg: "Node address {{ item.address }} is not different than k8s_gateway, ingress-nginx or kube-vip." fail_msg: "Node address {{ item.address }} is not different than k8s_gateway, ingress-nginx or kube-vip."
quiet: true quiet: true
loop: "{{ bootstrap_hosts.master + bootstrap_hosts.worker | default([]) }}" loop: "{{ bootstrap_nodes.master + bootstrap_nodes.worker | default([]) }}"
loop_control: loop_control:
label: "{{ item.address }}" label: "{{ item.address }}"
@@ -78,7 +78,7 @@
success_msg: "Node address {{ item.address }} is within {{ bootstrap_node_cidr }}." success_msg: "Node address {{ item.address }} is within {{ bootstrap_node_cidr }}."
fail_msg: "Node address {{ item.address }} is not within {{ bootstrap_node_cidr }}." fail_msg: "Node address {{ item.address }} is not within {{ bootstrap_node_cidr }}."
quiet: true quiet: true
loop: "{{ bootstrap_hosts.master + bootstrap_hosts.worker | default([]) }}" loop: "{{ bootstrap_nodes.master + bootstrap_nodes.worker | default([]) }}"
loop_control: loop_control:
label: "{{ item.address }}" label: "{{ item.address }}"
@@ -89,6 +89,6 @@
search_regex: OpenSSH search_regex: OpenSSH
timeout: 10 timeout: 10
connection: local connection: local
loop: "{{ bootstrap_hosts.master + bootstrap_hosts.worker | default([]) }}" loop: "{{ bootstrap_nodes.master + bootstrap_nodes.worker | default([]) }}"
loop_control: loop_control:
label: "{{ item.address }}" label: "{{ item.address }}"
@@ -6,4 +6,4 @@ metadata:
namespace: monitoring namespace: monitoring
stringData: stringData:
admin-user: admin admin-user: admin
admin-password: "{{ bootstrap_grafana_admin_password }}" admin-password: "{{ grafana.password }}"
@@ -89,7 +89,7 @@ spec:
kubeControllerManager: kubeControllerManager:
enabled: true enabled: true
endpoints: &cp endpoints: &cp
{% for item in bootstrap_hosts.master %} {% for item in bootstrap_nodes.master %}
- {{ item.address }} - {{ item.address }}
{% endfor %} {% endfor %}
serviceMonitor: serviceMonitor:
@@ -7,4 +7,4 @@ metadata:
type: Opaque type: Opaque
stringData: stringData:
username: admin username: admin
password: "{{ bootstrap_weave_gitops_admin_password | password_hash('bcrypt', rounds=10) }}" password: "{{ weave_gitops.password | password_hash('bcrypt', rounds=10) }}"
+3 -3
View File
@@ -4,15 +4,15 @@ kubernetes:
children: children:
master: master:
hosts: hosts:
{% for item in bootstrap_hosts.master %} {% for item in bootstrap_nodes.master %}
{{ item.name }}: {{ item.name }}:
ansible_user: {{ item.username }} ansible_user: {{ item.username }}
ansible_host: {{ item.address }} ansible_host: {{ item.address }}
{% endfor %} {% endfor %}
{% if bootstrap_hosts.worker | default([]) | length > 0 %} {% if bootstrap_nodes.worker | default([]) | length > 0 %}
worker: worker:
hosts: hosts:
{% for item in bootstrap_hosts.worker %} {% for item in bootstrap_nodes.worker %}
{{ item.name }}: {{ item.name }}:
ansible_user: {{ item.username }} ansible_user: {{ item.username }}
ansible_host: {{ item.address }} ansible_host: {{ item.address }}
@@ -1,7 +1,9 @@
#jinja2: trim_blocks: True, lstrip_blocks: True
--- ---
apiVersion: kustomize.config.k8s.io/v1beta1 apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization kind: Kustomization
resources: resources:
- ./namespace.yaml - ./namespace.yaml
- ./echo-server/ks.yaml {% if hajimari.enabled | default(false) %}
- ./hajimari/ks.yaml - ./hajimari/ks.yaml
{% endif %}
@@ -1,7 +1,10 @@
#jinja2: trim_blocks: True, lstrip_blocks: True
--- ---
apiVersion: kustomize.config.k8s.io/v1beta1 apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization kind: Kustomization
resources: resources:
- ./namespace.yaml - ./namespace.yaml
- ./addons/ks.yaml - ./addons/ks.yaml
{% if weave_gitops.enabled | default(false) %}
- ./weave-gitops/ks.yaml - ./weave-gitops/ks.yaml
{% endif %}
@@ -1,8 +1,15 @@
#jinja2: trim_blocks: True, lstrip_blocks: True
--- ---
apiVersion: kustomize.config.k8s.io/v1beta1 apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization kind: Kustomization
resources: resources:
- ./namespace.yaml - ./namespace.yaml
{% if grafana.enabled | default(false) %}
- ./grafana/ks.yaml - ./grafana/ks.yaml
{% endif %}
{% if kube_prometheus_stack.enabled | default(false) %}
- ./kube-prometheus-stack/ks.yaml - ./kube-prometheus-stack/ks.yaml
{% endif %}
{% if kubernetes_dashboard.enabled | default(false) %}
- ./kubernetes-dashboard/ks.yaml - ./kubernetes-dashboard/ks.yaml
{% endif %}
@@ -4,7 +4,7 @@ apiVersion: helm.toolkit.fluxcd.io/v2beta1
kind: HelmRelease kind: HelmRelease
metadata: metadata:
name: echo-server name: echo-server
namespace: default namespace: networking
spec: spec:
interval: 30m interval: 30m
chart: chart:
@@ -1,6 +1,6 @@
--- ---
apiVersion: kustomize.config.k8s.io/v1beta1 apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization kind: Kustomization
namespace: default namespace: networking
resources: resources:
- ./helmrelease.yaml - ./helmrelease.yaml
@@ -5,7 +5,7 @@ metadata:
name: cluster-apps-echo-server name: cluster-apps-echo-server
namespace: flux-system namespace: flux-system
spec: spec:
path: ./kubernetes/apps/default/echo-server/app path: ./kubernetes/apps/networking/echo-server/app
prune: true prune: true
sourceRef: sourceRef:
kind: GitRepository kind: GitRepository
@@ -4,6 +4,7 @@ kind: Kustomization
resources: resources:
- ./namespace.yaml - ./namespace.yaml
- ./cloudflared/ks.yaml - ./cloudflared/ks.yaml
- ./echo-server/ks.yaml
- ./external-dns/ks.yaml - ./external-dns/ks.yaml
- ./ingress-nginx/ks.yaml - ./ingress-nginx/ks.yaml
- ./k8s-gateway/ks.yaml - ./k8s-gateway/ks.yaml
+1
View File
@@ -1 +1,2 @@
addons.yaml
config.yaml config.yaml
+26
View File
@@ -0,0 +1,26 @@
---
#
# Addons configuration - addons.yaml is gitignored
#
# https://github.com/toboshii/hajimari
hajimari:
enabled: false
# https://github.com/grafana/grafana
grafana:
enabled: false
# password:
# https://github.com/prometheus-community/helm-charts/tree/main/charts/kube-prometheus-stack
kube_prometheus_stack:
enabled: false
# https://github.com/kubernetes/dashboard
kubernetes_dashboard:
enabled: false
# https://github.com/weaveworks/weave-gitops
weave_gitops:
enabled: false
# password:
+2 -6
View File
@@ -1,6 +1,6 @@
--- ---
# #
# Bootstrap configuration - This file is gitignored # Bootstrap configuration - config.yaml is gitignored
# #
# Github username (e.g. onedr0p) # Github username (e.g. onedr0p)
@@ -16,10 +16,6 @@ bootstrap_acme_email:
# Flux github webhook token (openssl rand -hex 12) # Flux github webhook token (openssl rand -hex 12)
bootstrap_flux_github_webhook_token: bootstrap_flux_github_webhook_token:
# Grafana admin password (openssl rand -hex 12)
bootstrap_grafana_admin_password:
# Weave GitOps dashboard password (openssl rand -hex 12)
bootstrap_weave_gitops_admin_password:
# Cloudflare domain # Cloudflare domain
bootstrap_cloudflare_domain: bootstrap_cloudflare_domain:
@@ -45,7 +41,7 @@ bootstrap_cluster_cidr: 10.42.0.0/16
bootstrap_service_cidr: 10.43.0.0/16 bootstrap_service_cidr: 10.43.0.0/16
# Node information # Node information
bootstrap_hosts: bootstrap_nodes:
# Use only 1, 3 or more odd master nodes, recommended is 3 # Use only 1, 3 or more odd master nodes, recommended is 3
master: [] master: []
# - name: kube0 # - name: kube0