Simplify playbook roles
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
Danny Bessems 2022-11-24 10:59:41 +01:00
parent 2d99511360
commit c27712bc20
14 changed files with 56 additions and 81 deletions

View File

@ -7,5 +7,4 @@
roles: roles:
- os - os
- firstboot - firstboot
- appliance - assets
- metacluster

View File

@ -1,2 +0,0 @@
- name: Install & configure dependencies
import_tasks: dependencies.yml

View File

@ -1,36 +1,3 @@
- name: Create folder structure(s)
ansible.builtin.file:
path: "{{ item }}"
state: directory
loop:
- /opt/metacluster/helm-charts
- /opt/metacluster/manifests/bootstrap-kubeadm/{{ components.clusterapi.management.version.base }}
- /opt/metacluster/manifests/cert-manager/{{ components.clusterapi.management.version.cert_manager }}
- /opt/metacluster/manifests/cluster-api/{{ components.clusterapi.management.version.base }}
- /opt/metacluster/manifests/control-plane-kubeadm/{{ components.clusterapi.management.version.base }}
- /opt/metacluster/manifests/infrastructure-vsphere/{{ components.clusterapi.management.version.infrastructure_vsphere }}
- /opt/metacluster/container-images
- name: Add helm repositories
kubernetes.core.helm_repository:
name: "{{ item.name }}"
repo_url: "{{ item.url }}"
state: present
loop: "{{ platform.helm_repositories }}"
- name: Fetch helm charts
ansible.builtin.command:
cmd: helm fetch {{ item.value.helm.chart }} --untar --version {{ item.value.helm.version }}
chdir: /opt/metacluster/helm-charts
when: item.value.helm is defined
register: helmcharts
loop: "{{ lookup('ansible.builtin.dict', components) }}"
loop_control:
label: "{{ item.key }}"
retries: 5
delay: 5
until: helmcharts is not failed
- block: - block:
- name: Aggregate chart_values into dict - name: Aggregate chart_values into dict
@ -51,7 +18,7 @@
- name: Download ClusterAPI manifests - name: Download ClusterAPI manifests
ansible.builtin.get_url: ansible.builtin.get_url:
url: "{{ item.url }}" url: "{{ item.url }}"
dest: /opt/metacluster/manifests/{{ item.dest }} dest: /opt/metacluster/cluster-api/{{ item.dest }}
register: clusterapi_manifests register: clusterapi_manifests
loop: loop:
# This list is based on `clusterctl config repositories` # This list is based on `clusterctl config repositories`

View File

@ -1,10 +1,3 @@
# - name: Create folder structure(s)
# ansible.builtin.file:
# path: "{{ item }}"
# state: directory
# loop:
# - /foo
- name: Download & install static binaries - name: Download & install static binaries
ansible.builtin.get_url: ansible.builtin.get_url:
url: "{{ item.url }}" url: "{{ item.url }}"

View File

@ -0,0 +1,5 @@
- name: Clone git repository
ansible.builtin.git:
repo: "{{ platform.gitops.repository.uri }}"
version: "{{ platform.gitops.repository.revision }}"
dest: /opt/metacluster/git-repositories/gitops

View File

@ -0,0 +1,19 @@
- name: Add helm repositories
kubernetes.core.helm_repository:
name: "{{ item.name }}"
repo_url: "{{ item.url }}"
state: present
loop: "{{ platform.helm_repositories }}"
- name: Fetch helm charts
ansible.builtin.command:
cmd: helm fetch {{ item.value.helm.chart }} --untar --version {{ item.value.helm.version }}
chdir: /opt/metacluster/helm-charts
when: item.value.helm is defined
register: helmcharts
loop: "{{ lookup('ansible.builtin.dict', components) }}"
loop_control:
label: "{{ item.key }}"
retries: 5
delay: 5
until: helmcharts is not failed

View File

