From fdead3c41c6fff69e2db914b73b2db9afbc0c41b Mon Sep 17 00:00:00 2001 From: Danny Bessems Date: Fri, 30 Dec 2022 11:14:49 +0100 Subject: [PATCH] Fix foldername;Add semi-recursive yaml parse commands --- .../roles/assets/tasks/containerimages.yml | 10 +++- .../roles/workloadcluster/tasks/.note | 52 ++++--------------- .../workloadcluster/tasks/clusterapi.yml | 2 +- 3 files changed, 21 insertions(+), 43 deletions(-) diff --git a/ansible/roles/assets/tasks/containerimages.yml b/ansible/roles/assets/tasks/containerimages.yml index 8a841aa..f0c1b75 100644 --- a/ansible/roles/assets/tasks/containerimages.yml +++ b/ansible/roles/assets/tasks/containerimages.yml @@ -1,6 +1,14 @@ - name: Parse manifests for container images ansible.builtin.shell: - cmd: cat {{ item.dest }} | yq --no-doc eval '.. | .image? | select(.)' | awk '!/ /' | sort -u + # This set of commands is necessary to deal with multi-line scalar values + # eg.: + # key: | + # multi-line + # value + cmd: >- + cat {{ item.dest }} | yq --no-doc eval '.. | .image? | select(.)' | awk '!/ /'; + cat {{ item.dest }} | yq eval '.data.data' | yq --no-doc eval '.. | .image? | select(.)'; + cat {{ item.dest }} | yq --no-doc eval '.. | .files? | with_entries(select(.value.path == "*.yaml")).[0].content' | awk '!/null/' | yq eval '.. | .image? | select(.)' register: parsedmanifests loop: "{{ clusterapi_manifests.results }}" loop_control: diff --git a/ansible/roles/firstboot/files/ansible_payload/roles/workloadcluster/tasks/.note b/ansible/roles/firstboot/files/ansible_payload/roles/workloadcluster/tasks/.note index 6a186b2..b8bc971 100644 --- a/ansible/roles/firstboot/files/ansible_payload/roles/workloadcluster/tasks/.note +++ b/ansible/roles/firstboot/files/ansible_payload/roles/workloadcluster/tasks/.note @@ -1,53 +1,23 @@ files: - [...] - - content: | - #!/bin/bash - vmtoolsd --cmd 'info-get guestinfo.ovfEnv' > /tmp/ovfenv - - IPAddress=$(sed -n 's/.*Property oe:key="guestinfo.interface.0.ip.0.address" oe:value="\([^"]*\).*/\1/p' /tmp/ovfenv) - SubnetMask=$(sed -n 's/.*Property oe:key="guestinfo.interface.0.ip.0.netmask" oe:value="\([^"]*\).*/\1/p' /tmp/ovfenv) - Gateway=$(sed -n 's/.*Property oe:key="guestinfo.interface.0.route.0.gateway" oe:value="\([^"]*\).*/\1/p' /tmp/ovfenv) - DNS=$(sed -n 's/.*Property oe:key="guestinfo.dns.servers" oe:value="\([^"]*\).*/\1/p' /tmp/ovfenv) - MACAddress=$(sed -n 's/.*ve:Adapter ve:mac="\([^"]*\).*/\1/p' /tmp/ovfenv) - - mask2cidr() { - c=0 - x=0$( printf '%o' $${1//./ } ) - - while [ $x -gt 0 ]; do - let c+=$((x%2)) 'x>>=1' - done - - echo $c - } - - Prefix=$(mask2cidr $SubnetMask) - - cat > /etc/netplan/01-netcfg.yaml <