On Dec 13, 12:31 pm, Kenneth Lo <[email protected]> wrote:
> Searching old archive I find this topic:
>
> http://groups.google.com/group/puppet-users/browse_thread/thread/187e...
>
> I understand that "case statements must be outside of resource
> statements" per that discussion and I understand the usage for the
> selector in-statement solution, however that's just for assignment
> though.
You seem to have a misapprehension here. See below.
> Consider this simple file resource, I just want to have a external
> variable that control whether I need the file in the system:
>
> file { "somefile" :
>
> case ${hasfile} {
> "true": { ensure => present }
> default: { ensure => absent }
> }
> source => "puppet:///somefile",
> owner => "root",
> .
> .
> .
>
> }
>
> Obviously I had a syntax error here because case statement is not
> happy within the resource.
I would write it using a selector, like this:
file { "somefile" :
ensure => ${hasfile} ? {
'true' => present,
default => absent
},
source => "puppet:///somefile",
owner => "root",
}
Others' examples of using an 'if' statement outside the resource are
also fine, but where the desired conditional effect is so localized, I
prefer to localize the conditional itself.
John
--
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.