Question

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 
Was it helpful?

Solution

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.

OTHER TIPS

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.

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top