hi, qstn re `command.remote.Command()` using pytho...
# getting-started
f
hi, qstn re
command.remote.Command()
using python. Ho do I pass environment variables?
for example:
Copy code
install_datadog_agent = command.remote.Command(
    "install_datadog_agent",
    connection=connection,
    environment={
        "DD_AGENT_MAJOR_VERSION": "7",
        "DD_SITE": "<http://datadoghq.com|datadoghq.com>",
    },
    create='echo "the version is ${DD_AGENT_MAJOR_VERSION}"',
    update='echo "the version is: ${DD_AGENT_MAJOR_VERSION}"',
    opts=pulumi.ResourceOptions(depends_on=[server]),
)
outputs
Copy code
Outputs:
  ~ catConfigStdout: 
      - the version is 
      + the version is:
Instead of the DD_AGENT_MAJOR_VERSION
e
That all looks correct. Does the environment work if you use the local command?
command.local.Command
?
d
IIRC the environment variables are passed as SSH environment variables, so your remote host must be configured with
AcceptEnv
for those environment variables. Is that correct?
e
They would be passed as SSH environment variables yes
d
Ubuntu by default accepts only:
AcceptEnv LANG LC_*
. Anything else would have to be configured in
/etc/sshd_config
.
f
Cool, thanks y’all!
e
I'll raise an issue to update our docs with this, it's a useful note to point out.
Turns out we already have an issue for this https://github.com/pulumi/pulumi-command/issues/48