I've begun using Hiera in combination with Foreman, primarily storing data 
that is best left in Array/Hash form.  I'd like to be able to have a 
module, in this case BackupPC, query all the Hiera data for each node where 
the backup directories/databases are stored.  Then use all that information 
on the BackupPC server to generate proper configuration files for each 
node's backups.  Here's what I have so far...

$ cat /etc/puppet/hiera.yaml 
---
:hierarchy:
  - %{fqdn}
  - common
:backends:
  - yaml
  - puppet
:yaml:
  :datadir: '/etc/puppet/hieradata'
:puppet:
  :datasource: data


An example of the BackupPC information in hiera
$ cat /etc/puppet/hieradata/dc-ctrl.tamu.edu.yaml 
---
backuppc_db_dumps:
  foreman:
    backup_dir: '/usr/share/foreman'
  mysql:
    backup_dir: '/etc'

I am currently using that data to create dump scripts on each node, and 
would like to re-use the same information to automatically configure the 
backup server to grab those locations.

This attempt may work, but it doesn't 'feel' right to me by overriding the 
fqdn fact.

/etc/puppet/modules/test  $ cat manifests/hiera_lookup.pp 
class test::hiera_lookup {
  $nodes = foreman('fact_values', 'fact = fqdn')

  if $nodes {
    create_resources('test::hiera_lookup::get_data', $nodes)
  }
}

define test::hiera_lookup::get_data (
  $fqdn
) {

 $data = hiera("backuppc_db_dumps", false)

  if $data { notify { $data: } }

}

Is there a better approach to override scope and grab what data from hiera 
that would normally not be available to a node?

Thanks
- Trey

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/puppet-users/-/KPHH_bR-4wsJ.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.

Reply via email to