Reputation: 6681
Chef provisioning offers a library for creating machines and infrastructures idempotently in Chef.
There is also a driver for using Vagrant.
With a few changes I managed to get a simple example working on my local laptop. I put code below in Ruby file vagrant_linux.rb
and then run it with chef-client -z vagrant_linux.rb
.
require 'chef/provisioning/vagrant_driver'
with_driver 'vagrant'
with_machine_options :vagrant_options => {
'vm.box' => 'ubuntu/trusty64'#,
},:vagrant_config => <<EOF
config.vm.provider 'virtualbox' do |v|
v.memory = 4096
v.cpus = 2
end
EOF
machine 'mario' do
converge true
end
When I create a Chef recipe based on this example, upload that to my Chef server and then apply to a node, this consistently fails with message
[2016-06-20T20:16:36+02:00] ERROR: machine[mario] (ok-test::default line 99) had an error: RuntimeError: vagrant up mario --provider virtualbox failed!
STDOUT:
STDERR:Vagrant failed to initialize at a very early stage:
Vagrant is attempting to interface with the UI in a way that requires
a TTY. Most actions in Vagrant that require a TTY have configuration
switches to disable this requirement. Please do that or run Vagrant
with TTY.
Google search shows that this is common issue for which there does not seem to be a good/working fix or workaround.
This makes me wonder if I am trying to do something I shouldn't because it is not supported and there is a better way to do it.
Vagrant is of course a tool that runs on local laptop. It is not typically used on a server.
What should I use to do provisioning of simple VirtualBox machines on a server?
Upvotes: 0
Views: 267
Reputation: 54181
Chef Provisioning is no longer a project you should probably start new work based on, see https://coderanger.net/provisioning/ for details. As mentioned in a comment, Test Kitchen is the right tool to use for setting up development and testing VMs either locally via Vagrant or using one of the various cloud plugins.
Upvotes: 1