Ask Your Question

hiera and puppet on centos7

asked 2015-11-03 20:19:25 -0500

tagomasa gravatar image

updated 2015-11-05 11:04:01 -0500

I try to update cron via puppet. Until today i have used only foreman for apply and never hiera. I did this after see this howto First i have create dirs for hiera

cd /etc/puppet && mkdir -p hieradata/development hieradata/production/domains hieradata/production/fqdns hieradata/production/OBSOLETE hieradata/production/roles

Then edit hiera.yaml

  - yaml :yaml: :datadir: '/etc/puppet/hieradata/%{::environment}' :hierarchy:
- fqdns/%{::fqdn}
- roles/%{::role}
- domains/%{::domain}
- common

Then my cron module put in common.yaml

## Cron module
cron::enable: true     # on startup
cron::ensure: true     # running
cron::crontab_path: /etc/crontab
puppetheader: Managed by Puppet @ site.priv

  SHELL: /usr/bin/sh
  PATH: /sbin:/bin:/usr/sbin:/usr/bin
  MAILTO: ""
  HOME: /root

  'check scripts in cron.hourly, cron.daily, cron.weekly and cron.monthly': 
    - "*/35   *  *  *  * >/dev/null 2>&1"

Hiera seems to work

hiera -c ../hiera.yaml cron::ensure

hiera cron::ensure 

But after did puppet agent -t...nothing change and /etc/crontab is system default. What i miss?

Edit1: i did also

puppet apply -e 'include cron' --hiera_config=/etc/puppet/hiera.yaml  --verbose --debug

and return

Debug: Scope(Class[Cron::Crontab::Config]): Retrieving template cron/crontab.erb
Debug: template[/etc/puppet/environments/production/modules/cron/templates/crontab.erb]: Bound template variables for /etc/puppet/environments/production/modules/cron/templates/crontab.erb in 0.00 seconds
Warning: Variable access via 'puppetheader' is deprecated. Use '@puppetheader' instead. template[/etc/puppet/environments/production/modules/cron/templates/crontab.erb]:1
   (at /usr/share/ruby/vendor_ruby/puppet/parser/templatewrapper.rb:77:in `method_missing')
Error: Failed to parse template cron/crontab.erb:
  Filepath: /usr/share/ruby/vendor_ruby/puppet/parser/templatewrapper.rb
  Line: 82
  Detail: Could not find value for 'package_name' at /etc/puppet/environments/production/modules/cron/templates/crontab.erb:2
 at /etc/puppet/environments/production/modules/cron/manifests/init.pp:47 on node centos71.verde.privata
Error: Failed to parse template cron/crontab.erb:
  Filepath: /usr/share/ruby/vendor_ruby/puppet/parser/templatewrapper.rb
  Line: 82
  Detail: Could not find value for 'package_name' at /etc/puppet/environments/production/modules/cron/templates/crontab.erb:2
 at /etc/puppet/environments/production/modules/cron/manifests/init.pp:47 on node centos71.verde.privata
edit retag flag offensive close merge delete


Have you restarted your Puppet master after changing hiera.yaml? That is required. If you did that, then please post a link to a pastebin of your code. It's hard to say what's happening without that.

GregLarkin gravatar imageGregLarkin ( 2015-11-04 01:10:50 -0500 )edit

Are you actually including the cron class anywhere? You're providing data for it's parameters, but is that data even being looked at?

lavaman gravatar imagelavaman ( 2015-11-04 13:06:50 -0500 )edit

What code i have to past?

tagomasa gravatar imagetagomasa ( 2015-11-05 10:52:13 -0500 )edit

The source code of your cron class is what's needed

GregLarkin gravatar imageGregLarkin ( 2015-11-05 22:23:43 -0500 )edit

Actually, I think that he only needs to set $package_name variable in order for his code to work.

Cristian Falcas gravatar imageCristian Falcas ( 2015-11-06 02:29:52 -0500 )edit

2 answers

Sort by ยป oldest newest most voted

answered 2015-11-06 17:39:39 -0500

tagomasa gravatar image

Solution found,was problem with module i try another module now work thanks to all

edit flag offensive delete link more

answered 2015-11-03 22:50:06 -0500

lupin gravatar image

How did you refer/call the value of your cron paramter from hiera, did do a hiera('cron::ensure')?

edit flag offensive delete link more


Yes return "true" but after puppet agent -t nothing change

tagomasa gravatar imagetagomasa ( 2015-11-05 10:53:49 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2015-11-03 20:19:25 -0500

Seen: 324 times

Last updated: Nov 06 '15