3

I'm new to this and I think I'm just missing one thing to grasp what the problem really is.

I understand that I can create my own puppet modules that will install certain packpages to a vagrant instance. There are also some ready-made ones, like this apache. I've run vagrant ssh and installed it using puppet module install puppetlabs/apache. It now resides under /etc/puppet/modules/apache. But, the apache is not installed.

So, how do I install apache?

In my Vagrantfile I have

config.vm.provision :puppet do |puppet|
  puppet.manifests_path = "puppet/manifests"
  puppet.module_path = "puppet/modules"
  puppet.manifest_file  = "init.pp"
  puppet.options="--verbose --debug"
end

Plus, in the main vagrant directory, under puppet/modules/apache/manifests/init.pp:

class apache2::install {
  package { 'apache2':
    ensure => present,
  }
}

and yet, after vagrant provision or vagrant reload no apache is being installed, or what I guess, the installation process doesn't even start. Log from after the vagrant provision, whose messages look totally cryptic to me.

[default] Running provisioner: puppet...
Running Puppet with init.pp...
debug: Creating default schedules
debug: Puppet::Type::User::ProviderDirectoryservice: file /usr/bin/dscl does not exist
debug: Puppet::Type::User::ProviderUser_role_add: file rolemod does not exist
debug: Puppet::Type::User::ProviderLdap: true value when expecting false
debug: Puppet::Type::User::ProviderPw: file pw does not exist
debug: Failed to load library 'ldap' for feature 'ldap'
debug: /File[/var/lib/puppet/ssl/certificate_requests]: Autorequiring File[/var/lib/puppet/ssl]
debug: /File[/var/lib/puppet/state/graphs]: Autorequiring File[/var/lib/puppet/state]
debug: /File[/var/lib/puppet/ssl/public_keys]: Autorequiring File[/var/lib/puppet/ssl]
debug: /File[/var/lib/puppet/facts]: Autorequiring File[/var/lib/puppet]
debug: /File[/var/lib/puppet/ssl/private_keys]: Autorequiring File[/var/lib/puppet/ssl]
debug: /File[/var/lib/puppet/client_yaml]: Autorequiring File[/var/lib/puppet]
debug: /File[/var/lib/puppet/state/last_run_report.yaml]: Autorequiring File[/var/lib/puppet/state]
debug: /File[/var/lib/puppet/client_data]: Autorequiring File[/var/lib/puppet]
debug: /File[/var/lib/puppet/state/state.yaml]: Autorequiring File[/var/lib/puppet/state]
debug: /File[/var/lib/puppet/ssl/certs]: Autorequiring File[/var/lib/puppet/ssl]
debug: /File[/var/lib/puppet/lib]: Autorequiring File[/var/lib/puppet]
debug: /File[/var/lib/puppet/ssl/private]: Autorequiring File[/var/lib/puppet/ssl]
debug: /File[/var/lib/puppet/state/last_run_summary.yaml]: Autorequiring File[/var/lib/puppet/state]
debug: /File[/var/lib/puppet/state]: Autorequiring File[/var/lib/puppet]
debug: /File[/var/lib/puppet/clientbucket]: Autorequiring File[/var/lib/puppet]
debug: /File[/var/lib/puppet/ssl]: Autorequiring File[/var/lib/puppet]
debug: Finishing transaction 70208664910260
debug: Loaded state in 0.00 seconds
debug: Loaded state in 0.00 seconds
info: Applying configuration version '1389652562'
debug: /Schedule[daily]: Skipping device resources because running on a host
debug: /Schedule[monthly]: Skipping device resources because running on a host
debug: /Schedule[hourly]: Skipping device resources because running on a host
debug: /Schedule[never]: Skipping device resources because running on a host
debug: /Schedule[weekly]: Skipping device resources because running on a host
debug: /Schedule[puppet]: Skipping device resources because running on a host
debug: Finishing transaction 70208665347780
debug: Storing state
debug: Stored state in 0.00 seconds
notice: Finished catalog run in 0.05 seconds
debug: Finishing transaction 70208665012580
debug: Received report to process from localhost.localdomain
debug: Processing report from localhost.localdomain with processor Puppet::Reports::Store 
Maciej Gurban
  • 5,615
  • 4
  • 40
  • 55

3 Answers3

4

