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
Sign up to request clarification or add additional context in comments.

Comments

0

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

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.