Похожие чаты

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

7 просмотров

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!

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

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

------------------------------------------------------------------------------ 📢 MAJOR ANNOUNCEMENT: HSUITE ECOSYSTEM UPDATE 📢 @everyone Dear HbarSuite Community, After month...
Big Stones
3
Ready for some fun AND a chance to win TKO Tokens? Join us for exciting minigames in our Telegram group! 🕒 Don’t miss out—games start on today 25 October 2024, at 8 PM! Ge...
Milkyway | Tokocrypto
248
Здравствуйте, вопрос по структурам данных. Были у вас случаи, когда пришлось писать деревья или двунаправленные списки?
/ /
48
Всем привет! Скажите, никто не пытался уменьшить размер процесса ssl, которые ассоциируется с открытым соединением (не помню точное название этого процесса, но там была какая-...
Алексей
20
Let's say the current price of BCH is 400$, and average fee for transaction is .1$ If the price jumps to let's say 4000$, transaction fee should be 1$ ? I don't know exactly ...
Mohamed
22
Мне тут приспичило встроить в программу форматировние текста SQL, расставить переносы строк и отступы так, чтобы лучше читалось. Я что-то свое изобразил, оно после ключевых сл...
Sergey Bodrov
11
а проверьте, собирается ли у кого сейчас транк лазаря через делюкс? у меня вот: fpcupdeluxe: info: Lazarus Native Installer (BuildModuleCustom: UserIDE): LazBuild: building Us...
Iluha Companets
20
why not complete my galxe task??
Crypto 6827
13
добрый день. возможно ли изменить цвет окон лазаруса? Как?
Budemposmotret
35
This is a big issue. Just by being a citizen of a country, you are denied to contribute to Open Source software: https://youtu.be/L5Ec5jrpLVk?si=1iIuHnMPbCB4anV-
Sharuzzaman Ahmat Raslan
72
Карта сайта