Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

puppet fails when using hiera lookup on package installation

Hey guys. Pretty new to puppet and am having issues with a hiera lookup specifically when installing packages. I believe puppet thinks that the package resource is missing a title - it just has a variable as a title instead of the package name.

[root@canary production]# puppet agent -t

Info: Using configured environment 'production'
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Loading facts
Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Evaluation Error: Missing title. The title expression resulted in undef at /etc/puppetlabs/code/environments/production/site/profiles/manifests/common/packages.pp:5:11 on node canary.esxi.com
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run

If I run puppet apply packages.pp (changing it from a class to a normal manifest) it runs fine.

[root@puppet02 common]# vim /etc/puppetlabs/code/environments/production/site/profiles/manifests/common/packages.pp

$packages = lookup('packages::installed')

#class profiles::common::packages {

package { $packages:
    ensure => installed,
}

#}

As you can see "nmap" is now installed.

[root@puppet02 common]# puppet apply packages.pp
Notice: Compiled catalog for puppet02.esxi in environment production in 0.08 seconds
Notice: /Stage[main]/Main/Package[nmap]/ensure: created
Error: Execution of '/usr/bin/yum -d 0 -e 0 -y install wget'' returned 1: Error: Nothing to do
Error: /Stage[main]/Main/Package[wget']/ensure: change from purged to present failed: Execution of '/usr/bin/yum -d 0 -e 0 -y install wget'' returned 1: Error: Nothing to do
Notice: Applied catalog in 8.81 seconds

common.yaml (where the packages are listed):

[root@puppet02 common]# vim /etc/puppetlabs/code/environments/production/hieradata/common.yaml
packages::installed:
 - bash-completion
 - vim
 - nfs-utils
 - iotop
 - ntp
 - epel-release
 - deltarpm
 - mlocate
 - nmap
 - tcpdump
 - nethogs
 - sysstat
 - wget'
 - git
 - yum-utils
 - bind-utils
 - net-tools
 - yum-cron

I'm able to look up the "packages:installed"

[root@puppet02 common]# puppet lookup packages::installed
---
- bash-completion
- vim
- nfs-utils
- iotop
- ntp
- epel-release
- deltarpm
- mlocate
- nmap
- tcpdump
- nethogs
- sysstat
- wget'
- git
- yum-utils
- bind-utils
- net-tools
- yum-cron

[root@puppet02 common]# vim /etc/puppetlabs/code/environments/production/site/profiles/manifests/common/packages.pp

$packages = lookup('packages::installed')

class profiles::common::packages {

package { $packages:
    ensure => installed,
}

}

My site.pp file:

node default {
    contain roles::base
    #notify { "This is running the default in site.pp" }
}