@ -1,11 +1,3 @@
- name: Create folder structure(s)
ansible.builtin.file:
path: "{{ item }}"
state: directory
loop:
- /var/lib/rancher/k3s/agent/images
- /var/lib/rancher/k3s/server/manifests
- /opt/metacluster/k3s
- name: Download & install K3s binary - name: Download & install K3s binary
ansible.builtin.get_url: ansible.builtin.get_url:

View File

@ -0,0 +1,24 @@
- name: Create folder structure(s)
ansible.builtin.file:
path: "{{ item }}"
state: directory
loop:
- /opt/metacluster/cluster-api/bootstrap-kubeadm/{{ components.clusterapi.management.version.base }}
- /opt/metacluster/cluster-api/cert-manager/{{ components.clusterapi.management.version.cert_manager }}
- /opt/metacluster/cluster-api/cluster-api/{{ components.clusterapi.management.version.base }}
- /opt/metacluster/cluster-api/control-plane-kubeadm/{{ components.clusterapi.management.version.base }}
- /opt/metacluster/cluster-api/infrastructure-vsphere/{{ components.clusterapi.management.version.infrastructure_vsphere }}
- /opt/metacluster/container-images
- /opt/metacluster/git-repositories/gitops
- /opt/metacluster/helm-charts
- /opt/metacluster/k3s
- /opt/workloadcluster/node-templates
- /var/lib/rancher/k3s/agent/images
- /var/lib/rancher/k3s/server/manifests
- import_tasks: dependencies.yml
- import_tasks: k3s.yml
- import_tasks: helm.yml
- import_tasks: git
- import_tasks: containerimages.yml
- import_tasks: nodetemplates.yml

View File

@ -0,0 +1,4 @@
- name: Download node-template image
ansible.builtin.uri:
url: "{{ components.clusterapi.workload.node_template.url }}"
dest: /opt/workloadcluster/node-templates/{{ components.clusterapi.workload.node_template.name }}

View File

@ -1,7 +1,7 @@
- name: Configure clusterctl - name: Configure clusterctl
ansible.builtin.template: ansible.builtin.template:
src: clusterctl.j2 src: clusterctl.j2
dest: /opt/metacluster/manifests/clusterctl.yaml dest: /opt/metacluster/cluster-api/clusterctl.yaml
vars: vars:
_template: _template:
version: version:
@ -27,4 +27,4 @@
- name: Initialize Cluster API management cluster - name: Initialize Cluster API management cluster
ansible.builtin.shell: ansible.builtin.shell:
cmd: clusterctl init -v5 -i vsphere:{{ components.clusterapi.management.version.infrastructure_vsphere }} --config ./clusterctl.yaml --kubeconfig {{ kubeconfig.path }} cmd: clusterctl init -v5 -i vsphere:{{ components.clusterapi.management.version.infrastructure_vsphere }} --config ./clusterctl.yaml --kubeconfig {{ kubeconfig.path }}
chdir: /opt/metacluster/manifests chdir: /opt/metacluster/cluster-api

View File

@ -1,8 +0,0 @@
- name: Pre-stage K3s components
import_tasks: k3s.yml
- name: Pre-stage meta-cluster components
import_tasks: components.yml
- name: Pre-stage meta-cluster configuration and workload-cluster components
import_tasks: staging.yml

View File

@ -1,18 +0,0 @@
- name: Create folder structure(s)
ansible.builtin.file:
path: "{{ item }}"
state: directory
loop:
- /opt/metacluster/git-repositories/gitops
- /opt/workloadcluster/node-templates
- name: Clone git repository
ansible.builtin.git:
repo: "{{ platform.gitops.repository.uri }}"
version: "{{ platform.gitops.repository.revision }}"
dest: /opt/metacluster/git-repositories/gitops
- name: Download node-template image
ansible.builtin.uri:
url: "{{ components.clusterapi.workload.node_template.url }}"
dest: /opt/workloadcluster/node-templates/{{ components.clusterapi.workload.node_template.name }}