Been trying to learn some better scripting in bash. Normally I can pull data values to iterate into command strings, but this one is showing my ignorance on syntax.
#! /bin/bash
while IFS=',' read name_c1 ip_c2
do
echo "Name:" $name_c1
echo "file:" v1-$ip_c2.yaml
export file=v1-$ip_c2.yaml
# cat $file
/usr/bin/incus launch images:debian/12/cloud $name_c1 -p prod-mgt --config=cloud-init.network-config=$(cat $file)
done < <(tail -n +1 host-list)
When I just echo the variables they render fine, but when rendering them from the command string, something is off. If I simplify the command string to just "/usr/bin/incus launch images:debian/12/cloud $name_c1"
Here is the output I get:
Name: c1
file: v1-192.168.0.222.yaml
Error: yaml: unmarshal errors:
line 1: cannot unmarshal !!str `c2,192....` into api.InstancePut
I know my syntax is off most likely, any clues to what I need to change to render those variables pulled from the host file?
Example of the host-list file for clarity:
c1,192.168.0.222
c2,192.168.0.221
c3,192.168.0.220
c4,192.168.0.219
c5,192.168.0.218
c6,192.168.0.217
Thank you
< filename
.c2,192....
into api.InstancePut ran it through shellcheck and cleaned it up a bit.