title: Puppet and hiera,how to apply changes?
body: <p>I  want to update cron via puppet.
  Until today i have used only foreman for apply
  and never userd hiera.
  Following this <a href="http://geek-kb.com/install-puppet-foreman-centos-6-x" rel="nofollow">howto</a>
  First i have create dirs for hiera</p>
  
  <pre><code>cd /etc/puppet &amp;&amp; mkdir -p hieradata/development hieradata/production/domains hieradata/production/fqdns hieradata/production/OBSOLETE hieradata/production/roles
  </code></pre>
  
  <p>Then I edit hiera.yaml</p>
  
  <pre><code>:backends:
    - yaml :yaml: :datadir: '/etc/puppet/hieradata/%{::environment}' :hierarchy:
  - fqdns/%{::fqdn}
  - roles/%{::role}
  - domains/%{::domain}
  - common
  </code></pre>
  
  <p>Then I put in common.yaml</p>
  
  <pre><code>## Cron module
  cron::enable: true     # on startup
  cron::ensure: true     # running
  cron::crontab_path: /etc/crontab
  puppetheader: Managed by Puppet @ site.priv
  
  cron::crontab_vars_hsh:
    SHELL: /usr/bin/sh
    PATH: /sbin:/bin:/usr/sbin:/usr/bin
    MAILTO: ""
    HOME: /root
  
  cron::crontab_site_job_hsh:
    'check scripts in cron.hourly, cron.daily, cron.weekly and cron.monthly': 
      - "*/35   *  *  *  *  script.sh &gt;/dev/null 2&gt;&amp;1"
  </code></pre>
  
  <p>Hiera seems to work</p>
  
  <p>hiera -c ../hiera.yaml   cron::ensure</p>
  
  <pre><code>hiera cron::ensure 
  true
  </code></pre>
  
  <p>But after did puppet agent -t...nothing change
  and /etc/crontab is system default.
  I did also</p>
  
  <pre><code>puppet apply -e 'include cron' --hiera_config=/etc/puppet/hiera.yaml  --verbose --debug
  </code></pre>
  
  <p>and return</p>
  
  <pre><code>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 server.example.com
  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 centos.example.com
  </code></pre>
  
  <p>What i miss?</p>
  
  <p>edit1: i add the .erb</p>
  
  <pre><code>## &lt;%= puppetheader %&gt;
  # for &lt;%= package_name %&gt;
  
  &lt;% if (!crontab_vars_hsh.empty?)  -%&gt;
  ## Variables
  &lt;% crontab_vars_hsh.sort.each do |key,val| -%&gt;
  &lt;%= key %&gt;=&lt;%= val %&gt; 
  &lt;% end -%&gt;
  &lt;% end -%&gt;
  
  # Example of job definition:
  # .---------------- minute (0 - 59)
  # |  .------------- hour (0 - 23)
  # |  |  .---------- day of month (1 - 31)
  # |  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ...
  # |  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
  # |  |  |  |  |
  # *  *  *  *  * username command-to-be-executed
  
  &lt;% if (!crontab_site_job_hsh.empty?)  -%&gt;
  ## Site Wide Jobs
  &lt;% crontab_site_job_hsh.sort.each do |key,val| -%&gt;
  
  # &lt;%= key %&gt;
  &lt;% val.each do |croncmd|  -%&gt;
   &lt;%= croncmd %&gt;
  &lt;% end -%&gt;
  &lt;% end -%&gt;
  &lt;% end -%&gt;
  
  &lt;% if (!crontab_node_job_hsh.empty?)  -%&gt;
  ## Node Specific Jobs
  &lt;% crontab_node_job_hsh.sort.each do |key,val| -%&gt;
  
  # &lt;%= key %&gt;
  &lt;% val.each do |croncmd|  -%&gt;
   &lt;%= croncmd %&gt;
  &lt;% end -%&gt;
  &lt;% end -%&gt;
  &lt;% end -%&gt;
  </code></pre>