5
votes

I'm just getting started with Vagrant and Puppet. I'm able to get a Virtualbox running but now I want to automate the software that gets installed on it.

In my Vagrantfile I have:

Vagrant::Config.run do |config|

    config.vm.box = "precise64"

    config.vm.forward_port 80, 9090
    config.vm.forward_port 27017, 27017

    config.vm.provision :puppet do |puppet|
     puppet.manifests_path = "manifests"
     puppet.manifest_file  = "default.pp"
    end

end

in manifests/default.pp I have:

Exec { path => [ "/bin/", "/sbin/" , "/usr/bin/", "/usr/sbin/" ] }

class php5{
    package { "php5":
        ensure => present,
    }
}


include php5

However, when I run vagrant up I get the following error (snippet).

[default] Running Puppet with /tmp/vagrant-puppet/manifests/default.pp...
stdin: is not a tty
No LSB modules are available.
warning: Could not retrieve fact fqdn
err: /Stage[main]/Php5/Package[php5]/ensure: change from purged to present failed: Execution of '/usr/bin/apt-get -q -y -o DPkg::Options::=--force-confold install php5' returned 100: Reading package lists...

I'm not really sure where the error lies, so here is some further information which might be useful

Ruby version

$ ruby -v 
ruby 1.8.7 (2011-12-28 patchlevel 357) [universal-darwin11.0]

gem sources

$ gem sources 
*** CURRENT SOURCES ***

http://rubygems.org/

Update 1: Following this post I installed facter and puppet now runs ok but the main problem is still happening.

Update 2: Correct answer marked, but I wanted to share my entire manifest file http://pastebin.com/LGNhVPV7

1
What happens if you try running the apt-get command from your vagrant host manually ? Maybe you need to configure apt.conf to allow you through your proxy ? (askubuntu.com/questions/38823/…) - pwan
@pwan running for example sudo apt-get update then sudo apt-get install php5-cli works fine from the virtual machine. But really I want to have all that happen on vagrant up - ed209
After the update are you still getting the warning? What's the output of facter fqdn. Seems like this might be your problem? stackoverflow.com/questions/7780322/… - seth

1 Answers

2
votes

The 'apt-get install' error is probably happening because the VM hasn't finished an 'apt-get update' before Puppet tries to do the 'apt-get install'. Puppet won't handle the 'apt-get update' on its own when you request that a package be installed, but you can spell out that it should happen in your manifest easily enough.

Try adding the apt class Mr Leach mentions in his http://johnleach.co.uk/words/771/puppet-dependencies-and-run-stages post. This should ensure that 'apt-get update' is run before any packages are installed.