Похожие чаты

Anyone knows a good solution for using ansible with env

varialbes of the remote host?
I have some executables that are in a custom directory that's not part of the default path. the .bashrc file adds it to path but since ansible is a non-login and non-interactive session it doesn't load those.
anyway to load the path for teh entire playbook?


my only solutions are:
1. sourcing the .bashrc file befre each command execution
2. using bash -lic
3. using enviroment with every task


none of these seem like a logical solution.

26 ответов

23 просмотра

Why exactly do you want to read the remove env vars?

elo- Автор вопроса

Стикер

elo- Автор вопроса
Raptor Blue Bear
Please elaborate

sure I insalled node.js via nvm, so the executable for node, npm, and npm global packages (in this case I want to use pm2) are in this path /root/.nvm/versions/node/v20.16.0/bin/ which is not part of the path var at /etc/envrioment. this path gets appended via this line in .bashrc (generated automatically by nvm) export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && \\. "$NVM_DIR/nvm.sh" # This loads nvm so now I can't access some executables without sourcing .bashrc or adding the path manually. this would be fine if I had just one play, but ansible stars a new shell in each play and the changes I made in the first play (modifying the path) is not playbook-wide.

elo- Автор вопроса

could you eloborate a little bit?

elo
could you eloborate a little bit?

How are you deploying it currently?

elo- Автор вопроса
Martin Rys
How are you deploying it currently?

I'm not deploying the .bashrc with ansible, the remote server was instantialized before and the .bashrc was created back then. I'm might've misunderstood you

elo
I'm not deploying the .bashrc with ansible, the re...

Okay, so you're ad-hoc deploying the .bashrc. Put it in Ansible instead.

elo
sure I insalled node.js via nvm, so the executab...

err...are you installing node.js as root? WHY!?

Raptor Blue Bear
err...are you installing node.js as root? WHY!?

Also this lol it sounds nightmarish to use npm instead of the package manager.

elo- Автор вопроса
Raptor Blue Bear
err...are you installing node.js as root? WHY!?

ahhh... I actually didn't know it's that bad.

elo- Автор вопроса
Martin Rys
Also this lol it sounds nightmarish to use npm ins...

I actually did this and it worked out but now I just want to know how to solve the issue of having to source some files when I use ansible. but I'm starting to realize that having to do that is the result of past mistakes.

elo
I actually did this and it worked out but now I ju...

If you had your .bashrc in Ansible you'd have no trouble as you'd already know where it's necessary.

elo- Автор вопроса
Martin Rys
Okay, so you're ad-hoc deploying the .bashrc. Put...

I'm sorry I still don't understand how to go around doing this do you mean If I wanted to install node via nvm, I should've done that using ansible too? and populating my .basrc this way?

elo
I'm sorry I still don't understand how to go aroun...

The trick is in having the entire state of the machine in the play and inventory. By ad-hoc modifying some system files, you're then running into a situation like this where you're trying to figure out to load it from the servers instead of already knowing it's there.

elo- Автор вопроса
Martin Rys
The trick is in having the entire state of the mac...

I think I get the gist of it, but how would I manage the version of the machine's node in my inventory/play? considering the path is depentant on the node version and it might get updated regularly and outside of this specific playbook? should I just stick to a versoin or is there a better way?

elo- Автор вопроса
Martin Rys
How else, ad-hoc?

yeah or some other scripts Is is just a bad approach to do stuff like this outside of this play's scope?

elo- Автор вопроса

hey sorry to bother you again, just wanted to know my current solution is a good one or not I now store the node version and the nvm path as inventory varialbes and declare the PATH in my plays if I want to reach them. is it cool or am I doing things in a way that'll cause trouble later? how would I go about editting these variables if I had to change the node version or anyghing? ad-hoc editting the inventory?

elo- Автор вопроса

oh got it, I'm doing this exact thing just wanted to double check if it's ok. and is storing the version and PATH as inventory group varialbes a good solution? or is there a better way to go about it.

elo
oh got it, I'm doing this exact thing just wanted ...

If you install it via Ansible and symlink it you don't need to mess with variables unless you need multiple installs going.

elo- Автор вопроса
Martin Rys
If you install it via Ansible and symlink it you d...

I actually have multiple versions going for three different projects at the moment. but I'll keep it in mind to use symlinks for when I just need the one version. again. thank you!

Похожие вопросы

Обсуждают сегодня

Господа, а что сейчас вообще с рынком труда на делфи происходит? Какова ситуация?
Rꙮman Yankꙮvsky
29
А вообще, что может смущать в самой Julia - бы сказал, что нет единого стандартного подхода по многим моментам, поэтому многое выглядит как "хаки" и произвол. Короче говоря, с...
Viktor G.
2
@Benzenoid can you tell me the easiest, and safest way to bu.y HEX now?
Živa Žena
20
This is a question from my wife who make a fortune with memes 😂😂 About the Migration and Tokens: 1. How will the old tokens be migrated to the new $LGCYX network? What is th...
🍿 °anton°
2
30500 за редактор? )
Владимир
47
а через ESC-код ?
Alexey Kulakov
29
What is the Dex situation? Agora team started with the Pnetwork for their dex which helped them both with integration. It’s completed but as you can see from the Pnetwork ann...
Ben
1
Гайс, вопрос для разносторонее развитых: читаю стрим с юарта, нада выделять с него фреймы с определенной структурой, если ли чо готовое, или долбаться с ринг буффером? нада у...
Vitaly
9
Anyone knows where there are some instructions or discort about failed bridge transactions ?
Jochem
21
@lozuk how do I get my phex copies of my ehex from a atomic wallet, to move to my rabby?
Justfrontin 👀
11
Карта сайта