vagrant-r10k is a Vagrant 1.2+ middleware plugin to allow you to have just a Puppetfile and manifests in your vagrant project, and pull in the required modules via r10k. This plugin only works with the 'puppet' provisioner, not a puppet server. It expects you to have a Puppetfile in the same repository as your Vagrantfile.
$ vagrant plugin install vagrant-r10k
Note that if you include modules from a (the) forge in your Puppetfile, i.e. in the format
mod 'username/modulename'
instead of just git references, you will need the puppet
rubygem installed and available. It
is not included in the Gemfile so that users who only use git references won't have a new/possibly
conflicting Puppet installation.
Add the following to your Vagrantfile, before the puppet section:
config.r10k.puppet_dir = 'dir' # the parent directory that contains your module directory and Puppetfile
config.r10k.puppetfile_path = 'dir/Puppetfile' # the path to your Puppetfile, within the repo
For the following example directory structure:
.
├── README.md
├── Vagrantfile
├── docs
│ └── foo.md
├── puppet
│ ├── Puppetfile
│ ├── manifests
│ │ └── default.pp
│ └── modules
└── someproject
└── foo.something
The configuration for r10k and puppet would look like:
# r10k plugin to deploy puppet modules
config.r10k.puppet_dir = "puppet"
config.r10k.puppetfile_path = "puppet/Puppetfile"
# Provision the machine with the appliction
config.vm.provision "puppet" do |puppet|
puppet.manifests_path = "puppet/manifests"
puppet.manifest_file = "default.pp"
puppet.module_path = "puppet/modules"
end
If you provide an array of directories in puppet.module_path, vagrant-r10k will use the first directory listed for auto configuration. If you want to let r10k use a different directory, see below.
Add the following to your Vagrantfile, before the puppet section:
config.r10k.puppet_dir = 'dir' # the parent directory that contains your module directory and Puppetfile
config.r10k.puppetfile_path = 'dir/Puppetfile' # the path to your Puppetfile, within the repo
config.r10k.module_path = 'dir/moduledir' # the path where r10k should install its modules (should be same / one of those in puppet provisioner, will be checked)
For the following example directory structure:
.
├── README.md
├── Vagrantfile
├── docs
│ └── foo.md
├── puppet
│ ├── Puppetfile
│ ├── manifests
│ │ └── default.pp
│ ├── modules # your own modules
│ └── vendor # modules installed by r10k
└── someproject
└── foo.something
The configuration for r10k and puppet would look like:
# r10k plugin to deploy puppet modules
config.r10k.puppet_dir = "puppet"
config.r10k.puppetfile_path = "puppet/Puppetfile"
config.r10k.module_path = "puppet/vendor"
# Provision the machine with the appliction
config.vm.provision "puppet" do |puppet|
puppet.manifests_path = "puppet/manifests"
puppet.manifest_file = "default.pp"
puppet.module_path = ["puppet/modules", "puppet/vendor"]
end
- Fork it ( https://github.com/jantman/vagrant-r10k/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Add yourself to the "Contributors" list below.
- Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request
- Oliver Bertuch - https://github.com/poikilotherm
Still need to write tests... but they'll be using bundler and rspec.
Note that developming vagrant plugins requires ruby 2.0.0 or newer.
A .ruby-version
is provided to get rvm
to use 2.1.1.
For manual testing:
bundle install --path vendor
VAGRANT_LOG=debug bundle exec vagrant up
To use an existing project's Vagrantfile, you can just specify the directory that the Vagrantfile
is in using the VAGRANT_CWD
environment variable (i.e. prepend VAGRANT_CWD=/path/to/project
to the above command).
Exporting VAGRANT_LOG=debug
will also turn on debug-level logging for r10k.
- Ensure all tests are passing, coverage is acceptable, etc.
- Increment the version number in
lib/vagrant-r10k/version.rb
- Update CHANGES.md
- Push those changes to origin.
bundle exec rake build
bundle exec rake release
Thanks to the following people:
- @adrienthebo for r10k and for vagrant-pe_build as a wonderful example of unit testing Vagrant plugins.
- @garethr for librarian-puppet-vagrant which inspired this plugin
- Alex Kahn of Paperless Post for his How to Write a Vagrant Middleware blog post, documenting the new middleware API