On Monday, March 10, 2014 9:47:22 AM UTC-4, jcbollinger wrote:
>
>
>
> On Friday, March 7, 2014 8:57:58 AM UTC-6, Mark deJong wrote:
>>
>> Hello,
>> We're currently using version 3.4.3, and the documentation on 
>> metaparameters states "any defined metaparameter can be used with any 
>> instance in your manifest, *including defined components.*" Unless I'm 
>> missing something, this statement does not hold true to the schedule 
>> parameter which gets passed into the defines as variables.
>>
>
>
> What makes you say that?  Do you have a manifest that seems to contradict 
> that statement, and 
> http://docs.puppetlabs.com/puppet/latest/reference/lang_defined_types.html#metaparameters?
>
>  I'm having the issue with the passwd::user accepting the schedule 
metaparameter. I have tried it both with and without define the variable 
'schedule.'

class passwd (
  $module_path        = $passwd::params::module_path,
  $path               = $passwd::params::path,
  $alg                = $passwd::params::alg,
  $length             = $passwd::params::length,
  $plugin             = $passwd::params::plugin,
  $enotify            = $passwd::params::enotify,
  $esubject           = $passwd::params::esubject,
  $schedule           = $passwd::params::schedule,
  $managehome         = $passwd::params::managehome,
  $homeowner_override = $passwd::params::homeowner_override,
  $homeowner          = $passwd::params::homeowner,
  $homegroup          = $passwd::params::homegroup,
  $users       = [],
) inherits passwd::params {
  include passwd::virtual

  validate_absolute_path($module_path)
  validate_absolute_path($path)
  validate_string($alg)
  validate_array($enotify)
  validate_string($esubject)
  validate_array($users)
  validate_bool($managehome)
  validate_bool($homeowner_override)

  anchor {'passwd::begin': } ->
  class {'passwd::install': } ->
  class {'passwd::schedule': } ->
  class {'passwd::provision': } ->
  anchor {'passwd::end': }
}


define passwd::user (
  $password,
  $uid,
  $gid,
  $comment,
  $shell,
  $home               = "${passwd::home_root}/${name}",
  $managehome         = $passwd::managehome,
  $homeowner_override = $passwd::homeowner_override,
  $homeowner          = $passwd::homeowner,
  $homegroup          = $passwd::homegroup,
  $path               = $passwd::path,
  $length             = $passwd::length,
  $ensure             = $passwd::ensure,
  $plugin             = $passwd::plugin,
  $enotify            = $passwd::enotify,
  $esubject           = $passwd::esubject,
  $schedule           = undef
){
  if ($password == 'G' and $ensure == 'present') {
    $pclear = generate('/bin/sh','-c',"/bin/cat  /dev/urandom | /usr/bin/tr 
-dc 'a-zA-Z0-9' | /usr/bin/fold -w ${length} | /usr/bin/head -n 1| tr -d 
'\n'")
    $pcrypt = generate('/usr/bin/openssl','passwd','-1',"'${pclear}'")
    $rpassword = chomp("${pcrypt}")
    notify {"${rpassword}":}
    if ! empty($enotify) {
      passwd::notify { $name:
        enotify  => $enotify,
        username  => $name,
        password => $pclear
      }
    }
  }
  else {
    $rpassword = $password
  }
  Augeas {
    load_path => "${passwd::params::module_path}/auglenses",
    lens   => "PluginPasswd.lns",
    incl    => "${path}",
  }
  case $ensure {
    present: {
      augeas { "pw_pl_mod_${name}":
        changes => [
          "set ${name}/password '${rpassword}'",
          "set ${name}/uid '${uid}'",
          "set ${name}/gid '${gid}'",
          "set ${name}/name '${comment}'",
          "set ${name}/home '${home}'",
          "set ${name}/shell '${shell}'",
        ],
schedule => $schedule
      }
      if $managehome {
        file { $home:
          ensure  => directory,
          owner   => homeowner_override ? {
            true    => $homeowner,
            default => $uid
          },
          group   => homeowner_override ? {
            true    => $homeowner,
            default => $gid
          },
          seltype  => user_home_dir_t,
          require => File[$passwd::home_root]
        }
      }
    }
    absent: {
      augeas { "pw_pl_mod_${name}":
        changes => [
          "rm ${name}"
        ]
      }
    }
  }
} 


class passwd::schedule (

) inherits passwd {
  schedule { 'passwd_generate_monthly':
    period => monthly,
    range  => "2 - 4",
    repeat => 1
  }
}


When I call passwd::user as either a resource or virtual resource, schedule 
is only honored by puppets built in functions within my define, but not  by 
passwd::user.

class passwd::virtual(
) inherits passwd {

  passwd::user{ 'johnjackson':
    password => "supersecretpassword",
    uid      => 121,
    gid      => 121,
    comment  => "User Comment",
    shell    => "/bin/false",
    schedule => 'passwd_generate_monthly'
  } 

  @passwd::user{ 'jimbeam':
    password => "G",
    uid      => 121,
    gid      => 121,
    comment  => "User Comment",
    shell    => "/bin/false",
    schedule => 'passwd_generate_monthly',
  }
}

Thanks!
M

 
>
>> Is there anyway to change its behavior to apply the schedule to our 
>> custom defines as a whole, and not have to pass that parameter to every 
>> resource within?
>>
>>
>
> As I read the docs, you shouldn't need to do anything special to achieve 
> that.  Suppose you present the manifest(s) that is causing you trouble, and 
> maybe we can shed some more light on the problem.
>
>
> John
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/c3ff4629-ae2d-4cd9-acec-307f8bb52465%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to