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

Chef solo provisioner shouldn't need to download chef client every vagrant up #5903

Closed
jess-sol opened this issue Jul 9, 2015 · 4 comments
Closed

Comments

@jess-sol
Copy link

jess-sol commented Jul 9, 2015

With spotty internet having to download the Chef client every time I need to rebuild a vagrant box becomes a real nuisance. I'm able to cache packages via the fantastic Cachier plugin, and it'd be nice if Vagrant cached versions of the Chef client and just copied them to the box before installation.

In fact Vagrant really shouldn't rely on an internet connection at all, if I'm rebuilding a box it should be possible without an internet connection. Vagrant is designed to make offline development easy, but it seems like the program has been consistently more reliant on being connected with unlimited bandwidth and high throughput.

I really hope this trend reverses, an internet connection should be an enhancement, only required when cached information isn't available. It certainly shouldn't keep me from getting any work done, otherwise what's the point of having my server environment local?

@sethvargo
Copy link
Contributor

Hi @ben-rosio

The Chef provisioner should only be installing Chef if Chef is not already installed on the system. Can you please share your Vagrantfile and the output of the command in debug mode?

Unfortunately Vagrant cannot install Chef without an Internet connection - that's just a limitation of Chef itself (or any package that needs to be installed). You can disable the automatic installation of Chef via:

chef.install = false

in your Chef solo or Chef client configuration block in the Vagrantfile (see docs for more information on that). If you have Chef pre-installed on the boxes, you can still use the provisioner, but disable the automatic installation. You can also pin to a specific version of Chef to install.

@sethvargo
Copy link
Contributor

Hi @ben-rosio

Upon further discussion with my team, this is not a bug in Vagrant. As you mentioned, you can use the Vagrant cachier plugin to cache things. We do not have plans to add support for caching into Vagrant core at this time. You might also be interested in this issue: #4989. Thanks! 😄

@jess-sol
Copy link
Author

The issue is that Vagrant uses curl to download and install chef client, so there is no way to cache it without the workaround you mentioned (not allowing Vagrant to install chef client, and instead installing it all manually).

The output with debug logging is too long, so here is my example Vagrantfile:

Vagrant.configure(2) do |config|
  config.vm.box = "chef/centos-6.5"

  config.vm.provision 'chef_solo' do |chef|
    chef.cookbooks_path = 'chef/kitchen' # Make sure exists
  end
end

And here are the important bits:

 INFO ssh: Execute: curl -sL https://www.chef.io/chef/install.sh | sudo bash (sudo=true)
DEBUG ssh: stdout: Downloading Chef  for el...
DEBUG ssh: stdout: downloading https://www.chef.io/chef/metadata?v=&prerelease=false&nightlies=false&p=el&pv=6&m=x86_64
DEBUG ssh: stdout:   to file /tmp/install.sh.2245/metadata.txt
DEBUG ssh: stdout: trying wget...
DEBUG ssh: stdout: trying curl...
DEBUG ssh: stdout: url  https://opscode-omnibus-packages.s3.amazonaws.com/el/6/x86_64/chef-12.4.1-1.el6.x86_64.rpm
md5 f09a9ae589bb9040232c600b008ef812
sha256  95150a4b3c3b2313bd206876e09e2fcf742f2fa4611951d52c79225becb32928
DEBUG ssh: stdout: downloaded metadata file looks valid...
DEBUG ssh: stdout: downloading https://opscode-omnibus-packages.s3.amazonaws.com/el/6/x86_64/chef-12.4.1-1.el6.x86_64.rpm
  to file /tmp/install.sh.2245/chef-12.4.1-1.el6.x86_64.rpm
trying wget...

DEBUG ssh: Sending SSH keep-alive...
DEBUG ssh: Sending SSH keep-alive...
DEBUG ssh: Sending SSH keep-alive...
DEBUG ssh: Sending SSH keep-alive...
DEBUG ssh: Sending SSH keep-alive...
DEBUG ssh: stdout: Comparing checksum with sha256sum...

Every time I run vagrant up it makes curl/wget calls that I can't cache on my host machine (Cachier doesn't help because first you're redownloading the install.sh chef script every time, and the script installs the rpm directly, not through yum).
Vagrant decided it was within its feature scope to automatically install chef onto machines, and the rest of the vagrant up command can be run offline, so I think the installation of the Chef client should be possible without an internet connection too (assuming the files have been cached at some point).

I was sold on Vagrant because of how easy it was to rebuild a machine, but now I dread rebuilding my vm because I'm not sure if it'll be able to come back up with a spotty internet connection.

@jess-sol
Copy link
Author

That said Chef's Omnibus install.sh script also doesn't work without an internet connection (even with caching options enabled). I've opened and issue with them to see if this will be resolved.

If they decide to resolve that issue I'll post back here with an update, and hopefully Vagrant will then allow the Chef client to be installed without an internet connection.

Referenced issue: chef/omnitruck#112

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

No branches or pull requests

2 participants