Packer.Images/ansible/roles/firstboot/files/ansible_payload/roles/workloadcluster/tasks/clusterapi.yml

61 lines
2.6 KiB
YAML
Raw Normal View History

2022-11-08 13:43:40 +00:00
- name: Configure clusterctl
ansible.builtin.template:
src: clusterctl.j2
2022-11-24 09:59:41 +00:00
dest: /opt/metacluster/cluster-api/clusterctl.yaml
2022-11-08 13:43:40 +00:00
vars:
_template:
version:
base: "{{ components.clusterapi.management.version.base }}"
cert_manager: "{{ components.clusterapi.management.version.cert_manager }}"
infrastructure_vsphere: "{{ components.clusterapi.management.version.infrastructure_vsphere }}"
2022-12-04 10:22:17 +00:00
ipam_incluster: "{{ components.clusterapi.management.version.ipam_incluster }}"
2022-11-08 13:43:40 +00:00
hv:
fqdn: "{{ vapp['hv.fqdn'] }}"
tlsthumbprint: "{{ tls_thumbprint.stdout }}"
2022-11-08 13:43:40 +00:00
username: "{{ vapp['hv.username'] }}"
password: "{{ vapp['hv.password'] }}"
datacenter: "{{ vcenter_info.datacenter }}"
datastore: "{{ vcenter_info.datastore }}"
network: "{{ vcenter_info.network }}"
2022-11-08 18:46:37 +00:00
resourcepool: "{{ vcenter_info.resourcepool }}"
folder: "{{ vcenter_info.folder }}"
2022-11-08 13:43:40 +00:00
cluster:
2022-11-09 15:59:43 +00:00
nodetemplate: "{{ (components.clusterapi.workload.node_template.name | split('.'))[:-1] | join('.') }}"
2022-11-08 13:43:40 +00:00
publickey: "{{ vapp['guestinfo.rootsshkey'] }}"
version: "{{ components.clusterapi.workload.version.k8s }}"
vip: "{{ vapp['workloadcluster.vip'] }}"
- name: Update image references to use local registry
ansible.builtin.replace:
dest: "{{ item.root + '/' + item.path }}"
regexp: '([ ]+image:[ "]+)(?!({{ _template.pattern }}|"{{ _template.pattern }}))'
replace: '\1{{ _template.pattern }}'
vars:
_template:
pattern: registry.{{ vapp['metacluster.fqdn'] }}/library/
loop: "{{ lookup('community.general.filetree', '/opt/metacluster/cluster-api') }}"
loop_control:
label: "{{ item.path }}"
when:
- item.path is search('.yaml')
- item.path is not search("clusterctl.yaml|metadata.yaml")
- name: Generate kustomization template
ansible.builtin.template:
src: kustomization.cluster-template.j2
dest: /opt/metacluster/cluster-api/infrastructure-vsphere/{{ components.clusterapi.management.version.infrastructure_vsphere }}/kustomization.yaml
vars:
_template:
rootca: "{{ stepca_cm_certs.resources[0].data['root_ca.crt'] }}"
- name: Initialize Cluster API management cluster
ansible.builtin.shell:
2022-12-04 10:22:17 +00:00
cmd: >-
clusterctl init \
-v5 \
--infrastructure vsphere:{{ components.clusterapi.management.version.infrastructure_vsphere }} \
--ipam in-cluster:{{ components.clusterapi.management.version.ipam_incluster }} \
2022-12-04 10:22:17 +00:00
--config ./clusterctl.yaml \
--kubeconfig {{ kubeconfig.path }}
2022-11-24 09:59:41 +00:00
chdir: /opt/metacluster/cluster-api