Re: [Puppet Users] syntax error with case statment; in file type.

2011-03-30 Thread Martin Alfke

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 puppet-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> puppet-users+unsubscr...@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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.



[Puppet Users] syntax error with case statment; in file type.

2011-03-30 Thread trey85stang
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"]
  }
}
  }
}

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 }

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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.