On Oct 11, 2013, at 5:48 AM, Jakub Bittner <[email protected]> wrote:
> Hello,
>
> I created puppet class and I want the file operation to be executed on all
> servers but not on server with hostname "'server1.domain.com". I tried this
> class, but it does not work. Is there any other way? Thanks
>
>
> class test {
> if $hostname != 'server1.domain.com' {
> file { "/etc/ntp.conf":
> owner => root,
> group => root,
> mode => 644,
> source => "puppet:///files/server/ntp.conf",
> }
> }
> }
>
You have a couple errors in your if statement. For comparing a literal string,
you need to use double-equals in your test:
if $hostname == 'server1.domain.com' { ... }
For a regex match, you'd use the equal-tilde:
if $hostname =~ /^server/ { ... }
To negate a match, you put the not (!) in front of the entire comparison, e.g.
if ! $hostname == 'server1.domain.com' { ... }
I like to add parentheses around my comparisons for visual clarity:
if ( $hostname =~ /^server/ ) and ! ( $virtual == 'vmware' ) { ... }
--
Peter Bukowinski
--
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/puppet-users.
For more options, visit https://groups.google.com/groups/opt_out.