Ivo van der Meer
2009-Mar-17 14:45 UTC
[Puppet Users] Puppet ensure file statement pointing to earlier defined file
Hi, I recently started with configuring and building puppet classes and one thing I struggle with creating a symlink of a file I defined at the same class. Below you can see my full class which works fine, but I will now take out some statements to elaborate on my symlinking issue. I was trying to create a symlink for 2 files as you can see, but I don''t want to define the full path of the source file again since it''s already defined with it''s own privileges, etc.. So I was thinking of setting the "ensure" statement to an earlier defined file, this way I don''t have to mock about it when the source file changes. - For the file called "sym_ldap.conf" if get a parse error. - For the file called "sym_ldap.secret" if get a symlink like this : ldap.secret -> ldap.secret Is my syntax wrong or isn''t it possible yet to use the "ensure" statement like this ? <snip> "sym_ldap.conf": path => $operatingsystem ? { "FreeBSD" => "/usr/local/etc/ldap.conf", "Debian" => "/etc/ldap.conf" }, ensure => openldap-client::File["ldap.conf"]; "sym_ldap.secret": path => $operatingsystem ? { "FreeBSD" => "/usr/local/etc/ldap.secret", "Debian" => "/etc/ldap.secret" }, ensure => File["ldap.secret"]; </snip> Kind regards, Ivo van der Meer ---- full class ---- class openldap-client { package { "openldap-client": ensure => installed, name => $operatingsystem ? { "FreeBSD" => "openldap-client", "Debian" => "libldap" } } file { "ldap.conf": path => $operatingsystem ? { "FreeBSD" => "/usr/local/etc/openldap/ldap.conf", "Debian" => "/etc/ldap/ldap.conf" }, owner => ldap, group => ldap, mode => 644, require => [ Package["openldap-client"] ]; "ldap.secret": path => $operatingsystem ? { "FreeBSD" => "/usr/local/etc/openldap/ldap.secret", "Debian" => "/etc/ldap/ldap.conf" }, owner => ldap, group => ldap, mode => 600, source => "puppet:///configuration/ldapauth/openldap/ldap.secret", require => [ Package["openldap-client"] ]; # Create symlinks for the following files "sym_ldap.conf": path => $operatingsystem ? { "FreeBSD" => "/usr/local/etc/ldap.conf", "Debian" => "/etc/ldap.conf" }, ensure => "/usr/local/etc/openldap/ldap.conf"; "sym_ldap.secret": path => $operatingsystem ? { "FreeBSD" => "/usr/local/etc/ldap.secret", "Debian" => "/etc/ldap.secret" }, ensure => "/usr/local/etc/openldap/ldap.secret"; } } ---- END full class ---- --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Joshua Anderson
2009-Mar-17 17:38 UTC
[Puppet Users] Re: Puppet ensure file statement pointing to earlier defined file
On Mar 17, 2009, at 7:45 AM, Ivo van der Meer wrote:> Is my syntax wrong or isn''t it possible yet to use the "ensure" > statement > like this ? > > <snip> > "sym_ldap.conf": > path => $operatingsystem ? { > "FreeBSD" => "/usr/local/etc/ldap.conf", > "Debian" => "/etc/ldap.conf" > }, > ensure => openldap-client::File["ldap.conf"]; > > "sym_ldap.secret": > path => $operatingsystem ? { > "FreeBSD" => "/usr/local/etc/ldap.secret", > "Debian" => "/etc/ldap.secret" > }, > ensure => File["ldap.secret"]; > </snip>Ivo, I don''t believe that you can use a file reference that way, but here''s how I would avoid having to specify the full paths multiple times: class openldap-client { case $operatingsystem { "FreeBSD": { $ldap_conf_dir = "/usr/local/etc/openldap" $ldap_link_dir = "/usr/local/etc" } "Debian": { $ldap_conf_dir = "/etc/ldap" $ldap_link_dir = "/etc" } } file { "ldap.conf": path => "${ldap_conf_dir}/ldap.conf", ... } file { "ldap.secret": path => "${ldap_conf_dir}/ldap.secret", ... } file { "sym_ldap.conf": ensure => "$ldap_conf_dir}/ldap.conf" path => "${ldap_link_dir}/ldap.conf" ... } file { "sym_ldap.secret": ensure => "$ldap_conf_dir}/ldap.secret" path => "${ldap_link_dir}/ldap.secret" ... } ... } -Josh --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Ivo van der Meer
2009-Mar-18 08:04 UTC
[Puppet Users] Re: Puppet ensure file statement pointing to earlier defined file
Wow that''s a smart way of solving this issue, I haven''t thought of that! Tnx! Kind regards, Ivo On Tue, 17 Mar 2009 10:38:57 -0700, Joshua Anderson <joshua_anderson@mac.com> wrote:> On Mar 17, 2009, at 7:45 AM, Ivo van der Meer wrote: > >> Is my syntax wrong or isn''t it possible yet to use the "ensure" >> statement >> like this ? >> >> <snip> >> "sym_ldap.conf": >> path => $operatingsystem ? { >> "FreeBSD" => "/usr/local/etc/ldap.conf", >> "Debian" => "/etc/ldap.conf" >> }, >> ensure => openldap-client::File["ldap.conf"]; >> >> "sym_ldap.secret": >> path => $operatingsystem ? { >> "FreeBSD" => "/usr/local/etc/ldap.secret", >> "Debian" => "/etc/ldap.secret" >> }, >> ensure => File["ldap.secret"]; >> </snip> > > Ivo, > > I don''t believe that you can use a file reference that way, but here''s > how I would avoid having to specify the full paths multiple times: > > > class openldap-client { > case $operatingsystem { > "FreeBSD": { > $ldap_conf_dir = "/usr/local/etc/openldap" > $ldap_link_dir = "/usr/local/etc" > } > "Debian": { > $ldap_conf_dir = "/etc/ldap" > $ldap_link_dir = "/etc" > } > } > > file { "ldap.conf": > path => "${ldap_conf_dir}/ldap.conf", > ... > } > > file { "ldap.secret": > path => "${ldap_conf_dir}/ldap.secret", > ... > } > > file { "sym_ldap.conf": > ensure => "$ldap_conf_dir}/ldap.conf" > path => "${ldap_link_dir}/ldap.conf" > ... > } > > file { "sym_ldap.secret": > ensure => "$ldap_conf_dir}/ldap.secret" > path => "${ldap_link_dir}/ldap.secret" > ... > } > > ... > > } > > > -Josh > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---