]> gitweb.fluxo.info Git - puppet-concat.git/commitdiff
Style guideline fixes
authorErik Dalén <dalen@spotify.com>
Wed, 14 Mar 2012 17:02:43 +0000 (18:02 +0100)
committerErik Dalén <dalen@spotify.com>
Tue, 24 Apr 2012 14:53:20 +0000 (16:53 +0200)
Comply better with puppet community style guidelines.

Change-Id: Ie1782d266539b1a8f9890b2ade77280011aa22aa

manifests/fragment.pp
manifests/init.pp
manifests/setup.pp

index 97c0d9c8c63c218ecff179437cfd5bcc9ddc9956..943bf6713566ab41f215d6f5c619d0b6d5a88a87 100644 (file)
 #   - group     Owner of the file
 #   - backup    Controls the filebucketing behavior of the final file and
 #               see File type reference for its use.  Defaults to 'puppet'
-define concat::fragment($target, $content='', $source='', $order=10, $ensure = "present", $mode = 0644, $owner = $::id, $group = $concat::setup::root_group, $backup = "puppet") {
-    $safe_name = regsubst($name, '/', '_', 'G')
-    $safe_target_name = regsubst($target, '/', '_', 'G')
-    $concatdir = $concat::setup::concatdir
-    $fragdir = "${concatdir}/${safe_target_name}"
+define concat::fragment($target, $content='', $source='', $order=10, $ensure = 'present', $mode = '0644', $owner = $::id, $group = $concat::setup::root_group, $backup = 'puppet') {
+  $safe_name = regsubst($name, '/', '_', 'G')
+  $safe_target_name = regsubst($target, '/', '_', 'G')
+  $concatdir = $concat::setup::concatdir
+  $fragdir = "${concatdir}/${safe_target_name}"
 
-    # if content is passed, use that, else if source is passed use that
-    # if neither passed, but $ensure is in symlink form, make a symlink
-    case $content {
-        "": {
-                case $source {
-                        "": {
-                                case $ensure {
-                                    "", "absent", "present", "file", "directory": {
-                                        crit("No content, source or symlink specified")
-                                    }
-                                }
-                            }
-                   default: { File{ source => $source } }
-                }
+  # if content is passed, use that, else if source is passed use that
+  # if neither passed, but $ensure is in symlink form, make a symlink
+  case $content {
+    '': {
+      case $source {
+        '': {
+          case $ensure {
+            '', 'absent', 'present', 'file', 'directory': {
+              crit('No content, source or symlink specified')
             }
-        default: { File{ content => $content } }
+          }
+        }
+        default: { File{ source => $source } }
+      }
     }
+    default: { File{ content => $content } }
+  }
 
-    file{"${fragdir}/fragments/${order}_${safe_name}":
-        mode   => $mode,
-        owner  => $owner,
-        group  => $group,
-        ensure => $ensure,
-        backup => $backup,
-        alias  => "concat_fragment_${name}",
-        notify => Exec["concat_${target}"]
-    }
+  file{"${fragdir}/fragments/${order}_${safe_name}":
+    ensure => $ensure,
+    mode   => $mode,
+    owner  => $owner,
+    group  => $group,
+    backup => $backup,
+    alias  => "concat_fragment_${name}",
+    notify => Exec["concat_${target}"]
+  }
 }
-
-# vi:tabstop=4:expandtab:ai
index 1e6aee045851876485508fc0fcb1bd0bc31fd078..48aeec3c25fe3f5575142dce981552ccfe4d3ad5 100644 (file)
 # ALIASES:
 #  - The exec can notified using Exec["concat_/path/to/file"] or Exec["concat_/path/to/directory"]
 #  - The final file can be referened as File["/path/to/file"] or File["concat_/path/to/file"]
-define concat($mode = 0644, $owner = $::id, $group = $concat::setup::root_group, $warn = "false", $force = "false", $backup = "puppet", $gnu = undef, $order="alpha") {
-    $safe_name   = regsubst($name, '/', '_', 'G')
-    $concatdir   = $concat::setup::concatdir
-    $version     = $concat::setup::majorversion
-    $fragdir     = "${concatdir}/${safe_name}"
-    $concat_name = "fragments.concat.out"
-    $default_warn_message = '# This file is managed by Puppet. DO NOT EDIT.'
+define concat($mode = '0644', $owner = $::id, $group = $concat::setup::root_group, $warn = false, $force = false, $backup = 'puppet', $gnu = undef, $order='alpha') {
+  $safe_name   = regsubst($name, '/', '_', 'G')
+  $concatdir   = $concat::setup::concatdir
+  $version     = $concat::setup::majorversion
+  $fragdir     = "${concatdir}/${safe_name}"
+  $concat_name = 'fragments.concat.out'
+  $default_warn_message = '# This file is managed by Puppet. DO NOT EDIT.'
 
-    case $warn {
-        'true',true,yes,on:   { $warnmsg = "$default_warn_message" }
-        'false',false,no,off: { $warnmsg = "" }
-        default:              { $warnmsg = "$warn" }
-    }
+  case $warn {
+    'true',true,yes,on:   { $warnmsg = $default_warn_message }
+    'false',false,no,off: { $warnmsg = '' }
+    default:              { $warnmsg = $warn }
+  }
 
-    $warnmsg_escaped = regsubst($warnmsg, "'", "'\\\\''", 'G')
-    $warnflag = $warnmsg_escaped ? {
-        ''      => '',
-        default => "-w '$warnmsg_escaped'"
-    }
+  $warnmsg_escaped = regsubst($warnmsg, "'", "'\\\\''", 'G')
+  $warnflag = $warnmsg_escaped ? {
+    ''      => '',
+    default => "-w '${warnmsg_escaped}'"
+  }
 
-    case $force {
-        'true',true,yes,on: { $forceflag = "-f" }
-        'false',false,no,off: { $forceflag = "" }
-        default: { fail("Improper 'force' value given to concat: $force") }
-    }
+  case $force {
+    'true',true,yes,on: { $forceflag = '-f' }
+    'false',false,no,off: { $forceflag = '' }
+    default: { fail("Improper 'force' value given to concat: ${force}") }
+  }
 
-    case $order {
-        numeric: { $orderflag = "-n" }
-        alpha: { $orderflag = "" }
-        default: { fail("Improper 'order' value given to concat: $order") }
-    }
+  case $order {
+    numeric: { $orderflag = '-n' }
+    alpha: { $orderflag = '' }
+    default: { fail("Improper 'order' value given to concat: ${order}") }
+  }
 
-    File{
-        owner  => $::id,
-        group  => $group,
-        mode   => $mode,
-        backup => $backup
-    }
+  File{
+    owner  => $::id,
+    group  => $group,
+    mode   => $mode,
+    backup => $backup
+  }
 
-    file{$fragdir:
-            ensure   => directory;
+  file{$fragdir:
+    ensure   => directory;
 
-         "${fragdir}/fragments":
-            ensure   => directory,
-            recurse  => true,
-            purge    => true,
-            force    => true,
-            ignore   => [".svn", ".git", ".gitignore"],
-            source   => $version ? {
-                            24      => "puppet:///concat/null",
-                            default => undef,
-                        },
-            notify   => Exec["concat_${name}"];
+  "${fragdir}/fragments":
+    ensure   => directory,
+    recurse  => true,
+    purge    => true,
+    force    => true,
+    ignore   => ['.svn', '.git', '.gitignore'],
+    source   => $version ? {
+      24      => 'puppet:///concat/null',
+      default => undef,
+    },
+    notify   => Exec["concat_${name}"];
 
-         "${fragdir}/fragments.concat":
-            ensure   => present;
+  "${fragdir}/fragments.concat":
+    ensure   => present;
 
-         "${fragdir}/${concat_name}":
-            ensure   => present;
+  "${fragdir}/${concat_name}":
+    ensure   => present;
 
-         $name:
-            source   => "${fragdir}/${concat_name}",
-            owner    => $owner,
-            group    => $group,
-            checksum => md5,
-            mode     => $mode,
-            ensure   => present,
-            alias    => "concat_${name}";
-    }
+  $name:
+    ensure   => present,
+    source   => "${fragdir}/${concat_name}",
+    owner    => $owner,
+    group    => $group,
+    checksum => md5,
+    mode     => $mode,
+    alias    => "concat_${name}";
+  }
 
-    exec{"concat_${name}":
-        notify    => File[$name],
-        subscribe => File[$fragdir],
-        alias     => "concat_${fragdir}",
-        require   => [ File[$fragdir], File["${fragdir}/fragments"], File["${fragdir}/fragments.concat"] ],
-        unless    => "${concat::setup::concatdir}/bin/concatfragments.sh -o ${fragdir}/${concat_name} -d ${fragdir} -t ${warnflag} ${forceflag} ${orderflag}",
-        command   => "${concat::setup::concatdir}/bin/concatfragments.sh -o ${fragdir}/${concat_name} -d ${fragdir} ${warnflag} ${forceflag} ${orderflag}",
-    }
-    if $::id == 'root' {
-      Exec["concat_${name}"]{
-        user      => root,
-        group     => $group,
-      }
+  exec{"concat_${name}":
+    notify    => File[$name],
+    subscribe => File[$fragdir],
+    alias     => "concat_${fragdir}",
+    require   => [ File[$fragdir], File["${fragdir}/fragments"], File["${fragdir}/fragments.concat"] ],
+    unless    => "${concat::setup::concatdir}/bin/concatfragments.sh -o ${fragdir}/${concat_name} -d ${fragdir} -t ${warnflag} ${forceflag} ${orderflag}",
+    command   => "${concat::setup::concatdir}/bin/concatfragments.sh -o ${fragdir}/${concat_name} -d ${fragdir} ${warnflag} ${forceflag} ${orderflag}",
+  }
+  if $::id == 'root' {
+    Exec["concat_${name}"]{
+      user      => root,
+      group     => $group,
     }
+  }
 }
index 584f58ade187e66559e4344e5058a91d644c347b..ce3f7ea8c4e8f9368161e04ad24602583ec366f7 100644 (file)
 #
 # It also copies out the concatfragments.sh file to ${concatdir}/bin
 class concat::setup {
-    $id = $::id
-    $root_group = $id ? {
-      root => 0,
-      default => $id
-    }
-    $concatdir = $::concat_basedir
-    $majorversion = regsubst($::puppetversion, '^[0-9]+[.]([0-9]+)[.][0-9]+$', '\1')
+  $id = $::id
+  $root_group = $id ? {
+    root    => 0,
+    default => $id
+  }
+  $concatdir = $::concat_basedir
+  $majorversion = regsubst($::puppetversion, '^[0-9]+[.]([0-9]+)[.][0-9]+$', '\1')
 
-    file{"${concatdir}/bin/concatfragments.sh":
-            owner  => $id,
-            group  => $root_group,
-            mode   => 755,
-            source => $majorversion ? {
-                        24      => "puppet:///concat/concatfragments.sh",
-                        default => "puppet:///modules/concat/concatfragments.sh"
-                      };
+  file{"${concatdir}/bin/concatfragments.sh":
+    owner  => $id,
+    group  => $root_group,
+    mode   => '0755',
+    source => $majorversion ? {
+      24      => 'puppet:///concat/concatfragments.sh',
+      default => 'puppet:///modules/concat/concatfragments.sh'
+    };
 
-         [ $concatdir, "${concatdir}/bin" ]:
-            ensure => directory,
-            owner  => $id,
-            group  => $root_group,
-            mode   => '0750';
+  [ $concatdir, "${concatdir}/bin" ]:
+    ensure => directory,
+    owner  => $id,
+    group  => $root_group,
+    mode   => '0750';
 
-        ## Old versions of this module used a different path.
-        '/usr/local/bin/concatfragments.sh':
-            ensure => absent;
-    }
+  ## Old versions of this module used a different path.
+  '/usr/local/bin/concatfragments.sh':
+    ensure => absent;
+  }
 }
-
-# vi:tabstop=4:expandtab:ai