dev/provisioning/modules/puppi/manifests/ze.pp
changeset 28 b0b56e0f8c7f
equal deleted inserted replaced
27:a2342f26c9de 28:b0b56e0f8c7f
       
     1 # Define puppi::ze
       
     2 #
       
     3 # The Puppi 2.0 define that transforms any class variable in data
       
     4 # you can use with Puppi
       
     5 #
       
     6 # == Usage
       
     7 # Basic Usage:
       
     8 # puppi::ze { "openssh":
       
     9 #   variables => get_class_args(),
       
    10 # }
       
    11 #
       
    12 # puppi::ze { "openssh":
       
    13 #   variables => get_class_args(),
       
    14 #   filter    => '.*content.*|.*key.*',
       
    15 # }
       
    16 #
       
    17 define puppi::ze (
       
    18   $variables,
       
    19   $helper = 'standard',
       
    20   $filter = '.*content.*|.*password.*',
       
    21   $ensure = 'present' ) {
       
    22 
       
    23   require puppi
       
    24   require puppi::params
       
    25 
       
    26   file { "puppize_${name}":
       
    27     ensure  => $ensure,
       
    28     path    => "${puppi::params::datadir}/${helper}_${name}.yml",
       
    29     mode    => '0644',
       
    30     owner   => $puppi::params::configfile_owner,
       
    31     group   => $puppi::params::configfile_group,
       
    32     content => inline_template("---\n<%= Hash[@variables].reject{ |k,v| k.to_s =~ /(${filter})/ }.keys.sort.map{|k| Array({k => @variables[k]}.to_yaml)[1..-1].join}.join(\"\n\") %>\n"),
       
    33   }
       
    34 
       
    35 }