Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement: add LABPASSPHRASE to .zshrc #827

Open
mjbear opened this issue Mar 26, 2024 · 7 comments
Open

Enhancement: add LABPASSPHRASE to .zshrc #827

mjbear opened this issue Mar 26, 2024 · 7 comments

Comments

@mjbear
Copy link

mjbear commented Mar 26, 2024

Is your feature request related to a problem? Please describe.
Feature request (enhancement).

Describe the solution you'd like
Add LABPASSPHRASE to the .zshrc after line 41 where XTERM is set to help avoid the stumbling block of an unset environment variable upon opening multiple terminals.

Something along the lines of the below snippet should do it.

&& echo "export LABPASSPHRASE=`awk '/password:/{print $2}' /home/coder/.config/code-server/config.yaml`" >> $HOME/.zshrc

Describe alternatives you've considered
We could keep things as they are (manual environment variable instantiation) or automate it a bit more with this enhancement.

Additional context
Before I realized (or looked to find that) the ATD lab environment uses Docker containers, I put in a feature enhancement issue on the avd-workshops repo to add the LABPASSPHRASE environment variable to .zshrc. 🤦‍♂️ 🤷‍♂️

💡 I plan to submit a PR to cover this suggestion once Arista Engineering weighs in. ❤️

@mjbear
Copy link
Author

mjbear commented Mar 26, 2024

It dawned on me that I don't (yet) know how soon /home/coder/.config/code-server/config.yaml exists.
Crossing my fingers 🤞 that the file exists early on in the process and this will work. 😁

It's getting late and I need to dig into this further another day.

@mjbear
Copy link
Author

mjbear commented Mar 26, 2024

So far I haven't yet found the point at which /home/coder/ ends up receiving its files.

There is the possibility the coder content (including config.yaml) is dropped in via rsync at a later time. Whether or not this is the case, it shouldn't matter as the export command (and nested awk command) would be run when users/students open a Terminal within the coder interface. (By that point all the files, including config.yaml would be present in the ATD instance.)

Feedback welcome.

@JulioPDX
Copy link
Contributor

@networkRob thought here is to always have the environment variable set and available to the ATD user. These can be leveraged in any workshops or guides without requiring the user to manually enter the information

@networkRob
Copy link
Contributor

This request makes sense, I'm just thinking about how to implement this. Within the coder container, we define our volume mounts here:

When a lab does startup, we have this script and couple of lines that goes through and updates the lab password with the unique lab password.

find /opt/atd/nested-labvm/atd-docker/* -type f -print0 | xargs -0 sed -i "s/{ARISTA_REPLACE}/$APWD/g"

Currently we don't mount the ~/.zshrc file out of the container, so that is purely within that container.

Maybe one possibility is to mount that as an env var into the container.

@mjbear
Copy link
Author

mjbear commented Mar 28, 2024

Thank you Julio for following up on this!
Hello Rob and thank you for sharing some knowledge! 😁

Ah hah, at line 183 is that config.yaml file being mounted into the container.
I'll defer to your experienced opinion on the solution(s).

@networkRob
Copy link
Contributor

I don't think we need to update the .zshrc file within the container.

I think what could be done, similar to the Nautobot container set, is to create an env file, where we put our placeholder of:

LABPASSPHRASE={REPLACE_PWD}

We have scripts that will update that password value when the topology boots up. Then that could be mounted via the docker-compose.yml file as an env_file

@mjbear
Copy link
Author

mjbear commented Mar 31, 2024

Nice!

(I learn best by seeing and doing so I tracked stuff down in the repo. 😀)

https://github.com/aristanetworks/atd-public/blob/0d056f79dce22cc9d481109bd3a545b9b9641801/nested-labvm/atd-docker/nautobot/nbot-local.env

- ./nautobot/nbot-local.env

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants