This is what I would like to do. define normal_user($fullname, $groups) { $username = $name user { "$username" : ensure => present, allowdupe => false, shell => ''/bin/bash'', home => "/home/${username}", gid => $username, groups => $groups, comment => $fullname, managehome => true, } if exists("puppet://modules/users/${username}.bashrc") { # This is the important line file { "/home/${username}/.bashrc": ensure => present, source => "puppet://modules/users/${username}.bashrc" } } normal_user { "joe": fullname => "Joe Hillenbrand", groups => ["admin"] } -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Markus Falb
2011-Jun-10 19:54 UTC
Re: [Puppet Users] How can I test if source file exists?
On 10.6.2011 21:18, JoE wrote:> This is what I would like to do. > > define normal_user($fullname, $groups) { > $username = $name > user { "$username" : > ensure => present, > allowdupe => false, > shell => ''/bin/bash'', > home => "/home/${username}", > gid => $username, > groups => $groups, > comment => $fullname, > managehome => true, > } > > if exists("puppet://modules/users/${username}.bashrc") { # This is > the important line > file { "/home/${username}/.bashrc": > ensure => present, > source => "puppet://modules/users/${username}.bashrc" > } > }If you specify multiple file sources for a file, then the first source that exists will be used. file { "/home/${username}/.bashrc": ensure => present, source => [ "puppet://modules/users/${username}.bashrc", "puppet://modules/users/default.bashrc", ], }> > normal_user { "joe": > fullname => "Joe Hillenbrand", > groups => ["admin"] > } >-- Kind Regards, Markus Falb