https://pulumi.com logo
#getting-started
Title
# getting-started
f

famous-eye-35723

07/13/2022, 7:26 PM
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

echoing-dinner-19531

07/13/2022, 7:53 PM
That all looks correct. Does the environment work if you use the local command?
command.local.Command
?
d

dazzling-oxygen-84405

07/13/2022, 8:01 PM
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

echoing-dinner-19531

07/13/2022, 8:03 PM
They would be passed as SSH environment variables yes
d

dazzling-oxygen-84405

07/13/2022, 8:06 PM
Ubuntu by default accepts only:
AcceptEnv LANG LC_*
. Anything else would have to be configured in
/etc/sshd_config
.
f

famous-eye-35723

07/13/2022, 8:51 PM
Cool, thanks y’all!
e

echoing-dinner-19531

07/14/2022, 8:19 AM
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
5 Views