From 6087e2d90eff28473369d51601e2435d2e649215 Mon Sep 17 00:00:00 2001 From: Christian Kellner Date: Wed, 9 Sep 2020 14:35:58 +0200 Subject: [PATCH] run-builder: inspect network to get gateway IP Instead of inferring the gateway ip via the the network device for the podman bridge, where the name can change, use podman network inspect. ```js The json looks like this: [ { "cniVersion": "0.4.0", "name": "org.osbuild.koji", "plugins": [ { "bridge": "cni-podman1", "hairpinMode": true, "ipMasq": true, "ipam": { "ranges": [ [ { "gateway": "10.89.0.1", "subnet": "10.89.0.0/24" } ] ], "routes": [ { "dst": "0.0.0.0/0" } ], "type": "host-local" }, "isGateway": true, "type": "bridge" }, { "capabilities": { "portMappings": true }, "type": "portmap" }, { "backend": "", "type": "firewall" }, { "domainName": "dns.podman", "type": "dnsname" } ] } ] ``` So the podman format for this is very obviously: {{ (index (index (index .plugins 0).ipam.ranges 0) 0).gateway }} --- run-builder.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/run-builder.sh b/run-builder.sh index 8dd25d4..f4790eb 100755 --- a/run-builder.sh +++ b/run-builder.sh @@ -19,10 +19,13 @@ else exit 2 fi +GATEWAY_IP=$(podman network inspect org.osbuild.koji --format '{{ (index (index (index .plugins 0).ipam.ranges 0) 0).gateway }}') +echo "Gateway IP is $GATEWAY_IP" + ${CONTAINER_RUNTIME} run --rm -i -t --name org.osbuild.koji.builder --network org.osbuild.koji \ -v "${SHARE_DIR}:/share:z" \ -v "${DATA_DIR}:/mnt:z" \ -v "${PWD}/container/builder/osbuild-koji.conf:/etc/koji-osbuild/builder.conf:z" \ --hostname org.osbuild.koji.kojid \ - --add-host=composer:$(ip route show dev cni-podman0 | cut -d\ -f7) \ + --add-host=composer:${GATEWAY_IP} \ koji.builder