dev/provisioning/modules/concat/manifests/setup.pp
changeset 28 b0b56e0f8c7f
equal deleted inserted replaced
27:a2342f26c9de 28:b0b56e0f8c7f
       
     1 # === Class: concat::setup
       
     2 #
       
     3 # Sets up the concat system. This is a private class.
       
     4 #
       
     5 # [$concatdir]
       
     6 #   is where the fragments live and is set on the fact concat_basedir.
       
     7 #   Since puppet should always manage files in $concatdir and they should
       
     8 #   not be deleted ever, /tmp is not an option.
       
     9 #
       
    10 # It also copies out the concatfragments.{sh,rb} file to ${concatdir}/bin
       
    11 #
       
    12 class concat::setup {
       
    13   if $caller_module_name != $module_name {
       
    14     warning("${name} is deprecated as a public API of the ${module_name} module and should no longer be directly included in the manifest.")
       
    15   }
       
    16 
       
    17   if $::concat_basedir {
       
    18     $concatdir = $::concat_basedir
       
    19   } else {
       
    20     fail ('$concat_basedir not defined. Try running again with pluginsync=true on the [master] and/or [main] section of your node\'s \'/etc/puppet/puppet.conf\'.')
       
    21   }
       
    22 
       
    23   # owner,group and mode of fragment files (on windows owner and access rights should
       
    24   # be inherited from concatdir and not explicitly set to avoid problems)
       
    25   $fragment_owner = $::osfamily ? { 'windows' => undef, default => $::id }
       
    26   $fragment_mode  = $::osfamily ? { 'windows' => undef, default => '0640' }
       
    27   # test on gid fact availability to support older facter versions
       
    28   if defined('$gid') and $::gid and $::osfamily != 'Windows' {
       
    29     $fragment_group = $::gid
       
    30   } else {
       
    31     $fragment_group = undef
       
    32   }
       
    33 
       
    34   $script_name = 'concatfragments.rb'
       
    35 
       
    36   $script_path = "${concatdir}/bin/${script_name}"
       
    37 
       
    38   $default_owner = $::osfamily ? { 'windows' => undef, default => $::id }
       
    39 
       
    40   $default_group = $default_owner ? { 'root' => '0', default => undef }
       
    41 
       
    42   $script_mode = $::osfamily ? { 'windows' => undef, default => '0755' }
       
    43 
       
    44   $script_command = $::osfamily? {
       
    45     'windows' => "ruby.exe '${script_path}'",
       
    46     'openbsd' => "/usr/local/bin/ruby21 '${script_path}'",
       
    47     'freebsd' => "/usr/local/bin/ruby '${script_path}'",
       
    48     default   => $script_path
       
    49   }
       
    50 
       
    51   file { $script_path:
       
    52     ensure => file,
       
    53     owner  => $default_owner,
       
    54     group  => $default_group,
       
    55     mode   => $script_mode,
       
    56     source => "puppet:///modules/concat/${script_name}",
       
    57   }
       
    58 
       
    59   file { [ $concatdir, "${concatdir}/bin" ]:
       
    60     ensure => directory,
       
    61     owner  => $default_owner,
       
    62     group  => $default_group,
       
    63     mode   => '0755',
       
    64   }
       
    65 }