FAQ
Can anyone tell me why this is legal:

      file { "/etc/cron.d":
         owner => "root",
         group => "root",
         mode => $operatingsystem ? {
            'Solaris' => "0755",
            default => "0700",
         }
       }


...And yet if I have any resource attributes below the "mode" selector
statement, it will not parse?

(Am I doing the right thing by having a selector in my file resource? I
have a large amount of files to validate, and attributes change for many of
the files, depending on the OS.)




--
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 puppet-users+unsubscribe@googlegroups.com.
To post to this group, send email to puppet-users@googlegroups.com.
Visit this group at http://groups.google.com/group/puppet-users.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

  • Steven VanDevender at Aug 5, 2013 at 6:12 pm
    root writes:
      >
    Can anyone tell me why this is legal: >
    file { "/etc/cron.d":
    owner => "root",
    group => "root",
    mode => $operatingsystem ? {
    'Solaris' => "0755",
    default => "0700",
    }
    }
      >
      >
    ...And yet if I have any resource attributes below the "mode" selector
    statement, it will not parse?
    No comma after the conditional? Like this:

              mode => $operatingsystem ? {
                 'Solaris' => "0755",
                 default => "0700",
              },

    All resource attributes use comma as a separator. You can optionally
    leave off the final comma (although style recommendations suggest you
    should always end an attribute specification with a comma, mainly so
    that you don't have to remember to add it if you add additional
    attribute specifications).
    (Am I doing the right thing by having a selector in my file resource? I
    have a large amount of files to validate, and attributes change for many of
    the files, depending on the OS.)
    That is certainly one way to manage the OS-specific differences in your
    resources. If you have a lot of things that are always mode 755 in one
    OS and mode 700 in another, it may be somewhat more concise to declare a
    variable and use that:

    $dirmode = $operatingsystem ? {
      "Solaris" => 0755,
      default => 0700,
    }

    ...

      file { "/etc/cron.d":
       owner => "root",
       group => "root",
       mode => $dirmode,
      }

    --
    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 puppet-users+unsubscribe@googlegroups.com.
    To post to this group, send email to puppet-users@googlegroups.com.
    Visit this group at http://groups.google.com/group/puppet-users.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Root at Aug 8, 2013 at 12:00 pm
    This of course was the answer, thanks. It did not look "right" to me to
    have that comma after the closing bracket, but that is what the language
    requires.
    On Monday, August 5, 2013 2:12:38 PM UTC-4, Steven VanDevender wrote:



    No comma after the conditional? Like this:

    mode => $operatingsystem ? {
    'Solaris' => "0755",
    default => "0700",
    },

    All resource attributes use comma as a separator. You can optionally
    leave off the final comma (although style recommendations suggest you
    should always end an attribute specification with a comma, mainly so
    that you don't have to remember to add it if you add additional
    attribute specifications).
    (Am I doing the right thing by having a selector in my file resource? I
    have a large amount of files to validate, and attributes change for many of
    the files, depending on the OS.)
    That is certainly one way to manage the OS-specific differences in your
    resources. If you have a lot of things that are always mode 755 in one
    OS and mode 700 in another, it may be somewhat more concise to declare a
    variable and use that:

    $dirmode = $operatingsystem ? {
    "Solaris" => 0755,
    default => 0700,
    }

    ...

    file { "/etc/cron.d":
    owner => "root",
    group => "root",
    mode => $dirmode,
    }
    --
    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 puppet-users+unsubscribe@googlegroups.com.
    To post to this group, send email to puppet-users@googlegroups.com.
    Visit this group at http://groups.google.com/group/puppet-users.
    For more options, visit https://groups.google.com/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppuppet-users @
categoriespuppet
postedAug 5, '13 at 6:02p
activeAug 8, '13 at 12:00p
posts3
users2
websitepuppetlabs.com

2 users in discussion

Root: 2 posts Steven VanDevender: 1 post

People

Translate

site design / logo © 2022 Grokbase