Closed thomashashi closed 1 year ago
Wondering if, instead of relying on variables which may exist in the user's bashrc, we parse /root/terraform-cloud/terraform.tfvars
directly in any scripts which need to access these variables?
Wondering if, instead of relying on variables which may exist in the user's bashrc, we parse
/root/terraform-cloud/terraform.tfvars
directly in any scripts which need to access these variables?
We could, however we use $ORG
and $WORKSPACE
in many places throughout this repo, and as long as we call bash as bash -l
bash will absorb everything in .bashrc
then they're available as boring, common environment variables, i.e. parse the terraform.tfvars
once and be done with it. That simplicity has some benefit.
In challenge 2 we use the check script to do a bunch of non-check work, setting some agent variables, copying around and changing some Terraform code, adding things to root's .bashrc, etc.
Check scripts do not always run. For example, a user who can skip tracks can skip this challenge and its check script will not run. Or a user who uses the
/tmp/skip-check
trick will cause the check script to exit before the necessary work is done.Cleanup scripts, however, always run, and since we require those changes to happen, move them to the cleanup script.
In addition, we do things like
grep $ORG /root/.bashrc || echo "export ORG=\"$ORG\"" >> /root/.bashrc
which is fragile because it is an unanchored grep, so if the user's $ORG or $WORKSPACE happens to match anything in the existing .bashrc we won't add the export line. In addition, we haven't actually added this line anywhere else in previous challenges, so just unconditionally set it in the cleanup script.