Ask Your Question

automate VM building using puppet

asked 2014-05-20 04:24:33 -0600

puppetlearners gravatar image

updated 2014-05-20 10:41:49 -0600

spuder gravatar image


We are trying to automate Building VM using puppet with the help of vagrant. We have a host machine which is a Puppet agent on which VM is to be built. We created the following manifest to automate the process

ensure => directory,
owner => 'root',
group => 'root',

We are able to install VirtualBox and Vagrant successfully, so omitting that part. Then, from the Vagrant directory, we try to generate the vagrantfile using puppet with,

cwd => '/home/VagrantVM/',
command => '/usr/bin/vagrant init',

The above manifest script returns the following error:

Notice: /Stage[main]/Vmclass/Exec[Add_Box]/returns: /opt/vagrant/embedded/gems/gems/vagrant-1.5.4/lib/vagrant/shared_helpers.rb:69:in `expand_path': couldn't find HOME environment -- expanding `~' (ArgumentError)
Notice: /Stage[main]/Vmclass/Exec[Add_Box]/returns:     from /opt/vagrant/embedded/gems/gems/vagrant-1.5.4/lib/vagrant/shared_helpers.rb:69:in `expand_path'
Notice: /Stage[main]/Vmclass/Exec[Add_Box]/returns:     from /opt/vagrant/embedded/gems/gems/vagrant-1.5.4/lib/vagrant/shared_helpers.rb:69:in `user_data_path'
Notice: /Stage[main]/Vmclass/Exec[Add_Box]/returns:     from /opt/vagrant/embedded/gems/gems/vagrant-1.5.4/lib/vagrant/plugin/manager.rb:16:in `user_plugins_file'
Notice: /Stage[main]/Vmclass/Exec[Add_Box]/returns:     from /opt/vagrant/embedded/gems/gems/vagrant-1.5.4/lib/vagrant/plugin/manager.rb:27:in `instance'
Notice: /Stage[main]/Vmclass/Exec[Add_Box]/returns:     from /opt/vagrant/bin/../embedded/gems/gems/vagrant-1.5.4/lib/vagrant/pre-rubygems.rb:21:in `<main>'
Error: /home/VagrantVM/ returned 1 instead of one of [0]
Error: /Stage[main]/Vmclass/Exec[Add_Box]/returns: change from notrun to 0 failed: /home/VagrantVM/ returned 1 instead of one of [0]
Notice: Finished catalog run in 2.43 seconds

Can anyone please help us with this?

edit retag flag offensive close merge delete


Once we setup the VM and bring it up, we are able to make it a puppet agent and run puppet agent on it. But we need to build the VM using Puppet manifest.

puppetlearners gravatar imagepuppetlearners ( 2014-05-20 04:26:37 -0600 )edit

Could you expound why you are using puppet to do the vagrant init? There is no advantage to automating that step that I can see, since you will need to modify the vagrant file anyway.

spuder gravatar imagespuder ( 2014-05-20 10:50:54 -0600 )edit

Spuder, Thank you for introducing 'Packer'. And, I had thought that I could edit the Vagrantfile just like I edit any other text file using sed inside Puppet exec command. But, tried and found my understanding wrong. Could you please explain me why Vagrantfile is not editable with puppet?

puppetlearners gravatar imagepuppetlearners ( 2014-05-23 00:48:38 -0600 )edit

I suppose you 'could' edit the vagrant file with puppet (the augeas provider will likely be better than exec + sed), but I'm struggling to understand the use case where you would need to use puppet to edit the vagrant file.

spuder gravatar imagespuder ( 2014-05-23 11:07:38 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2014-05-20 10:43:48 -0600

spuder gravatar image

updated 2018-05-03 11:51:32 -0600

binford2k gravatar image

You may be interested in packer. It is written by the same guy as Vagrant. It may be helpful in your vm creation workflow and seems better suited to your requirements than configuration management.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2014-05-20 04:24:33 -0600

Seen: 836 times

Last updated: May 03