Reduce loop list length;Test vApp properties
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Danny Bessems 2023-02-07 22:11:09 +01:00
parent 4d2513c1a5
commit b8cb76e7ac
5 changed files with 52 additions and 5 deletions

View File

@ -0,0 +1,24 @@
- name: Check for expected vApp properties
ansible.builtin.assert:
that:
- vapp[item] is defined
- (vapp[item] | length) > 0
loop:
- deployment.type
- guestinfo.dnsserver
- guestinfo.gateway
- guestinfo.hostname
- guestinfo.ipaddress
- guestinfo.prefixlength
- guestinfo.rootsshkey
- hv.fqdn
- hv.password
- hv.username
- ippool.endip
- ippool.startip
- metacluster.fqdn
- metacluster.password
- metacluster.token
- metacluster.vip
- workloadcluster.name
- workloadcluster.vip

View File

@ -54,18 +54,20 @@
- name: WORKAROUND - Update image references to use local registry - name: WORKAROUND - Update image references to use local registry
ansible.builtin.replace: ansible.builtin.replace:
dest: "{{ item.root ~ '/' ~ item.path }}" dest: "{{ item }}"
regexp: '([ ]+image:[ "]+)(?!({{ _template.pattern }}|"{{ _template.pattern }}))' regexp: '([ ]+image:[ "]+)(?!({{ _template.pattern }}|"{{ _template.pattern }}))'
replace: '\1{{ _template.pattern }}' replace: '\1{{ _template.pattern }}'
vars: vars:
fileglobs:
- "{{ query('ansible.builtin.fileglob', '/opt/metacluster/cluster-api/cni-calico/' ~ components.clusterapi.workload.version.calico ~ '/*.yaml') }}"
- "{{ query('ansible.builtin.fileglob', '/opt/metacluster/cluster-api/infrastructure-vsphere/' ~ components.clusterapi.management.version.infrastructure_vsphere ~ '/*.yaml') }}"
_template: _template:
pattern: registry.{{ vapp['metacluster.fqdn'] }}/library/ pattern: registry.{{ vapp['metacluster.fqdn'] }}/library/
loop: "{{ lookup('community.general.filetree', '/opt/metacluster/cluster-api') }}" loop: "{{ fileglobs[0:] | flatten | select }}"
loop_control: loop_control:
label: "{{ item.path }}" label: "{{ item | basename }}"
when: when:
- item.path is search('.yaml') - item is not search("components.yaml|metadata.yaml")
- item.path is not search("cert-manager.yaml|clusterctl.yaml|components.yaml|metadata.yaml")
- name: Generate kustomization template - name: Generate kustomization template
ansible.builtin.template: ansible.builtin.template:

View File

@ -1 +1,2 @@
- import_tasks: vapp.yml
- import_tasks: vcenter.yml - import_tasks: vcenter.yml

View File

@ -1,2 +1,3 @@
- import_tasks: vapp.yml
- import_tasks: vcenter.yml - import_tasks: vcenter.yml
- import_tasks: metacluster.yml - import_tasks: metacluster.yml

View File

@ -0,0 +1,19 @@
- name: Check for expected vApp properties
ansible.builtin.assert:
that:
- vapp[item] is defined
- (vapp[item] | length) > 0
loop:
- guestinfo.dnsserver
- guestinfo.gateway
- guestinfo.hostname
- guestinfo.ipaddress
- guestinfo.prefixlength
- guestinfo.rootsshkey
- hv.fqdn
- hv.password
- hv.username
- metacluster.fqdn
- metacluster.password
- metacluster.token
- metacluster.vip