http proxy setting does not present in salt-minion older versions - linux

It seems that http proxy setting in salt-minion does not support in salt-minion older version. Do we have any workaround for this.
When I am running salt command from salt-master, environment variables set in salt minion do not work.I have my http proxy setting in environment variables.but when i am running command from salt-master it does not get variables set in env.
Please let me know if any workaround for this.
Salt minion version: 0.17.5

You should set it permanently, and system wide (all users, all processes) add set variable in /etc/environment:
sudo -H gedit /etc/environment
This file only accepts variable assignments like:
HTTP_PROXY="my value"
Do not use the export keyword here.
You need to logout from current user and login again so environment variables changes take place.

Related

Set Environmnet Path Node.JS

I need to set environment variable for my NodeJS application. I'm using OS W10. I tried wrote in CMD
SET PORT=5000
When i wrote SET in CMD i saw value PORT=5000, but if i closed CMD and opend it one again and wrote again SET PORT i got message: Environment variable port not defined.
And if i try to get data from Node.JS application via command process.env.PORT i got value undefined. Do you have anybody experience with this isssue ?
Thanks.
An environment variable set in a Windows 10 command shell persists only for the lifetime of that command shell and is only seen in that command shell (or in child processes).
So, if you want to set an environment variable in the command shell for your node.js app, you have to set it in that very command shell that you're about to run your node.js app from. This can either be done manually or you can create a batch file that sets the environment variable and then runs your node.js program.
If you want to set a persistent environment variable that is automatically available in all future command shells, then you can go into Windows settings and modify the default environment that is passed to all new command shells. Here are some steps to do that:
Open Windows Settings
Type environment in the search box in the settings window.
If you are logged in as an administrator, you should get a drop-down that contains two options, edit system environment variables or edit environment variables for your account. Pick the desired choice.
A dialog comes up where you can then edit, add or delete persistent environment variables.
SET only sets the environment setting for current session, once closed you loose it. In order to get PORT value using process.env.PORT, you need to set PORT first then run your server within same CMD window.
If you are using BASH (Git Bash) you can do it using one line
PORT=5000 node server.js
I highly recommend using DOTENV package to manage your Environment Variables.

how to read System's https_proxy variable in nodejs

I know how to read environment variable from nodejs process.env.variable. I want to read system variable http_proxy which is set from windows environment variable, but process.env doesn't show http_proxy variable.
setting that environment from mycomputer->rightClick->properties ->Advensed System Seting -> Environment Variable-> new -> key :https_proxy , value : abc:80
console.log(JSON.stringify(process.env)); dosent shows https_proxy
There are several things to consider :
There are system environment variables and user environment variables. What user is the node running as? If you run it in a command window, it is probably running as your user. If you run as a service it will be the Network service user, unless you configured another user.
Is the environment variable visible for the user node is running as?
If you define a new environment variable, it is not automatically accessible everywhere. Node must be restarted to see the new variable. But this may not be sufficient. If you start node from the terminal, consider that in Windows a command window only sees the environment variables that were available when cmd was started, and those that were defined inside that terminal. That means, that you need not only to restart node, but also to close and reopen the command window.

Ubuntu bug? Environment variables only after logging as root

I have an IP address that I use very often, so I tried to set it as an environment variable now that I installed Ubuntu. I edited /etc/environment and added a couple of lines for my api token and my IP address. It looks like this:
PATH="some/paths"
TOKEN="my:token"
ZRUS="my.ip.address"
Now if I want to access the IP I would in theory do ssh $ZRUS. However, it does not work; I do echo $ZRUS and I get a blank line, so I do printenv and I get a list of all the environment variables and I don't see my IP there. I then do su root and I do printenv again and I get the same list plus the IP address and the TOKEN. I then do su myuser and do echo $ZRUS and magically the IP works.
Now I'm wondering why I have to log in as root first to get my global environment variables to work in the local user. It seems as if the scope varied depending on whether root has had a go on the session or not, which seems strange to me.
Do you guys think this is a bug or a functionality? And how would you overcome this?
Environment variables set in an environment file /etc/environment will only take effect if you read them into your active shell source /etc/environment or you logout/login (which will re-read the environment files into your active shell).
The act of su myuser is essentially creating a new shell for your current user which re-reads the environment file

How to set a proxy for the azure-cli command line tool?

I'm behind a corporate firewall and cannot connect using the command line interface, which probably doesn't get proxy information from the system configuration, but I cannot find a way to set the correct options.
The environment variables mentioned in the other answer are part of the solution, so you do need to set them by running these commands before az login. Note that (in my case, at least) both URLs start with http, not https.
In PowerShell:
$env:HTTP_PROXY="http://my-proxy-details"
$env:HTTPS_PROXY="http://my-proxy-details"
In cmd:
SET HTTP_PROXY http://my-proxy-details
SET HTTPS_PROXY http://my-proxy-details
Or, to set them permanently:
[Environment]::SetEnvironmentVariable("HTTP_PROXY", "http://my-proxy-details", "Machine")
[Environment]::SetEnvironmentVariable("HTTPS_PROXY", "http://my-proxy-details", "Machine")
If that fixes it for you, you can stop reading here. If not, and you see a certificate error, the extra step is to find the Azure CLI's private Python installation, and add your root certificate to its cacert.pem files. While Python itself uses the Windows certificate store, some packages (notably certifi) do not.
You will need your proxy's root certificate in PEM format - that is, as base64 text rather than as a binary. It may well have the .cer extension.
Find the site-packages folder inside Azure CLI's program folder. For me, it's C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\Lib\site-packages. Search it for files named cacert.pem. I found three of them. Copy the contents of your certificate and paste it at the bottom of each of these files. Save them and try again.
You could use HTTP_PROXY or HTTPS_PROXY environment variables to set a proxy.
In CMD
You need add "=" when set environment variables:
SET HTTP_PROXY=http://my-proxy-details
SET HTTPS_PROXY=http://my-proxy-details
In PowerShell:
$env:HTTP_PROXY="http://my-proxy-details"
$env:HTTPS_PROXY="http://my-proxy-details"

Jenkins ignores proxy settings while building a job

I set a proxy under Plugins in Jenkins like suggested online.
I also edited the /etc/environment
bash-3.2$ cat /etc/environment
http_proxy=proxy.company.net:8080
https_proxy=proxy.company.net:8080
HTTP_PROXY=proxy.company.net:8080
HTTPS_PROXY=proxy.company.net:8080
HTTPS_PROXY_REQUEST_FULLURI=false
HTTP_PROXY_REQUEST_FULLURI=false
I verfied the variables and they are available on logon.
When I start ant manualy as root via ssh, my "composer.phar" script is able to connect and download files. As soon as Jenkins starts the job (I think its the "jenkins" linux user), he waits until timeout and aborts the build. I used "su jenkins -s /bin/bash" to get a shell as "jenkins" and the env-vars are set correctly...
What can I do? Why does Jenkins ignore these ENV-Vars?
Thanks.
The http_proxy variables (as seen e.g. on the wget man page) require a "http://" prefix to work properly for many programs.
Jenkins on the other hand has a proxy configuration at Manage Jenkins > Plugin Manager > Advanced. This configuration overrides the environment variables.
Check Alex' answer to another question for getting around this behavior for individual nodes/builds.
I did not get it solved. After a restart the server fails all Jenkins Jobs for some minutes... suddenly the connection to the proxy succeeds and everything works well.

Resources