iterative / terraform-provider-iterative

☁️ Terraform plugin for machine learning workloads: spot instance recovery & auto-termination | AWS, GCP, Azure, Kubernetes
https://registry.terraform.io/providers/iterative/iterative/latest/docs
Apache License 2.0
288 stars 27 forks source link

source profile #576

Closed casperdcl closed 2 years ago

casperdcl commented 2 years ago

script = "#!/bin/bash ..." doesn't source from /etc/profile. This leads to confusion.

prints nothing:

script = "#!/bin/bash
echo $LD_LIBRARY_PATH"

prints something:

ssh $instance_ip && echo $LD_LIBRARY_PATH

0x2b3bfa0 commented 2 years ago

What about #!/bin/bash -l in the shebang? 😉

casperdcl commented 2 years ago

Exactly what I was thinking, though haven't tested and not sure about side-effects.

0x2b3bfa0 commented 2 years ago

I have tested it, and it works.

  1. Create a.sh with #!/bin/sh -l and env and give it execution permissions
  2. Create b.sh with #!/bin/sh and env and give it execution permissions
  3. Run env -i ./a.sh and env -i ./b.sh to verify that profile is being sourced on the former
0x2b3bfa0 commented 2 years ago

not sure about side-effects

What could possibly go wrong? 😄

casperdcl commented 2 years ago

There are a few #!/bin/sh littered around this repo which could potentially be changed to #!/bin/sh -l? Might be a good idea to fully support custom images.

0x2b3bfa0 commented 2 years ago

Have you found any other #!/bin/.*sh that could benefit from being a login shell?

casperdcl commented 2 years ago

things that affect runner?

0x2b3bfa0 commented 2 years ago

As long as runners don't support custom images, there is no reason to do the same. 🤔