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

Passing Environment Variables through to Puppet Apply #2270

Closed
simondean opened this issue Sep 25, 2013 · 8 comments · Fixed by #7931
Closed

Passing Environment Variables through to Puppet Apply #2270

simondean opened this issue Sep 25, 2013 · 8 comments · Fixed by #7931

Comments

@simondean
Copy link

Hi. There seems to be no way to pass environment variables to the Puppet Apply process when using Vagrant. Being able to do this would really help when behind a proxy server. It's important to note that the proxy is not needed to contact a Puppet master etc.; the proxy is needed for the VM to install things (and not just things from a Linux package repo). At the minute I have to either litter my puppet modules and manifests with proxy settings or change the global config of the VM to make every process in the VM use the proxy server.

It would be really helpful if Vagrant supported something like this (the environment property is the new bit):

  config.vm.provision :puppet do |puppet|
    puppet.manifests_path = "puppet/manifests"
    puppet.manifest_file  = "init.pp"
    puppet.environment = {
      "http_proxy": "http://proxy:8080",
      "https_proxy": "http://proxy:8080"
    }
  end

The great thing about this approach is that once "vagrant up" is finished, it doesn't leave any proxy config in the VM.

@mitchellh
Copy link
Contributor

One workaround you can do for now is to use a shell provisioner prior to set the env vars (globally). In the future I think the proper workaround will be to be able to specify a custom execution command for Puppet.

@simondean
Copy link
Author

Thanks. I'm using this rather horrid work around at the moment:

  config.vm.provision :puppet do |puppet|
    puppet.manifests_path = "puppet/manifests"
    puppet.manifest_file  = "init.pp"
    puppet.facter = {
      # Specifying the proxy environment variables this way is a work around.  
      # The work around can be removed when this issue is fixed https://github.com/mitchellh/vagrant/issues/2270
      "anything=anything http_proxy=http://proxy:8080 https_proxy=http://proxy:8080 anything" => "anything"
    }
  end

@mitchellh mitchellh modified the milestones: 1.5.0, 1.6.0 Mar 13, 2014
@ebr
Copy link

ebr commented Apr 25, 2014

I second the need for a fix. In my case, setting an environment variable globally doesn't work, because the variable in question is LANG=en_US.UTF-8, and only needs to be set on the very first provision (Puppet adopts it on subsequent vagrant provision runs, but not on the first).

In the meantime, the hackish workaround by @simondean works. Thanks for that. Saved me a lot of brain racking.

@hugocorbucci
Copy link

Had this issue as well recently. More and more with build/CI/CD tools based on environment variables, being able to replicate the situation with Vagrant gets more necessary.

@Tblue
Copy link

Tblue commented Nov 24, 2014

We really need this as well (currently also using @simondean's hacky workaround). Looking at the code, this should not be hard to implement -- basically, a duplicate of the code which converts the facter hash to FACTER_<key> environment variables. Maybe I will come up with a patch.

@phanson
Copy link

phanson commented Feb 7, 2015

Thanks @simondean for the workaround! This is a big issue for anyone behind a proxy.

One more data point: I previously tried passing the proxy config using puppet.options and had no luck.

@mbrodala
Copy link
Contributor

@mitchellh Can you have a look at this again? Especially considering #6688.

@ghost
Copy link

ghost commented Apr 3, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Apr 3, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.