I want to distribute a binary directory based upon whether the "architecture" is 32- or 64-bit. It appears I cannot nest a case statement under file, however this is what I was attempting to do: file { "/usr/local/nagios/libexec": require => File[''/usr/local/nagios''], ensure => directory, owner => ''root'', group => ''root'', mode => 655, recurse => true, ## APPEARS I can''t do this case $architecture { /(i386|i586|i686/): { source => "puppet:///files/32/usr/local/nagios/ libexec" } x86_64: { source => "puppet:///files/64/usr/local/nagios/ libexec" } } } I know I could reverse it and do a case first, then have redundant file {} declarations, but that seems just that, redundant. Can anyone point out what I''m doing wrong here. The output in the puppet logs isn''t generally helpful with debugging. Thanks. -- 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.
You''re pretty close. You don''t want the case statement per se, but you do want a conditional: file { "/usr/local/nagios/libexec": require => File[''/usr/local/nagios''], ensure => directory, owner => ''root'', group => ''root'', mode => 655, recurse => true, source => $::architecture { /(i386|i586|i686/) => "puppet:///files/32/usr/local/nagios/libexec", x86_64 => "puppet:///files/64/usr/local/nagios/libexec", } } On Apr 16, 2012, at 3:43 PM, Forrie wrote:> I want to distribute a binary directory based upon whether the > "architecture" is 32- or 64-bit. It appears I cannot nest a case > statement under file, however this is what I was attempting to do: > > file { "/usr/local/nagios/libexec": > require => File[''/usr/local/nagios''], > ensure => directory, > owner => ''root'', > group => ''root'', > mode => 655, > recurse => true, > ## APPEARS I can''t do this > case $architecture { > /(i386|i586|i686/): { > source => "puppet:///files/32/usr/local/nagios/ > libexec" > } > x86_64: { > source => "puppet:///files/64/usr/local/nagios/ > libexec" > } > } > } > > > I know I could reverse it and do a case first, then have redundant > file {} declarations, but that seems just that, redundant. > > Can anyone point out what I''m doing wrong here. The output in the > puppet logs isn''t generally helpful with debugging. > > > Thanks. > > -- > 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.-- 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.
Thank you, I appreciate it. Still learning all the interesting nuances of this syntax. I''m not yet familiar with this $:: -- 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.
Geoff Davis
2012-Apr-17 19:48 UTC
Re: [Puppet Users] Re: Case statements in a file directive
The $:: business is to force the variable look up to be in the top scope. It didn''t fix have anything to do with the conditional, I just put it there for correctness. In this case, you are using a variable that is set by facter, so it appears in the top scope. Variables that you set yourself can be in the top scope if you put them in site.pp, or in a class scope if you declare them inside of a class. There''s also a node scope. While referring to variables with explicit scoping is not required in the current version of puppet, there are some major upcoming changes to how Puppet makes variables available to different parts of your code. You''ll most likely get a compiler warning if you don''t use it in the 2.7 series, and it just won''t work in the next version of Puppet. This page on variable scope is worth reading: http://docs.puppetlabs.com/guides/scope_and_puppet.html Geoff Davis Scripps Institution of Oceanography gadavis@ucsd.edu, (858) 822-5756 On Apr 17, 2012, at 12:31 PM, Forrie wrote:> Thank you, I appreciate it. Still learning all the interesting > nuances of this syntax. I''m not yet familiar with this $:: > > > -- > 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.-- 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.
So, it''s choking on this still at the line with the conditional: Apr 17 18:58:17 test-system puppet-agent[7590]: Could not retrieve catalog from remote server: Error 400 on SERVER: Could not parse for environment production: Syntax error at ''{''; expected ''}'' at /etc/ puppet/manifests/classes/nagios-client-test.pp:20 on node test- system.my-domain.com The brackets look balanced to me. file { "/usr/local/nagios/libexec": require => File[''/usr/local/nagios''], ensure => directory, owner => ''root'', group => ''root'', mode => 655, recurse => true, source => $::architecture { /(i386|i586|i686/) => "puppet:///files/32/usr/local/ nagios/libexec", x86_64 => "puppet:///files/64/usr/local/ nagios/libexec", } } -- 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.
> /(i386|i586|i686/) =>should be> /(i386|i586|i686)/ =>shouldn''t it? Den On 18/04/2012, at 9:01, Forrie <forrie@gmail.com> wrote:> So, it''s choking on this still at the line with the conditional: > > Apr 17 18:58:17 test-system puppet-agent[7590]: Could not retrieve > catalog from remote server: Error 400 on SERVER: Could not parse for > environment production: Syntax error at ''{''; expected ''}'' at /etc/ > puppet/manifests/classes/nagios-client-test.pp:20 on node test- > system.my-domain.com > > The brackets look balanced to me. > > > file { "/usr/local/nagios/libexec": > require => File[''/usr/local/nagios''], > ensure => directory, > owner => ''root'', > group => ''root'', > mode => 655, > recurse => true, > source => $::architecture { > /(i386|i586|i686/) => "puppet:///files/32/usr/local/ > nagios/libexec", > x86_64 => "puppet:///files/64/usr/local/ > nagios/libexec", > } > } > > > -- > 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. >-- 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.
Geoff Davis
2012-Apr-17 23:44 UTC
Re: [Puppet Users] Re: Case statements in a file directive
Yup, I fat-fingered my response. On Apr 17, 2012, at 4:10 PM, Denmat <tu2bgone@gmail.com> wrote:>> /(i386|i586|i686/) => > should be >> /(i386|i586|i686)/ => > shouldn''t it? > > Den > On 18/04/2012, at 9:01, Forrie <forrie@gmail.com> wrote: > >> So, it''s choking on this still at the line with the conditional: >> >> Apr 17 18:58:17 test-system puppet-agent[7590]: Could not retrieve >> catalog from remote server: Error 400 on SERVER: Could not parse for >> environment production: Syntax error at ''{''; expected ''}'' at /etc/ >> puppet/manifests/classes/nagios-client-test.pp:20 on node test- >> system.my-domain.com >> >> The brackets look balanced to me. >> >> >> file { "/usr/local/nagios/libexec": >> require => File[''/usr/local/nagios''], >> ensure => directory, >> owner => ''root'', >> group => ''root'', >> mode => 655, >> recurse => true, >> source => $::architecture { >> /(i386|i586|i686/) => "puppet:///files/32/usr/local/ >> nagios/libexec", >> x86_64 => "puppet:///files/64/usr/local/ >> nagios/libexec", >> } >> } >> >> >> -- >> 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. >> > > -- > 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.-- 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.
Peter Bukowinski
2012-Apr-18 03:13 UTC
Re: [Puppet Users] Case statements in a file directive
Looks like you''re missing a question mark in the selector in your source parameter. It should look like this: source => $::architecture ? { /(i386|i586|i686)/ => "puppet:///files/32/usr/local/nagios/libexec", x86_64 => "puppet:///files/64/usr/local/nagios/libexec", } -- Peter On Apr 17, 2012, at 7:44 PM, Geoff Davis wrote:> Yup, I fat-fingered my response. > > On Apr 17, 2012, at 4:10 PM, Denmat <tu2bgone@gmail.com> wrote: > >>> /(i386|i586|i686/) => >> should be >>> /(i386|i586|i686)/ => >> shouldn''t it? >> >> Den >> On 18/04/2012, at 9:01, Forrie <forrie@gmail.com> wrote: >> >>> So, it''s choking on this still at the line with the conditional: >>> >>> Apr 17 18:58:17 test-system puppet-agent[7590]: Could not retrieve >>> catalog from remote server: Error 400 on SERVER: Could not parse for >>> environment production: Syntax error at ''{''; expected ''}'' at /etc/ >>> puppet/manifests/classes/nagios-client-test.pp:20 on node test- >>> system.my-domain.com >>> >>> The brackets look balanced to me. >>> >>> >>> file { "/usr/local/nagios/libexec": >>> require => File[''/usr/local/nagios''], >>> ensure => directory, >>> owner => ''root'', >>> group => ''root'', >>> mode => 655, >>> recurse => true, >>> source => $::architecture { >>> /(i386|i586|i686/) => "puppet:///files/32/usr/local/ >>> nagios/libexec", >>> x86_64 => "puppet:///files/64/usr/local/ >>> nagios/libexec", >>> } >>> }-- 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.
So there were two gotchas :-) One, my mis-typed / and the other the missing ? in the evaluation ;-) Thanks again, guys, I appreciate the feedback. -- 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.