Fix Ansible templating;DRY
Some checks reported errors
continuous-integration/drone/push Build encountered an error

This commit is contained in:
Danny Bessems 2023-04-03 16:26:38 +02:00
parent 7ac4cc0914
commit 6942c33ae8
3 changed files with 30 additions and 21 deletions

View File

@ -13,15 +13,38 @@ volumes:
steps: steps:
- name: Debugging information - name: Debugging information
image: bv11-cr01.bessems.eu/library/packer-extended image: bv11-cr01.bessems.eu/library/packer-extended
pull: always
commands: commands:
- ansible --version - ansible --version
- ovftool --version - ovftool --version
- packer --version - packer --version
- yamllint --version - yamllint --version
- name: Linting
image: bv11-cr01.bessems.eu/library/packer-extended
pull: always
commands:
- |
yamllint -d "{extends: relaxed, rules: {line-length: disable}}" \
ansible \
packer/preseed/UbuntuServer22.04/user-data \
scripts
- name: Install Ansible Galaxy collections
image: bv11-cr01.bessems.eu/library/packer-extended
pull: always
commands:
- |
ansible-galaxy install \
-r ansible/requirements.yml \
-p /scratch/ansible-galaxy
volumes:
- name: scratch
path: /scratch
- name: Kubernetes Bootstrap Appliance - name: Kubernetes Bootstrap Appliance
depends_on: depends_on:
- Debugging information - Install Ansible Galaxy collections
image: bv11-cr01.bessems.eu/library/packer-extended image: bv11-cr01.bessems.eu/library/packer-extended
pull: always pull: always
commands: commands:
@ -30,14 +53,6 @@ steps:
packer/preseed/UbuntuServer22.04/user-data packer/preseed/UbuntuServer22.04/user-data
- | - |
export K8S_VERSION=$(yq '.components.clusterapi.workload.version.k8s' < ./ansible/vars/metacluster.yml) export K8S_VERSION=$(yq '.components.clusterapi.workload.version.k8s' < ./ansible/vars/metacluster.yml)
- |
yamllint -d "{extends: relaxed, rules: {line-length: disable}}" \
ansible \
packer/preseed/UbuntuServer22.04/user-data \
scripts
- |
ansible-galaxy install \
-r ansible/requirements.yml
- | - |
packer init -upgrade \ packer init -upgrade \
./packer ./packer
@ -87,7 +102,7 @@ steps:
- name: Kubernetes Upgrade Appliance - name: Kubernetes Upgrade Appliance
depends_on: depends_on:
- Debugging information - Install Ansible Galaxy collections
image: bv11-cr01.bessems.eu/library/packer-extended image: bv11-cr01.bessems.eu/library/packer-extended
pull: always pull: always
commands: commands:
@ -96,14 +111,6 @@ steps:
packer/preseed/UbuntuServer22.04/user-data packer/preseed/UbuntuServer22.04/user-data
- | - |
export K8S_VERSION=$(yq '.components.clusterapi.workload.version.k8s' < ./ansible/vars/metacluster.yml) export K8S_VERSION=$(yq '.components.clusterapi.workload.version.k8s' < ./ansible/vars/metacluster.yml)
- |
yamllint -d "{extends: relaxed, rules: {line-length: disable}}" \
ansible \
packer/preseed/UbuntuServer22.04/user-data \
scripts
- |
ansible-galaxy install \
-r ansible/requirements.yml
- | - |
packer init -upgrade \ packer init -upgrade \
./packer ./packer

View File

@ -59,9 +59,9 @@
secret: argocd-cluster-{{ vapp['workloadcluster.name'] | lower }} secret: argocd-cluster-{{ vapp['workloadcluster.name'] | lower }}
url: https://{{ vapp['workloadcluster.vip'] }}:6443 url: https://{{ vapp['workloadcluster.vip'] }}:6443
kubeconfig: kubeconfig:
ca: (secret_workloadcluster_kubeconfig.resources[0].data.value | b64decode | from_yaml).clusters[0].cluster['certificate-authority-data'] | b64encode ca: "{{ (secret_workloadcluster_kubeconfig.resources[0].data.value | b64decode | from_yaml).clusters[0].cluster['certificate-authority-data'] | b64encode }}"
certificate: (secret_workloadcluster_kubeconfig.resources[0].data.value | b64decode | from_yaml).users[0].user['client-certificate-data'] | b64encode certificate: "{{ (secret_workloadcluster_kubeconfig.resources[0].data.value | b64decode | from_yaml).users[0].user['client-certificate-data'] | b64encode }}"
key: (secret_workloadcluster_kubeconfig.resources[0].data.value | b64decode | from_yaml).users[0].user['client-key-data'] | b64encode key: "{{ (secret_workloadcluster_kubeconfig.resources[0].data.value | b64decode | from_yaml).users[0].user['client-key-data'] | b64encode }}"
- name: Configure workload-cluster GitOps repository - name: Configure workload-cluster GitOps repository
ansible.builtin.template: ansible.builtin.template:

View File

@ -34,6 +34,8 @@ build {
"PYTHONUNBUFFERED=1" "PYTHONUNBUFFERED=1"
] ]
use_proxy = "false" use_proxy = "false"
collections-path = "/scratch/ansible-galaxy"
extra_arguments = [ extra_arguments = [
"--extra-vars", "appliancetype=${source.name}", "--extra-vars", "appliancetype=${source.name}",
"--extra-vars", "ansible_ssh_pass=${var.ssh_password}", "--extra-vars", "ansible_ssh_pass=${var.ssh_password}",