1

Once I've installed Puppet, Foreman, Hiera and Facter, how do I get them all to work with one another?

The Foreman GUI is operating properly and can be viewed using a browser. Hiera is installed, and by guides I read on the internet it seems like it's configured correctly and Facter also works properly, but agents are not getting modules from the Puppet server.

I've added a very simple MOTD module and configured it to run in common.yaml. But the module is not installed on agent machines and no error is displayed.

Running puppet agent -t on the server and on clients works:

[root@puppet production]# puppet agent -t
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Loading facts
Info: Caching catalog for puppet.nj.peer39.com
Info: Applying configuration version '1425802774'
Notice: Finished catalog run in 0.05 seconds
[root@puppet production]#

hiera.yaml looks like that:

[root@puppet production]# cat /etc/puppet/hiera.yaml
:backends:
  - yaml
:yaml:
  :datadir: '/etc/puppet/hieradata/%{::environment}'
:hierarchy:
  - fqdns/%{::fqdn}
  - roles/%{::role}
  - domains/%{::domain}
  - common

environment.conf looks like that:

[root@puppet production]# pwd
/etc/puppet/environments/production
[root@puppet production]# cat environment.conf
modulepath  = modules
manifest = /etc/puppet/environments/production/manifests/
[root@puppet production]#

I also tried loading the module through a fqdn.yaml file but to no avail and no error is displayed.

/etc/puppet/puppet.conf looks like that:

[master]
    autosign       = $confdir/autosign.conf { mode = 664 }
    reports        = foreman
    external_nodes = /etc/puppet/node.rb
    node_terminus  = exec
    ca             = true
    ssldir         = /var/lib/puppet/ssl
    certname       = puppet.company.com
    strict_variables = false
    environmentpath = $confdir/environments

Edit #1:

My common.yaml looks like that:

classes:
- motd

When I said fqdn.yaml I meant:

[root@puppet fqdns]# pwd
/etc/puppet/hieradata/production/fqdns
[root@puppet fqdns]# ll
total 8
-rw-r--r-- 1 root root 23 Mar 11 09:26 pnd01.company.yaml
-rw-r--r-- 1 root root 17 Mar 12 08:24 puppet.company.com.yaml
[root@puppet fqdns]#

That's my site.pp, which is located at /etc/puppet/environments/production/manifests:

[root@puppet manifests]# cat site.pp
hiera_include("classes", [])
Package {  allow_virtual => false, }

node default {
}
030
  • 5,901
  • 13
  • 68
  • 110
Itai Ganot
  • 10,644
  • 29
  • 93
  • 146
  • 1
    On the `puppetmaster`, how does the log look for when it compiles the catalog? Also, how does `common.yaml` look? – Belmin Fernandez Mar 12 '15 at 17:24
  • What do you mean by "loading the module through a [yaml]"? Please note that literal `fqdn.yaml` is not in your hierarchy - `fqdns/.yaml` is. Is there a `site.pp` or any `.pp` in your `manifests` directory? Is Puppet configured to use the foreman as an ENC? If not, what is foreman doing in your setup anyway? – Felix Frank Mar 13 '15 at 11:23
  • Thanks for your replies, I've edited my question, please check Edit #1. @FelixFrank, what do you mean as an ENC please? – Itai Ganot Mar 13 '15 at 11:35
  • More info on [ENCs](https://docs.puppetlabs.com/guides/external_nodes.html). This looks all right. Try some [Hiera debugging](https://docs.puppetlabs.com/hiera/1/command_line.html) first. Also use `notify` resources to debug the manifest. – Felix Frank Mar 13 '15 at 13:04

1 Answers1

2
  1. The Puppetmaster needs to be restarted if the hiera.yaml has been changed
  2. The format of the hiera files is important, i.e. two spaces instead of null and ---

common.yaml

---
classes:
  - motd

instead of

classes:
- motd
  1. If Puppet Environments are enabled the datadir should be configured as follows:

/etc/puppet/hiera.yaml

:yaml:
  :datadir: "/etc/puppet/environments/%{::environment}/hieradata"

Every environment should contain a hieradata directory and it should include the common.yaml. If no environments are used the hiera.yaml looks as follows:

:yaml:
  :datadir: "/etc/puppet/hieradata"

move the common.yaml to this directory and restart the puppetmaster

  1. Defining hiera_include('classes') in the site.pp instead of hiera_include("classes", []) is sufficient
030
  • 5,901
  • 13
  • 68
  • 110
  • That's the way it is written, SF's [ ] code block removed the spaces but the file looks just like you showed. – Itai Ganot Mar 14 '15 at 19:04