Correction:

  #  subscribe  => $highavailability ? {
  #    true  => File["myapp"],
  #    false => $hostname ? {
  #      /$m[0-9]*/ => File["myapp1"],
  #      /$s[0-9]*/ => File["myapp2"],
  #    },
  #  },

On Mar 30, 12:20 pm, trey85stang <[email protected]> wrote:
> sweet,  got it fixed by using selectors instead of case....  Im going
> to add one more question to this thread since it appears to be syntax
> related as well...  perhaps my logic is just a little fubar
>
> but,  I have this module that the services complains that it cannot
> find the file dependencies:
>
> class apparmor {
>   if $highavailability == "true" {
>     file { "myapp":
>       owner   => "root",
>       group   => "root",
>       mode    => 640,
>       path    => "/etc/apparmor.d/path.to.myapp",
>       source  => "puppet://modules/apparmor/path.to.myapp",
>       require => Package["libapparmor","apparmor-profiles","perl-
> libapparmor","yast2-apparmor"],
>     }
>   } else {
>       case $hostname {
>         /$m[0-9]*$/: {
>           file { "myapp1":
>             owner   => "root",
>             group   => "root",
>             mode    => 640,
>             path    => "/etc/apparmor.d/path.to.myapp1",
>             source  => "puppet://modules/apparmor/path.to.myapp1",
>             require => Package["libapparmor","apparmor-profiles","perl-
> libapparmor","yast2-apparmor"],
>           }
>         }
>         /$s[0-9]*$/: {
>           file { "myapp2":
>            owner   => "root",
>            group   => "root",
>            mode    => 640,
>            path    => "/etc/apparmor.d/path.to.myapp2",
>            source  => "puppet://modules/apparmor/path.to.myapp2",
>            require => Package["libapparmor","apparmor-profiles","perl-
> libapparmor","yast2-apparmor"],
>         }
>       }
>     }
>   }
>   service { apparmor:
>     ensure     => running,
>   #  subscribe  => $highavailability ? {
>   #    true  => File["myapp_profile"],
>   #    false => $hostname ? {
>   #      /$m[0-9]*/ => File["myapp1_apparmor"],
>   #      /$s[0-9]*/ => File["myapp2_apparmor"],
>   #    },
>   #  },
>     hasrestart => true,
>     hasstatus  => true,
>     restart    => "/etc/init.d/apparmor restart",
>     status     => "/etc/init.d/apparmor status",
>   }
>
> }
>
> The commented out part under service is the section I am having
> trouble with;  as it always compalins that it cannot find
> File["myapp"];  the logic works but but the file type is never found.
> With that section commented out the respective files transfer to their
> respective location.
>
> Any idea's on this one?  I seem to be having problems with my logic
> building in these modules.
>
> On Mar 30, 9:32 am, Martin Alfke <[email protected]> wrote:
>
>
>
>
>
>
>
> > On Mar 30, 2011, at 4:03 PM, trey85stang wrote:
>
> > > I am getting a syntax error in a module and I'm not sure why...
>
> > > Anyone care to take a look?
>
> > > class audit {
> > >  file { "/etc/audit.rules":
> > >    owner => "root",
> > >    group => "root",
> > >    mode  => 640,
> > >    case $operatingsystemrelease {
> > >      "10.2": { path   => "/etc/audit.rules",
> > >        source => "puppet:///modules/audit/audit.rules.sles10",
> > >        require => Package["audit-libs","audit"]
> > >      }
> > >      "11.1": { path   => "/etc/audit/audit.rules",
> > >        source => "puppet:///modules/audit/audit.rules.sles11",
> > >        require => Package["audit-libs","audit","audit-audispd-
> > > plugins"]
> > >      }
> > >    }
> > >  }
> > > }
>
> > You need to use a selector for each resource item:
> > path => $operatingsystemrelease ?  {
> >   "10.2" => "/etc/audit.rules",
> >   "11.1" => "/etc/audit/audit.rules",
> >   default => undef,},
>
> > source => $operatingsystemrelease ? {
> >   "10.2" => "puppet...",
> >   "11.1" => "puppet...",
> >   default => ...,
>
> > },
>
> > another option would be to separate this to multiple manifests (one for 
> > each os-release) and include based upon os-release number.
>
> > > error on client is:
> > > err: Could not retrieve catalog from remote server: Error 400 on
> > > SERVER: Syntax error at 'case'; expected '}' at /etc/puppet/shared/
> > > modules/audit/manifests/init.pp:6 on node node.example.com
>
> > > Also,  is it possible to do regex's in the case statement?
>
> > > i.e"
> > >  "/^10\.[0-3]*/": { stuff here }
> > >  "/^11\.[0-3]*/": { other stuff }
>
> > Regexp are possible, But you have to take care of upper/lower letters 
> > yourself.
>
> > > Thanks
>
> > > --
> > > You received this message because you are subscribed to the Google Groups 
> > > "Puppet Users" group.
> > > To post to this group, send email to [email protected].
> > > To unsubscribe from this group, send email to 
> > > [email protected].
> > > For more options, visit this group 
> > > athttp://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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.

Reply via email to