Skip to content

Instantly share code, notes, and snippets.

@optiz0r
Created December 18, 2013 08:38
Show Gist options
  • Save optiz0r/8019140 to your computer and use it in GitHub Desktop.
Save optiz0r/8019140 to your computer and use it in GitHub Desktop.
Puppet example showing default parameters on exported defined types aren't stored in the catalog
{
u'parameters': {
u'ensure': u'present',
u'path': u'/data/test',
# Missing are job_name, server_name, backup_schedule
},
u'title': u'test',
u'tags': [u'node', u'backup', u'testnode.localdomain', u'class', u'backup::job', u'job'],
u'exported': True,
u'file': u'/home/puppet/production/modules/backup/manifests/init.pp',
u'line': 123,
u'type': u'Bacula::Job'
}
class backup::common(
$server_name, # internal server name clients should backup to
) {
# common stuff like package installs
}
class backup::client(
# Can be overridden per-client using hiera
$backup_schedule='Weekly',
) {
include backup::common
@@backup::client {
$::fqdn:
# explicit parameters are stored in the catalog
ensure => present;
# Expecting omitted parameters to have default values resolved and stored in catalog.
# This is not the case. Should it be?
}
@@backup::filesystem {
'test':
# explicit parameters are stored in the catalog
ensure => present,
path => '/data/test';
# Expecting omitted parameters to have default values resolved and stored in catalog.
# This is not the case. Should it be?
}
}
class backup::server(
$config_dir='/etc/backup/conf.d',
$storage_path='/data/backup',
) {
include backup::common
# Collect resources for things that should be backed up to this server
# Since server_name is not listed explicitly above, it's not in the catalog
# so these don't match anything!
Backup::Client<<| server_name == $::backup::common::server_name |>>
Backup::Job<<| server_name == $::backup::common::server_name |>>
}
define backup::client(
$ensure=present,
# Sensible defaults, expecting these to resolve on the exporter side and be stored in catalog
$client_name=$title,
$server_name=$::backup::common::server_name,
) {
file {
"${::backup::server::config_dir}/${client_name}.conf":
# Template uses parameters that the client should provide,
# scope lookup to get at $::backup::server variables
content => template('backup/_client.conf.erb');
}
}
define backup::job(
$ensure=present,
# Sensible defaults, expecting these to resolve on the exporter side and be stored in catalog
$job_name=$title,
$server_name=$::backup::common::server_name,
$backup_schedule=$::backup::client::backup_schedule,
$path='/home',
) {
file {
"${::backup::server::config_dir}/clients/${title}.conf":
# Template uses parameters that the client should provide like backup_schedule
# scope lookup to get at $::backup::server variables like storage_path
content => template('backup/_client.conf.erb');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment