Refactor templating #42
continuous-integration/drone/push Build is failing Details

This commit is contained in:
Danny Bessems 2022-07-11 09:24:04 +02:00
parent 2847542976
commit f04095db8c
3 changed files with 25 additions and 19 deletions

View File

@ -1 +0,0 @@
#jinja2:variable_start_string:'[%' , variable_end_string:'%]'

View File

@ -25,16 +25,16 @@
- name: Aggregate chart_values into dict - name: Aggregate chart_values into dict
ansible.builtin.set_fact: ansible.builtin.set_fact:
chart_values: "{{ chart_values | default({}) | combine({ item.key: { 'chart_values': item.value.helm.chart_values } }) }}" chart_values: "{{ chart_values | default({}) | combine({ item.key: { 'chart_values': (item.value.helm.chart_values | from_yaml) } }) }}"
when: item.value.helm.chart_values is defined when: item.value.helm.chart_values is defined
loop: "{{ lookup('ansible.builtin.dict', components) }}" loop: "{{ lookup('ansible.builtin.dict', components) }}"
loop_control: loop_control:
label: "{{ item.key }}" label: "{{ item.key }}"
- name: Write dict to vars_file - name: Write dict to vars_file
ansible.builtin.blockinfile: ansible.builtin.copy:
path: /opt/firstboot/ansible/vars/metacluster.yml dest: /opt/firstboot/ansible/vars/metacluster.yml
block: "{{ { 'components': chart_values } | to_nice_yaml(indent=2, width=4096) }}" content: "{{ { 'components': chart_values } | to_nice_yaml(indent=2, width=4096) }}"
- name: Parse helm charts for container images - name: Parse helm charts for container images
ansible.builtin.shell: ansible.builtin.shell:

View File

@ -20,69 +20,76 @@ components:
version: 1.3.0 version: 1.3.0
chart: longhorn/longhorn chart: longhorn/longhorn
parse_logic: cat values.yaml | yq eval '.. | select(has("repository")) | .repository + ":" + .tag' parse_logic: cat values.yaml | yq eval '.. | select(has("repository")) | .repository + ":" + .tag'
chart_values: chart_values: |
{% raw %}
defaultSettings: defaultSettings:
defaultDataPath: /mnt/blockstorage defaultDataPath: /mnt/blockstorage
defaultReplicaCount: 1 defaultReplicaCount: 1
ingress: ingress:
enabled: true enabled: true
host: storage.[% vapp['metacluster.fqdn'] %] host: storage.{{ vapp['metacluster.fqdn'] }}
persistence: persistence:
defaultClassReplicaCount: 1 defaultClassReplicaCount: 1
{% endraw %}
harbor: harbor:
helm: helm:
version: 1.9.1 # (= Harbor v2.5.1) version: 1.9.1 # (= Harbor v2.5.1)
chart: harbor/harbor chart: harbor/harbor
parse_logic: helm template . | yq --no-doc eval '.. | .image? | select(.)' | sort -u | awk '!/ /' parse_logic: helm template . | yq --no-doc eval '.. | .image? | select(.)' | sort -u | awk '!/ /'
chart_values: chart_values: |
{% raw %}
expose: expose:
ingress: ingress:
hosts: hosts:
core: registry.[% vapp['metacluster.fqdn'] %] core: registry.{{ vapp['metacluster.fqdn'] }}
externalURL: https://registry.[% vapp['metacluster.fqdn'] %] externalURL: https://registry.{{ vapp['metacluster.fqdn'] }}
harborAdminPassword: "[% vapp['guestinfo.rootpw'] %]" harborAdminPassword: "{{ vapp['guestinfo.rootpw'] }}"
notary: notary:
enabled: false enabled: false
{% endraw %}
gitea: gitea:
helm: helm:
version: v5.0.9 # (= Gitea v1.16.8) version: v5.0.9 # (= Gitea v1.16.8)
chart: gitea-charts/gitea chart: gitea-charts/gitea
parse_logic: helm template . | yq --no-doc eval '.. | .image? | select(.)' | sort -u | sed '/:/!s/$/:latest/' parse_logic: helm template . | yq --no-doc eval '.. | .image? | select(.)' | sort -u | sed '/:/!s/$/:latest/'
chart_values: chart_values: |
{% raw %}
gitea: gitea:
admin: admin:
username: administrator username: administrator
password: "[% vapp['guestinfo.rootpw'] %]" password: "{{ vapp['guestinfo.rootpw'] }}"
email: admin@[% vapp['metacluster.fqdn'] %] email: admin@{{ vapp['metacluster.fqdn'] }}
image: image:
pullPolicy: IfNotPresent pullPolicy: IfNotPresent
ingress: ingress:
enabled: true enabled: true
hosts: hosts:
- host: git.[% vapp['metacluster.fqdn'] %] - host: git.{{ vapp['metacluster.fqdn'] }}
paths: paths:
- path: / - path: /
pathType: Prefix pathType: Prefix
{% endraw %}
argo-cd: argo-cd:
helm: helm:
version: 4.9.7 # (= ArgoCD v2.4.2) version: 4.9.7 # (= ArgoCD v2.4.2)
chart: argo/argo-cd chart: argo/argo-cd
parse_logic: helm template . | yq --no-doc eval '.. | .image? | select(.)' | sort -u | awk '!/ /' parse_logic: helm template . | yq --no-doc eval '.. | .image? | select(.)' | sort -u | awk '!/ /'
chart_values: chart_values: |
{% raw %}
server: server:
extraArgs: extraArgs:
- --insecure - --insecure
ingress: ingress:
enabled: true enabled: true
hosts: hosts:
- gitops.[% vapp['metacluster.fqdn'] %] - gitops.{{ vapp['metacluster.fqdn'] }}
configs: configs:
secret: secret:
argocdServerAdminPassword: "[% vapp['guestinfo.rootpw'] | password_hash('bcrypt') %]" argocdServerAdminPassword: "{{ vapp['guestinfo.rootpw'] | password_hash('bcrypt') }}"
{% endraw %}
dependencies: dependencies: