1

Previously I had a similar configuration to this working but as soon as I added hiera to my puppet build I started having problems. The error I currently have after running vagrant provision is as follows:

==> default: [vagrant-hostsupdater] Checking for host entries
==> default: [vagrant-hostsupdater]   found entry for: 192.168.33.10 local.mysite
==> default: Configuring cache buckets...
==> default: Running provisioner: puppet...
==> default: Running Puppet with app.pp...
==> default: stdin: is not a tty
==> default: Error: Could not find class nodejs for local.mysite on node local.mysite
==> default: Error: Could not find class nodejs for local.mysite on node local.mysite
The SSH command responded with a non-zero exit status. Vagrant
assumes that this means the command failed. The output for this command
should be in the log above. Please read the output to determine what
went wrong.

My vagrant config is:

# -*- mode: ruby -*-
# vi: set ft=ruby :
require "yaml"

# Load yaml configuration
config_file = "#{File.dirname(__FILE__)}/config/vm_config.yml"
default_config_file = "#{File.dirname(__FILE__)}/config/.vm_config_default.yml"

vm_external_config = YAML.load_file(config_file)

# Configure Vagrant
Vagrant.configure("2") do |config|
  config.vm.box = "ubuntu/trusty64"

  config.vm.box_url = "http://cloud-images.ubuntu.com/vagrant/trusty/current/trusty-server-cloudimg-amd64-vagrant-disk1.box"

  config.vm.network :private_network, ip: vm_external_config["ip"]
  config.vm.hostname = vm_external_config["hostname"]
  config.vm.network "forwarded_port", guest: vm_external_config["port"], host: 2368

  config.vm.synced_folder vm_external_config["ghost_path"], "/var/www/mysite.com", :nfs => true

  config.vm.provider :virtualbox do |vb|
    vb.customize ["modifyvm", :id, "--memory", vm_external_config["memory"]]
  end

  config.cache.scope = :box

  config.librarian_puppet.placeholder_filename = ".gitkeep"

  config.vm.provision :puppet do |puppet|
    puppet.hiera_config_path = "puppet/hiera/hiera.yaml"
    puppet.manifests_path = "puppet/manifests"
    puppet.manifest_file = "app.pp"
    puppet.module_path = "puppet/modules"
    puppet.facter = {
        "environment" => ENV['ENV'] ? ENV['ENV'] : 'local'
    }
  end
end

My source tree looks like so (much of it isn't relevant aside from the folders structure for the custom blog module and hiera config):

├── Vagrantfile
├── config
│   └── vm_config.yml
└── puppet
    ├── Puppetfile
    ├── hiera
    │   ├── common.yaml
    │   ├── hiera.yaml
    │   ├── local
    │   │   └── site.yaml
    │   └── production
    │       └── site.yaml
    ├── manifests
    │   └── app.pp
    └── modules
        ├── blog
        │   └── manifests
        │       └── app.pp
        ├── ghost
        │   └── manifests
        │       └── app.pp
        ├── init.d
        │   └── files
        │       ├── WebhookServer
        │       └── ghost
        ├── mailgunner
        ├── nginx
        │   ├── files
        │   │   ├── local
        │   │   │   ├── mysite.com
        │   │   │   └── mail.mysite.com
        │   │   └── production
        │   │       ├── mysite.com
        │   │       └── mail.mysite.com
        │   └── manifests
        │       └── server.pp
        ├── tools
        │   ├── files
        │   │   ├── local
        │   │   │   ├── backup.sh
        │   │   │   ├── ghostsitemap.sh
        │   │   │   └── init-mysite.sh
        │   │   └── production
        │   │       ├── backup.sh
        │   │       ├── ghostsitemap.sh
        │   │       └── init-mysite.sh
        │   └── manifests
        │       └── install.pp
        └── webhooks
            ├── files
            │   ├── local
            │   │   └── init-webhook.sh
            │   ├── production
            │   │   └── init-webhook.sh
            │   ├── webhook.sh
            │   └── webhooks.rb
            └── manifests
                └── install.pp

hiera.yaml:

---
:backends:
  - yaml

:yaml:
  :datadir: /vagrant/hieradata

:hierarchy:
  - "%{::environment}/site
  - common

common.yaml

--
classes:
  - site

local/site.yaml

--
:site:
  environment: local
  name: local.mysite
  mailserver: local.mail.mysite

blog/manifests/app.pp

class blog::app {

  class { 'nodejs':
    version => 'v0.10.25',
  } ->
  package { 'pm2':
    ensure => present,
    provider => 'npm',
    require => Class['nodejs'],
  }
}

Puppetfile

forge 'https://forgeapi.puppetlabs.com'

mod 'willdurand/nodejs', '1.9.4'

Basically, my problem is that my puppet install is not reinstalling nodejs (I'd removed it previously using an rm -rf puppet/modules/nodejs)

Does anyone have any ideas how or why puppet is now refusing to install the nodejs puppet module in the puppet/modules directory?

FYI - I've installed the willdurand/nodejs module using puppet module install willdurand/nodejs

Any help is much appreciated - I've been banging my head against a brick wall on this for a few days now!

James Murphy
  • 800
  • 1
  • 15
  • 29
  • seems you're using librarian so can you confirm you have the plugin `vagrant-librarian-puppet` installed – Frederic Henri Apr 25 '16 at 06:59
  • Hi Frédéric - are you able to expand on that please? – James Murphy Apr 25 '16 at 07:07
  • I'm very much a first-time user to puppet. I've been working from the Puppet 3 book introduction from John Arundel but much of the work has been pieced from sketchy examples around the web and other GitHub examples I've found, so it's entirely possible I've gotten my wires crossed – James Murphy Apr 25 '16 at 07:09

1 Answers1

1

The Puppetfile is used by the vagrant-librarian-puppet to install your puppet module so it should install.

Make sure the plugin is installed

$ vagrant plugin list
vagrant-librarian-puppet (0.9.2)
....

If you dont see the plugin, make sure to install it

$ vagrant plugin install vagrant-librarian-puppet
Frederic Henri
  • 51,761
  • 10
  • 113
  • 139
  • Thanks I believe I've done that but I'll double check when I'm home. Out of interest do I still need to manually install puppet modules e.g. 'puppet module install willdurand/nodejs' ? Or will vagrant puppet librarian do that for me? – James Murphy Apr 25 '16 at 07:15
  • no the idea with librarian is that it will do it for you - you set all your necessary modules and it will run the install puppet modules for you before any provisioning is done. going further, personally I still prefer to have a shell script that run the install puppet modules as it does not rely on yet another plugin on the workstation of my team members, but its a matter of taste and how you use it – Frederic Henri Apr 25 '16 at 07:17
  • Okay - I think my problem then is I installed the library manually and it won't install it because it believes it exists. I'll try uninstalling it and rerunning the vagrant provision step to confirm - thanks – James Murphy Apr 25 '16 at 07:19
  • it could indeed be the problem. you can try by starting from scratch and re-provision a new VM. I am not sure if there should be some error logs or not to tell you the module cannot be installed as its already there or something like that – Frederic Henri Apr 25 '16 at 07:28