0

I'm stuck for houres on this strange issue. I have a bashscript which is executing the following:

TEST="12.x.x.x"

echo ${TEST} gave me 12.x.x.x

So now I want to use this env var in my command:

oadm ca create-server-cert --signer-cert=ca.crt \
    --signer-key=ca.key --signer-serial=ca.serial.txt \
    --hostnames='docker-registry.default.svc.cluster.local,$TEST' \
    --cert=registry.crt --key=registry.key

An echo of this command shows the content of $TEST in it. But the command fails (it did not create the crt and key for my IP). But it works when I'm just executing:

oadm ca create-server-cert --signer-cert=ca.crt \
    --signer-key=ca.key --signer-serial=ca.serial.txt \
    --hostnames='docker-registry.default.svc.cluster.local,12.x.x.x' \
    --cert=registry.crt --key=registry.key

What could be the issue? An echo of $TEST gave always my IP. Before and after the command.

2 Answers 2

2

Single quotes prevent variable expansion. Try with double quotes:

oadm ca create-server-cert --signer-cert=ca.crt \
    --signer-key=ca.key --signer-serial=ca.serial.txt \
    --hostnames="docker-registry.default.svc.cluster.local,${TEST}" \
    --cert=registry.crt --key=registry.key
0

The variable is not valid between single quotes'', you should use double quotes "" , like this:

--hostnames="docker-registry.default.svc.cluster.local,$TEST"

Not the answer you're looking for? Browse other questions tagged or ask your own question.