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.")
    }
  }
On 4 Jan 2016 20:23, "jcbollinger" <john.bollin...@stjude.org> wrote:

>
>
> On Tuesday, December 29, 2015 at 9:30:08 AM UTC-6, linux....@gmail.com
> wrote:
>>
>> 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.
>>
>
>
> Your subject suggests that you hope to solve your problem by creating a
> defined type, and that is indeed a reasonable direction in which to
> proceed.  I am uncertain how to answer your question in any detail,
> however.  The Puppet manual has a section on defined types
> <https://docs.puppetlabs.com/puppet/4.3/reference/lang_defined_types.html>.
> Have you read it?  Do you have specific questions?
>
>
> 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/650e38fc-1ded-48e9-8c1b-2917fa870030%40googlegroups.com
> <https://groups.google.com/d/msgid/puppet-users/650e38fc-1ded-48e9-8c1b-2917fa870030%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CAPLcSADgDoeTyz5RdTeUuq-X%2BK1h%3DZZuu0jG%2Bw%2BEsCMQ_OJsLg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to