All, The entire puppet configuration I have is based on the rule that nodes can only have variables and/or classes.
below are two examples how I configured puppet to deal with an apache installation and addding users The 'apache' example does work perfectly, but the 'users' example does not and this is where I need your help For example a node named apache.mydomain.com could be like this node 'apache.mydomain.com' { # Variables $apache_srv_version = "2.2.17-1" $apache_vgname = "vg01" # Classes include apache::setup } Apache module ## init.pp class apache { require apache::params } ## params.pp class apache::params { .... $package_version = $apache_srv_version ? { "2.2.16" => "2.2.16-1.el5", "2.2.16-1" => "2.2.16-1.el5", "2.2.17" => "2.2.17-1.el5", "2.2.17-1" => "2.2.17-1.el5", default => "latest", } # End package version .... } ## setup.pp class apache::setup inherits apache { class { "apache::setup::pre1": stage => pre1 } } class apache::setup::pre1 inherits apache::setup { package { $apache::params::package_name_modules: ensure => "${apache::params::package_version}", ...... } } What happens is that the variable gets set in the node 'apache.mydomain.com' $apache_srv_version = "2.2.17-1" Then it's evaluated in the apache::params class and the proper version value is stored in $package_version $package_version = $apache_srv_version ? { } When the actual package get installed in apache::setup::pre1, the value is retrieved from apache::params ensure => "${apache::params::package_version}", This all works like a charm and I have dozens of other classes which work the same way as the apache class. The module I have a problem with is my users module. This looks like the apache module, but is slightly different (like the 'define' used instead of only classes) Let me explain node 'users.mydomain.com' { # Variables $users_application_name = "ap1" # Classes include users::funcusers::was } ## init.pp define users ( $ensure = "present", $username = "${title}", $uid, $gid, $comment = "${username}", $home = "/home/${username}", $shell = "/bin/bash", $system = "false", $password = "", $password_min_age = "0", $password_max_age = "90", $groups = "", $membership = "", $mode = "700", $force = "false" ) { # # Load subclasses include users::params include users::virtual # # Required user settings user { "${username}": ensure => "${ensure}", uid => "${uid}", gid => "${gid}", comment => "${comment}", home => "${home}", shell => "${shell}", system => "${system}", } # # Additional user settings if $password != "" and "${users::params::password_initialize}" == "true" { User["${username}"] { password => "${password}", } } if $groups != "" { User["${username}"] { groups => $groups, } } if $membership != "" { User["${username}"] { membership => $membership, } } if $password_min_age != "" and $centrify_mode == "" { User["${username}"] { password_min_age => $password_min_age, } } if $password_max_age != "" and $centrify_mode == "" { User["${username}"] { password_max_age => $password_max_age, } } # # Create homedirectory file { "${home}": ensure => $ensure ? { "present" => "directory", "absent" => "absent", default => "directory", }, owner => "${uid}", group => "${gid}", mode => "${mode}", force => "${force}", require => User["${username}"], } } ## params.pp class users::params { $users_applications = $users_application_name ? { "ap1" => "ap1", "ap1" => "ap2", default => "unknown", } } ## funcusers.pp import "funcusers/*.pp" class users::funcusers inherits users::virtual { $user_type = "funcusers" } ## funcusers/was.pp class users::funcusers::was inherits users::funcusers { case $users::params::users_applications { "ap1": { Users <| title == was |> <- Group <| title == ap1 |> } "ap2": { Users <| title == was |> <- Group <| title == ap2 |> } default: { Users <| title == was |> <- Group <| title == was |> } } } ## virtual.pp class users::virtual { require users::params class { "users::virtual::init": stage => init } } class users::virtual::init inherits users::virtual { @group { "was": gid => "${users::params::gid_was}" } @group { "ap1": gid => "${users::params::gid_ap1}" } @group { "ap2": gid => "${users::params::gid_ap2}" } @users { "was": uid => "123", gid => $users::params::users_applications ? { "ap1" => "$ {users::params::gid_ap1}", "ap2" => "$ {users::params::gid_ap2}", default => "$ {users::params::gid_was}", }, groups => "extra", comment => "Functional user $ {users::params::users_applications}"; } } When puppet runs, the variable set in the host 'users.mydomain.com' $users_application_name = "ap1" is ignored and does not seem to be 'known' to the other subclassess (like params) and therefore ap1 will never be used, but always the defaults I know the users module and the way I have created it DOES work, because when I copy the same variable line from the node directly into the params class everything works fine class users::params { $users_application_name = "ap1" $users_applications = $users_application_name ? { "ap1" => "ap1", "ap1" => "ap2", default => "unknown", } } the $users_applications will have 'ap1' as value and will create the user 'was' with the gid of ap1 and put ap1 in the user comment. Can somebody explain me what I am doing wrong here ? or what I have missed ? WHy does the apache params 'see' the variable frmo the node config and the users params not ? FYI, I use puppet version 2.6.8 (and also tested with 2.6.9) on a RHEL5 server with ruby 1.8.5 -- 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.