Can someone point me in the right direction, I''ve got two "source" files one 32bit, on 64bit I''ve got it to work using the ternary operator but get syntax errors if I try to use a case: Works: class audit { package { "audit": ensure => present, name => $operatingsystem ? { default => "auditd", }, } file { "auditd.conf": owner => "root", group => "root", mode => "640", require => Package["audit"], path => $operatingsystem ? { default => "/etc/auditd.conf", }, source => "puppet://$server/modules/audit/ auditd.conf", } file { "audit.rules": owner => "root", group => "root", mode => "600", path => $operatingsystem ? { default => "/etc/audit.rules", }, source => $hardwaremodel ? { "x86_64" => "puppet://$server/modules/ audit/audit.rules.64", default => "puppet://$server/modules/ audit/audit.rules.32", }, } service { "audit": enable => "true", ensure => "running", hasstatus => "true", require => File["auditd.conf", "audit.rules"], subscribe => File["auditd.conf", "audit.rules"], name => $operatingsystem ? { default => "auditd", }, } } Syntax Error: Jul 23 13:20:43 <master> puppetmasterd[14197]: Syntax error at ''case''; expected ''}'' at /etc/puppet/modules/audit/manifests/init.pp:32 on node <client> Jul 23 13:20:43 <master> puppetmasterd[14197]: Syntax error at ''case''; expected ''}'' at /etc/puppet/modules/audit/manifests/init.pp:32 on node <client> class audit { package { "audit": ensure => present, name => $operatingsystem ? { default => "auditd", }, } file { "auditd.conf": owner => "root", group => "root", mode => "640", require => Package["audit"], path => $operatingsystem ? { default => "/etc/auditd.conf", }, source => "puppet://$server/modules/audit/ auditd.conf", } file { "audit.rules": owner => "root", group => "root", mode => "600", path => $operatingsystem ? { default => "/etc/audit.rules", }, case $hardwaremodel { "x86_64": { source => "puppet:// $server/modules/audit/audit.rules.64" } default: { source => "puppet:// $server/modules/audit/audit.rules.32" } }, } service { "audit": enable => "true", ensure => "running", hasstatus => "true", require => File["auditd.conf", "audit.rules"], subscribe => File["auditd.conf", "audit.rules"], name => $operatingsystem ? { default => "auditd", }, } } -- 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.
On Fri, Jul 23, 2010 at 2:22 PM, ScubaDude <brett.maton@googlemail.com> wrote:> Can someone point me in the right direction, I''ve got two "source" > files one 32bit, on 64bitProbably more elegant to use a ERB template only -- 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.
On Fri, Jul 23, 2010 at 7:22 AM, ScubaDude <brett.maton@googlemail.com>wrote:> Can someone point me in the right direction, I''ve got two "source" > files one 32bit, on 64bit > I''ve got it to work using the ternary operator but get syntax errors > if I try to use a case: > > Works: > > class audit { > > package { > "audit": > ensure => present, > name => $operatingsystem ? { > default => "auditd", > }, > } > > file { > "auditd.conf": > owner => "root", > group => "root", > mode => "640", > require => Package["audit"], > path => $operatingsystem ? { > default => "/etc/auditd.conf", > }, > source => "puppet://$server/modules/audit/ > auditd.conf", > } > > file { > "audit.rules": > owner => "root", > group => "root", > mode => "600", > path => $operatingsystem ? { > default => "/etc/audit.rules", > }, > source => $hardwaremodel ? { > "x86_64" => "puppet://$server/modules/ > audit/audit.rules.64", > default => "puppet://$server/modules/ > audit/audit.rules.32", > }, > } > > service { > "audit": > enable => "true", > ensure => "running", > hasstatus => "true", > require => File["auditd.conf", "audit.rules"], > subscribe => File["auditd.conf", "audit.rules"], > name => $operatingsystem ? { > default => "auditd", > }, > } > } > > Syntax Error: > > Jul 23 13:20:43 <master> puppetmasterd[14197]: Syntax error at ''case''; > expected ''}'' at /etc/puppet/modules/audit/manifests/init.pp:32 on node > <client> > Jul 23 13:20:43 <master> puppetmasterd[14197]: Syntax error at ''case''; > expected ''}'' at /etc/puppet/modules/audit/manifests/init.pp:32 on node > <client> > > class audit { > > package { > "audit": > ensure => present, > name => $operatingsystem ? { > default => "auditd", > }, > } > > file { > "auditd.conf": > owner => "root", > group => "root", > mode => "640", > require => Package["audit"], > path => $operatingsystem ? { > default => "/etc/auditd.conf", > }, > source => "puppet://$server/modules/audit/ > auditd.conf", > } > > file { > "audit.rules": > owner => "root", > group => "root", > mode => "600", > path => $operatingsystem ? { > default => "/etc/audit.rules", > }, > case $hardwaremodel { > "x86_64": { source => "puppet:// > $server/modules/audit/audit.rules.64" } > default: { source => "puppet:// > $server/modules/audit/audit.rules.32" } > }, > } > > service { > "audit": > enable => "true", > ensure => "running", > hasstatus => "true", > require => File["auditd.conf", "audit.rules"], > subscribe => File["auditd.conf", "audit.rules"], > name => $operatingsystem ? { > default => "auditd", > }, > } > } >You might want to add the case statement out of the file resource and assign to a variable for the source: case $hardwaremodel { "x86_64": { $hw_source "puppet://$server/modules/audit/audit.rules.64" } default: { $hw_source "puppet://$server/modules/audit/audit.rules.32" } } Then insinde the file resource only add the variable to the source: source => $hw_source, Seems like the parser does not allow case statements in the attributes of the resources. --> 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<puppet-users%2Bunsubscribe@googlegroups.com> > . > For more options, visit this group at > http://groups.google.com/group/puppet-users?hl=en. > >-- Tony http://blog.tonyskapunk.net -- 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.
On Fri, Jul 23, 2010 at 9:08 AM, Tony G. <tonysk8@gmail.com> wrote:> > Seems like the parser does not allow case statements in the attributes of > the resources.This is correct, case statements must be outside of resource statements. You could use the selector in-statement though. file { "/tmp/foo": source => $hardwaremodel ? { "x86_64" => "puppet://$server/modules/audit/audit.rules.64", default => "puppet://$server/modules/audit/audit.rules.32" } } Cheers, -- Jeff McCune http://www.puppetlabs.com/ -- 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.
On 7/23/2010 2:22 PM, ScubaDude wrote:> file { > "audit.rules": > owner => "root", > group => "root", > mode => "600", > path => $operatingsystem ? { > default => "/etc/audit.rules", > }, > case $hardwaremodel { > "x86_64": { source => "puppet:// > $server/modules/audit/audit.rules.64" } > default: { source => "puppet:// > $server/modules/audit/audit.rules.32" } > }, > }Write instead: file { "audit.rules": owner => "root", group => "root", mode => "600", path => $operatingsystem ? { default => "/etc/audit.rules", }, } case $hardwaremodel { "x86_64": { File["audit.rules"] { source => "puppet:///modules/audit/audit.rules.64" } }, default: { File["audit.rules"] { source => "puppet:///modules/audit/audit.rules.32" } }, } Best Regards, David -- dasz.at OG Tel: +43 (0)664 2602670 Web: http://dasz.at Klosterneuburg UID: ATU64260999 FB-Nr.: FN 309285 g FB-Gericht: LG Korneuburg -- 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.
On Jul 26, 12:20 am, David Schmitt <da...@dasz.at> wrote:> > Write instead: > > file { > "audit.rules": > owner => "root", > group => "root", > mode => "600", > path => $operatingsystem ? { > default => "/etc/audit.rules", > }, > > } > > case $hardwaremodel { > "x86_64": { File["audit.rules"] { source => > "puppet:///modules/audit/audit.rules.64" } }, > default: { File["audit.rules"] { source => > "puppet:///modules/audit/audit.rules.32" } }, > > } >I have to say I don''t like this at all. I think a far more clearer definition would be like this: file { "audit.rules": owner => "root", group => "root", mode => "600", path => "/etc/audit.rules, source => [ "puppet:///modules/audit/audit.rules. $hardwaremodel", "puppet:///modules/audit/audit.rules" ] } Then you just create a audit/files/audit.rules.x86_64 and anything else will fall through to audit.rules.> Best Regards, David > -- > dasz.at OG Tel: +43 (0)664 2602670 Web:http://dasz.at > Klosterneuburg UID: ATU64260999 > > FB-Nr.: FN 309285 g FB-Gericht: LG Korneuburg-- 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.
+1, although it just works for the source parameter. On 7/26/2010 5:57 PM, Andrew Forgue wrote:> > > On Jul 26, 12:20 am, David Schmitt<da...@dasz.at> wrote: >> >> Write instead: >> >> file { >> "audit.rules": >> owner => "root", >> group => "root", >> mode => "600", >> path => $operatingsystem ? { >> default => "/etc/audit.rules", >> }, >> >> } >> >> case $hardwaremodel { >> "x86_64": { File["audit.rules"] { source => >> "puppet:///modules/audit/audit.rules.64" } }, >> default: { File["audit.rules"] { source => >> "puppet:///modules/audit/audit.rules.32" } }, >> >> } >> > > I have to say I don''t like this at all. I think a far more clearer > definition would be like this: > > file { > "audit.rules": > owner => "root", > group => "root", > mode => "600", > path => "/etc/audit.rules, > source => [ > "puppet:///modules/audit/audit.rules. > $hardwaremodel", > "puppet:///modules/audit/audit.rules" > ] > } > > Then you just create a audit/files/audit.rules.x86_64 and anything > else will fall through to audit.rules. > > > > >> Best Regards, David >> -- >> dasz.at OG Tel: +43 (0)664 2602670 Web:http://dasz.at >> Klosterneuburg UID: ATU64260999 >> >> FB-Nr.: FN 309285 g FB-Gericht: LG Korneuburg >-- dasz.at OG Tel: +43 (0)664 2602670 Web: http://dasz.at Klosterneuburg UID: ATU64260999 FB-Nr.: FN 309285 g FB-Gericht: LG Korneuburg -- 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.
An option I like is a source like this: source => "puppet://$servername/modules/audit/$architecture/ audit.rules" Place your audit.rules in x86_64 and whatever 32-bit is (sorry don''t have any of those). -Erinn On Jul 27, 8:32 am, David Schmitt <da...@dasz.at> wrote:> +1, although it just works for the source parameter. > > On 7/26/2010 5:57 PM, Andrew Forgue wrote: > > > > > > > On Jul 26, 12:20 am, David Schmitt<da...@dasz.at> wrote: > > >> Write instead: > > >> file { > >> "audit.rules": > >> owner => "root", > >> group => "root", > >> mode => "600", > >> path => $operatingsystem ? { > >> default => "/etc/audit.rules", > >> }, > > >> } > > >> case $hardwaremodel { > >> "x86_64": { File["audit.rules"] { source => > >> "puppet:///modules/audit/audit.rules.64" } }, > >> default: { File["audit.rules"] { source => > >> "puppet:///modules/audit/audit.rules.32" } }, > > >> } > > > I have to say I don''t like this at all. I think a far more clearer > > definition would be like this: > > > file { > > "audit.rules": > > owner => "root", > > group => "root", > > mode => "600", > > path => "/etc/audit.rules, > > source => [ > > "puppet:///modules/audit/audit.rules. > > $hardwaremodel", > > "puppet:///modules/audit/audit.rules" > > ] > > } > > > Then you just create a audit/files/audit.rules.x86_64 and anything > > else will fall through to audit.rules. > > >> Best Regards, David > >> -- > >> dasz.at OG Tel: +43 (0)664 2602670 Web:http://dasz.at > >> Klosterneuburg UID: ATU64260999 > > >> FB-Nr.: FN 309285 g FB-Gericht: LG Korneuburg > > -- > dasz.at OG Tel: +43 (0)664 2602670 Web:http://dasz.at > Klosterneuburg UID: ATU64260999 > > FB-Nr.: FN 309285 g FB-Gericht: LG Korneuburg-- 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.
Thanks for the responses! I''ll try some of these out and post what I end up with. devzero, have you looked at how completely different the requirements are for 32bit and 64bit in audit.rules? Using an erb would be a nightmare! -- 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.
After a brief deliberation, it was actually a toss up between Andrew Forgue and Erinn Loony-Trigss''s suggestions. I opted for Andrew''s solution as in this case it seemed the neatest, although it was a very close thing. I''m sure that using an architecture directory would be the more elegant solution in some cases though. To everyone else, thank you for shedding some light on how puppet deals with case statements as I''m sure I''ll be needing those in the future. Thanks again for your help. -- 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.