Installs Vagrant and manages Vagrant plugins via custom resources.
This cookbook is not intended to install Vagrant 1.0 RubyGem versions. Use the vagrant_gem resource if you need to remove an old gem install.
This cookbook is not supported for installing versions of Vagrant older than 1.6.
This cookbook is maintained by the Sous Chefs. The Sous Chefs are a community of Chef cookbook maintainers working together to maintain important cookbooks. If you’d like to know more please visit sous-chefs.org or come chat with us on the Chef Community Slack in #sous-chefs.
This cookbook should not be used on platforms that Vagrant itself does not support.
Vagrant publishes packages for:
- Mac OS X
- Windows
- Linux (deb-package based platforms, e.g., Debian and Ubuntu)
- Linux (rpm-package based platforms, e.g., RHEL-compatible distributions, Fedora, and Amazon Linux)
Other platforms are not supported. This cookbook attempts to exit gracefully in places where unsupported platforms may cause an issue, but it is strongly recommended that this cookbook not be used on an unsupported platform's node run list or used as a dependency for cookbooks used on unsupported platforms.
- AlmaLinux 8+
- Amazon Linux 2023+
- CentOS Stream 9+
- Debian 12+
- Fedora latest
- Oracle Linux 8+
- Rocky Linux 8+
- Ubuntu 22.04+
- OS X 10.9
May work on other Debian/RHEL family distributions with or without modification.
This cookbook has test-kitchen support for Windows and Mac OS X, but requires custom Vagrant boxes.
Because Vagrant is installed as a native system package, Chef must run as a privileged user (e.g., root or Administrator).
Use of the AppImage version of Vagrant assumes you have set up support for FUSE filesystems. See FUSE for general explanation of FUSE. The vagrant installation resource does not install or set up FUSE.
This cookbook now exposes custom resources only. Legacy root recipes and attributes were removed. See migration.md for examples that map the old recipe and attribute API to resource properties.
This cookbook includes the:
vagrantresource, for installing vagrant.vagrant_pluginresource, for managing vagrant plugins.vagrant_gemresource, for removing legacy RubyGem installs.
See the resource documentation:
:install: installs vagrant. Platform specific details are here.
:checksum: Vagrant package checksum (SHA256):url: Download Vagrant package from this URL:version: Vagrant package version:appimage: Install the appimage version of vagrant flag:appimage_file: Install the appimage vagrant file at this location, defaults to /usr/local/bin/vagrant:plugins: Install Vagrant plugins after Vagrant is installed:plugin_user: User used for plugins installed through thepluginsproperty:plugin_password: Password used for plugins installed through thepluginsproperty
vagrant 'Vagrant'
vagrant 'Vagrant from url' do
checksum 'abc123'
url 'https://releases.hashicorp.com/vagrant/2.4.9/vagrant_2.4.9-1_amd64.deb'
version '2.4.9'
end
vagrant 'Vagrant with plugins' do
plugin_user 'root'
plugins [
'vagrant-ohai',
{ name: 'vagrant-berkshelf', version: '1.2.0' },
]
end:install: installs the specified plugin. Default.:uninstall: uninstalls the specified plugin:remove: uninstalls the specified plugin
:plugin_name: name attribute, the name of the plugin, e.g. "vagrant-omnibus".:version: version of the plugin to installed, must be specified as a string, e.g., "1.0.2":env: plugin environment variable settings, some plugins require specific settings:user: a user to run plugin installation as. Usually this is for single user systems (like workstations).:sources: alternate locations to search for plugins. This would commonly be used if you are hosting your vagrant plugins in a custom gem repo
vagrant_plugin 'vagrant-omnibus'
vagrant_plugin 'vagrant-berkshelf' do
version '1.2.0'
sources ['http://src1.example.com', 'http://src2.example.com']
end# Install the plugins as the `donuts` user, into ~/donuts/.vagrant.d
# .vagrant.d will be allocated if it does not exist.
# If a specific user, group or mode is desired use a directory resource to
# create the .vagrant.d directory.
vagrant_plugin 'vagrant-aws' do
user 'donuts'
endrequires a username and password.
vagrant_plugin 'vagrant-winrm' do
user 'vagrant'
password 'vagrant'
end
# Install a plugin in the /root directory
vagrant_plugin 'vagrant-aws' do
vagrant_home '/root/.vagrant.d'
endMatchers are automatically generated by current versions of ChefSpec.
Example:
RSpec.describe 'example::default' do
let(:chef_run) { ChefSpec::SoloRunner.converge(described_recipe) }
it 'installs the vagrant-omnibus plugin' do
expect(chef_run).to install_vagrant_plugin('vagrant-omnibus').with(
user: 'my_user'
)
end
end:remove: removes the named gem withgem_packageandchef_gem. Default.
:gem_name: name attribute, the RubyGem to remove.
vagrant_gem 'vagrant'- vagrant-libvirt. Installing this plugin has required setting environment variables on ubuntu system. Adding env CONFIGURE_ARGS: 'with-libvirt-include=/usr/include/libvirt with-libvirt-lib=/usr/lib' to the vagrant_plugin resource properties has worked.
Use the resources directly from a wrapper cookbook. To install Vagrant and plugins:
vagrant 'Vagrant' do
plugins [
'vagrant-omnibus',
{ name: 'vagrant-berkshelf', version: '1.2.0' },
]
endThis project exists thanks to all the people who contribute.
Thank you to all our backers!
Support this project by becoming a sponsor. Your logo will show up here with a link to your website.