Using cloud-init, I can specify a runcmd
section and do something like this:
runcmd: [
'MYVAR=VALUE some-command --a A --b B'
]
This works, and runs some-command
with MYVAR
set to VALUE
in the environment. It runs under the shell.
However, I actually want to use the parameterized form, like this:
runcmd: [
[
'some-command',
'--a', 'A',
'--b', 'B'
]
]
The reason is that some of these parameter values will be dynamically substituted, and I don't want the shell trying to interpret them.
So, I can run commands with this array of strings just fine, but how I can I specify the environment for them?
You could use the
env
command to accomplish this:See the
env
man page for more information.