You've told Vagrant that it should look for manifests in puppet/manifests (relative to your Vagrant directory), and that it should configure the machine based on whatever is in init.pp, which it will look for in puppet/manifests (as per your instructions). That is, Vagrant will install whatever is in puppet/manifests/init.pp. It will not look at puppet/modules/apache/manifests/init.pp (at least, not at first).

Put something like the following in puppet/manifests/init.pp and it should install properly.

class {'apache':}

In addition to the apache module, make sure you have all dependancies (the stdlib and concat modules from Puppetlabs in this case) installed in your puppet/modules directory, too.

Shaun O'Keefe
  • 1,308
  • 1
  • 11
  • 12
  • On the module page at https://forge.puppetlabs.com/puppetlabs/apache#setup the beginning tells me to `class { 'apache': }`. But where the heck to I put that? I doesn't work in my main init.pp – Maciej Gurban Jan 14 '14 at 13:25
  • 1
    `class {'apache':}` in your `/puppet/manifests/init.pp` file should work. Make sure you have a copy of stdlib and concat in your `/puppet/modules/` directory (I just clone copies of these from their respective Github repos). – Shaun O'Keefe Jan 14 '14 at 23:07
  • Thanks, that helped. I'm actually installing them now from puppetforge. – Maciej Gurban Jan 15 '14 at 18:05
  • No problem. Updated the answer to use the base apache class as per the apache module readme and also included a note about the dependancies. Happy to accept this? – Shaun O'Keefe Jan 15 '14 at 22:36
3

I went with a solution I don't fully like, as it overwrites any settings not provisioned by puppet. But hey, it gets the job done smoothly.

My Vagrantfile:

VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|

  config.vm.box = "base"
  #config.vm.box_url = "http://domain.com/path/to/above.box"

  config.vm.network :forwarded_port, guest: 80, host: 5656, auto_correct: true

  config.vm.provision :shell do |shell|
    shell.inline = "mkdir -p /etc/puppet/modules;
                    puppet module install puppetlabs-concat --force --modulepath '/vagrant/puppet/modules'
                    puppet module install puppetlabs-stdlib --force --modulepath '/vagrant/puppet/modules'
                    puppet module install puppetlabs-apache --force --modulepath '/vagrant/puppet/modules'"
  end


  config.vm.provision :puppet do |puppet|
    puppet.manifests_path = "puppet/manifests"
    puppet.module_path = "puppet/modules"
    puppet.manifest_file  = "init.pp"
    puppet.options="--verbose --debug"
  end

end

Note: the script may actually also work without --force --modulepath '/vagrant/puppet/modules

My puppet/manifests/init.pp

node default {
    class { 'apache':  }
}

Thanks to https://stackoverflow.com/a/21105703/2066118 for pointing me into the right direction.

Community
  • 1
  • 1
Maciej Gurban
  • 5,615
  • 4
  • 40
  • 55
  • There's no need to run the shell commands inside the VM. `/vagrant/puppet/modules/` on the VM is just a copy of the directory on the host machine host pointed to by the `puppet.module_path` setting in your Vagrant file. Install (I usually just clone copies of them from their Github repos) the modules in `/puppet/modules/` and they will be made available to your VM. Afaik this is standard operating procedure. – Shaun O'Keefe Jan 14 '14 at 23:14
  • Also, declaring your class inside the `node default` node won't not work, but there's no need for it :) – Shaun O'Keefe Jan 14 '14 at 23:15
  • Your suggestions have been very helpful so far. Thanks for that. I'm still having a small problem grasping the proper organisation (and usage of self-written modules) of the project when using librarian-puppet. Would you have a few minutes to spare some time to answer a couple of theoretical questions? – Maciej Gurban Jan 20 '14 at 10:53
  • Sure. Just submit them as questions and tag them under puppet and I'll answer them when they turn up. – Shaun O'Keefe Jan 21 '14 at 04:30
1

I'm not sure about Vagrant, but in puppet you need to mention what needed to install in a node on '/etc/puppet/manifests/site.pp' file.

So it will be like this.

node 'hosts.fqdn' {

include apache2 

}

For more information : http://docs.puppetlabs.com/puppet/2.7/reference/lang_node_definitions.html

Community
  • 1
  • 1
Thilina
  • 695
  • 2
  • 7
  • 20