--
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...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/eda4893c-a09d-44cd-80c3-c9c0f0d67599%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Hi,I am new to puppet and I am trying to write a module to manage user .bashrc files. I managed to place the file to the desired location with following code for 1 user because the username is hardcoded. However, I tried different ways to manage the file for 10 different users using variables which fails. Can someone please help me with the same.
Hi,
The below code works fine for me. However, I want to reframe the code by using define statement in params.pp instead of config.pp.
I wanted to define it in params.pp so that I can use only variables in config.pp(ex:I am using $home/$name/.bashrc as file path in config which should be something like $bashrc if I would be able to use define in params.pp)
init.pp:
class profile (
$home = $profile::params::home,
$bashrc_host = $profile::params::bashrc_host,
) inherits profile::params {
profile::config::params {user1:}
profile::config::params {user2:} anchor { 'profile::begin': } ->
class { '::profile::config': } ->
anchor { 'profile::end': }
}
config.pp:
class profile::config inherits profile {
define user (username=$name)
file { "$home/$name/.bashrc":
ensure => file,
source => "puppet:///modules/profile/$fqdn_$name_bashrc",
}
params:pp:
class profile::params {
$bashrc_host = "modules/profile/$fqdn_$name_bashrc"
}
case $::osfamily {
'RedHat': {
$bashrc = '/home/$name/.bashrc'
}
default: {
fail("The ${module_name} module is not supported on an ${::osfamily} based system.")
}
}
--
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...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/650e38fc-1ded-48e9-8c1b-2917fa870030%40googlegroups.com.
Hi,
The below code works fine for me.
However, I want to reframe the code by using define statement in params.pp instead of config.pp.
define profile::user($param1, $param2) {
# ...
}
I wanted to define it in params.pp so that I can use only variables in config.pp(ex:I am using $home/$name/.bashrc as file path in config which should be something like $bashrc if I would be able to use define in params.pp)
John,
Sorry for the typos in the code.for some reason I had to type the code instead of copying.I thought it would give a general idea about the format in which I wanted to write it.
Secondly, I used define inside a class because I could not see a way to call the define inside another class which is out of it.
Let's say if I define something like modules/profile/manifests/user.pp:
define user (username=$name){
}
I want to call it into parms.pp where I assign all my variables related to this module something like below.$name should expand into actual user name which is passed through init.pp
class profile::params {
$bashrc_host = "modules/profile/$fqdn_$name_bashrc"
$bashrc = '/home/$name/.bashrc'
}
I am using puppet 2.7.hence I cannot use iterations to make it happen.
--
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...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/2043e299-78c2-4db9-a704-b96f60457b39%40googlegroups.com.
John,
Sorry for the typos in the code.for some reason I had to type the code instead of copying.I thought it would give a general idea about the format in which I wanted to write it.
Secondly, I used define inside a class because I could not see a way to call the define inside another class which is out of it.
Let's say if I define something like modules/profile/manifests/user.pp:
define user (username=$name){
}
I want to call it into parms.pp where I assign all my variables related to this module something like below.$name should expand into actual user name which is passed through init.pp
class profile::params {
$bashrc_host = "modules/profile/$fqdn_$name_bashrc"
$bashrc = '/home/$name/.bashrc'
}
profile::user { 'user1': }
define profile::user($param1, $param2) {
include '::profile::params'
# now assuredly safe to access $profile::params::bashrc, etc.
# ...
}
I am using puppet 2.7.hence I cannot use iterations to make it happen.