Re: [Puppet Users] Lookup another node's hiera data - fqdn hierarchy

2012-07-23 Thread treydock


On Saturday, July 21, 2012 9:57:13 PM UTC-5, Garrett Honeycutt wrote:
>
> On 7/21/12 4:13 AM, treydock wrote: 
> > 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 
>
> This would be a great place to use exported resources[1]. Each node 
> could still use Hiera to determine if they should be backed up (or what 
> should be backed up) and export a resource and the backup server could 
> collect. 
>
> [1] - http://docs.puppetlabs.com/guides/exported_resources.html 
>
> -g 
>
> -- 
> Garrett Honeycutt 
>
> 206.414.8658 
> http://puppetlabs.com 
>


Looking at some of online documentation I see no means to either export the 
hash variable pulled into the modules from hiera or to export the defines 
called with "create_resources".

Is there a way to do something like @@$backuppc_db_dumps = 
hiera('backuppc_db_dumps') ?  Or possibly a way to export a custom define 
with all the parameters passed to it?

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/-/_mh8ipqsZ-EJ.
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.



Re: [Puppet Users] Lookup another node's hiera data - fqdn hierarchy

2012-07-21 Thread Garrett Honeycutt
On 7/21/12 4:13 AM, treydock wrote:
> 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

This would be a great place to use exported resources[1]. Each node
could still use Hiera to determine if they should be backed up (or what
should be backed up) and export a resource and the backup server could
collect.

[1] - http://docs.puppetlabs.com/guides/exported_resources.html

-g

-- 
Garrett Honeycutt

206.414.8658
http://puppetlabs.com

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
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.



[Puppet Users] Lookup another node's hiera data - fqdn hierarchy

2012-07-20 Thread treydock
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.