Похожие чаты

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 ответов

14 просмотров

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!

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

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

30500 за редактор? )
Владимир
47
any reference of this implementation?
BitBuddha
29
Ⓐrtto, [4/23/24 7:02 PM] Please explain more fully how it is not working exactly, and what are the steps you are taking, and what error messages come or what happens. Ⓐrtto, ...
Ezza Kezza
2
sounds like people have lost their kaspa on tradeogre... does this mean tradeogre not trustworthy?
Ezza Kezza
15
Страшнейшая правда про списки ЦБ. С первых дней жизни P2P сферы, молодые человеки, начитавшись законодательной базы и "внутренних" документов, решили, что им противостоит сер...
Foxcool
3
Недавно Google Project Zero нашёл багу в SQLite с помощью LLM, о чём достаточно было шумно в определённых интернетах, которые сопровождались рассказами, что скоро всех "ибешни...
Alex Sherbakov
5
So much speculation in the last week. So much volatility in price. This is because Hedera has a GC that isn't using the network it's governing. Why aren't people asking why a...
Summit Seeker R
8
Anyone else having this error when trying to make transactions?
Datzel
11
Question: How viable is it to use Anvil as the backend infrastructure for managing a TradFi portfolio, while integrating Flexa for instant liquidity and payment solutions? Cou...
Kevin
2
вы делали что-то подобное и как? может есть либы готовые? увидел картинку нокода, где всё линиями соединено и стало интересно попробовать то же в ddl на lua сделать. решил с ч...
Victor
8
Карта сайта