]> gitweb.fluxo.info Git - puppet-shorewall.git/commitdiff
fix for new style for 2.7
authormh <mh@immerda.ch>
Wed, 6 Jun 2012 04:19:34 +0000 (01:19 -0300)
committermh <mh@immerda.ch>
Wed, 6 Jun 2012 04:19:34 +0000 (01:19 -0300)
README
manifests/base.pp
manifests/centos.pp
manifests/debian.pp
manifests/init.pp
manifests/managed_file.pp
manifests/routestopped.pp
manifests/rules/jetty/http.pp
manifests/rules/out/ibackup.pp
manifests/rules/puppet.pp
templates/debian_default.erb

diff --git a/README b/README
index feac7fc85ce9feefe5fa4224abf5e0a269e11741..77a845c88b0ac7eb59651613af0c54df52425de3 100644 (file)
--- a/README
+++ b/README
@@ -21,8 +21,9 @@ Example
 Example from node.pp:
 
 node xy {
-       $shorewall_startup="0"  # create shorewall ruleset but don't startup
-       include config::site-shorewall
+       class{'config::site_shorewall':
+         startup => "0"  # create shorewall ruleset but don't startup
+  }
        shorewall::rule {
                'incoming-ssh': source => 'all', destination => '$FW',  action  => 'SSH/ACCEPT', order => 200;
                'incoming-puppetmaster': source => 'all', destination => '$FW',  action  => 'Puppetmaster/ACCEPT', order => 300;
@@ -32,62 +33,60 @@ node xy {
 }
 
 
-class config::site-shorewall {
-        include shorewall
-
-       # If you want logging:
-        #shorewall::params {
-        #       'LOG':            value => 'debug';
-        #      'MAILSERVER':     value => $shorewall_mailserver;
-        #}
-
-        shorewall::zone {'net':
-                type => 'ipv4';
-        }
-
-        shorewall::rule_section { 'NEW':
-                order => 100;
-        }
-
-        case $shorewall_rfc1918_maineth {
-                '': {$shorewall_rfc1918_maineth = true }
-        }
-
-        case $shorewall_main_interface {
-                '': { $shorewall_main_interface = 'eth0' }
-        }
-
-        shorewall::interface {"$shorewall_main_interface":
-                zone    => 'net',
-                rfc1918  => $shorewall_rfc1918_maineth,
-                options => 'tcpflags,blacklist,nosmurfs';
-        }
-
-        shorewall::policy {
-                'fw-to-fw':
-                  sourcezone              =>      '$FW',
-                  destinationzone         =>      '$FW',
-                  policy                  =>      'ACCEPT',
-                  order                   =>      100;
-                'fw-to-net':
-                sourcezone              =>      '$FW',
-                destinationzone         =>      'net',
-                policy                  =>      'ACCEPT',
-                shloglevel              =>      '$LOG',
-                order                   =>      110;
-                'net-to-fw':
-                sourcezone              =>      'net',
-                destinationzone         =>      '$FW',
-                policy                  =>      'DROP',
-                shloglevel              =>      '$LOG',
-                order                   =>      120;
-        }       
+class config::site_shorewall($startup = '1') {
+  class{'shorewall':
+    startup => $startup
+  }
+
+  # If you want logging:
+  #shorewall::params {
+  # 'LOG':  value => 'debug';
+  #}
+
+  shorewall::zone {'net':
+    type => 'ipv4';
+  }
+
+  shorewall::rule_section { 'NEW':
+    order => 100;
+  }
+
+  $shorewall_main_interface hiera('shorewall_main_interface','eth0')
+  shorewall::interface { $shorewall_main_interface:
+    zone    => 'net',
+    rfc1918  => hiera('shorewall_rfc1918_maineth',true)
+    options => 'tcpflags,blacklist,nosmurfs';
+  }
+
+  shorewall::policy {
+    'fw-to-fw':
+      sourcezone              =>      '$FW',
+      destinationzone         =>      '$FW',
+      policy                  =>      'ACCEPT',
+      order                   =>      100;
+    'fw-to-net':
+      sourcezone              =>      '$FW',
+      destinationzone         =>      'net',
+      policy                  =>      'ACCEPT',
+      shloglevel              =>      '$LOG',
+      order                   =>      110;
+    'net-to-fw':
+      sourcezone              =>      'net',
+      destinationzone         =>      '$FW',
+      policy                  =>      'DROP',
+      shloglevel              =>      '$LOG',
+      order                   =>      120;
+  }       
 
         
-        # default Rules : ICMP 
-        shorewall::rule { 'allicmp-to-host': source => 'all', destination => '$FW', order  => 200, action  => 'AllowICMPs/ACCEPT';
-        }
+  # default Rules : ICMP 
+  shorewall::rule {
+    'allicmp-to-host':
+      source => 'all',
+      destination => '$FW',
+      order  => 200,
+      action  => 'AllowICMPs/ACCEPT';
+  }
 }
 
 
index d3fdec778967a5d64b700d76eefc6a738ccb81b2..709f4b7ee115ddb4714a2d077386dcce65e2e984 100644 (file)
@@ -8,14 +8,14 @@ class shorewall::base {
       '/etc/shorewall/shorewall.conf':
         # use OS specific defaults, but use Default if no other is found
         source => [
-            "puppet:///modules/site-shorewall/${fqdn}/shorewall.conf.${operatingsystem}",
-            "puppet:///modules/site-shorewall/${fqdn}/shorewall.conf",
-            "puppet:///modules/site-shorewall/shorewall.conf.${operatingsystem}.${lsbdistcodename}",
-            "puppet:///modules/site-shorewall/shorewall.conf.${operatingsystem}",
-            "puppet:///modules/site-shorewall/shorewall.conf",
-            "puppet:///modules/shorewall/shorewall.conf.${operatingsystem}.${lsbdistcodename}",
-            "puppet:///modules/shorewall/shorewall.conf.${operatingsystem}.${lsbmajdistrelease}",
-            "puppet:///modules/shorewall/shorewall.conf.${operatingsystem}",
+            "puppet:///modules/site_shorewall/${::fqdn}/shorewall.conf.${::operatingsystem}",
+            "puppet:///modules/site_shorewall/${::fqdn}/shorewall.conf",
+            "puppet:///modules/site_shorewall/shorewall.conf.${::operatingsystem}.${::lsbdistcodename}",
+            "puppet:///modules/site_shorewall/shorewall.conf.${::operatingsystem}",
+            "puppet:///modules/site_shorewall/shorewall.conf",
+            "puppet:///modules/shorewall/shorewall.conf.${::operatingsystem}.${::lsbdistcodename}",
+            "puppet:///modules/shorewall/shorewall.conf.${::operatingsystem}.${::lsbmajdistrelease}",
+            "puppet:///modules/shorewall/shorewall.conf.${::operatingsystem}",
             "puppet:///modules/shorewall/shorewall.conf"
         ],
         require => Package[shorewall],
index c61e03c3b7d7c96a788cc06ec3a7fa495f439195..7968b6984c58932e1be105b1798857f42e0b4335 100644 (file)
@@ -1,5 +1,5 @@
 class shorewall::centos inherits shorewall::base {
-  if $lsbmajdistrelease == '6' {
+  if $::lsbmajdistrelease == '6' {
     # workaround for
     # http://comments.gmane.org/gmane.comp.security.shorewall/26991
     file{'/etc/shorewall/params':
index eab54a22ee77205279dd2f132beca0f47c92c0ce..c7ed607715e74ebafa68fe77ebeeb706b9f36e44 100644 (file)
@@ -1,15 +1,11 @@
 class shorewall::debian inherits shorewall::base {
-    case $shorewall_startup {
-      '': { $shorewall_startup = "1" }
-    }
-    file{'/etc/default/shorewall':
-        #source => "puppet:///modules/shorewall/debian/default",
-        content => template("shorewall/debian_default.erb"),
-        require => Package['shorewall'],
-        notify => Service['shorewall'],
-        owner => root, group => 0, mode => 0644;
-    }
-    Service['shorewall']{
-        status => '/sbin/shorewall status'
-    }
+  file{'/etc/default/shorewall':
+    content => template("shorewall/debian_default.erb"),
+    require => Package['shorewall'],
+    notify => Service['shorewall'],
+    owner => root, group => 0, mode => 0644;
+  }
+  Service['shorewall']{
+    status => '/sbin/shorewall status'
+  }
 }
index 7c622220a13c0bd118b2e145ec0e67325a2c9d44..17ff12d9229624aa535f1c9ea4bb5992f4507889 100644 (file)
@@ -1,17 +1,19 @@
-class shorewall { 
+class shorewall(
+  $startup = '1'
+) {
 
-  case $operatingsystem {
+  case $::operatingsystem {
     gentoo: { include shorewall::gentoo }
     debian: { include shorewall::debian }
     centos: { include shorewall::centos }
     ubuntu: {
-    case $lsbdistcodename {
+    case $::lsbdistcodename {
       karmic: { include shorewall::ubuntu::karmic }
       default: { include shorewall::debian }
       }
     }
     default: {
-      notice "unknown operatingsystem: $operatingsystem" 
+      notice "unknown operatingsystem: ${::operatingsystem}"
                  include shorewall::base
     }
   }
@@ -38,7 +40,7 @@ class shorewall {
   shorewall::managed_file { rfc1918: }
   # See http://www.shorewall.net/3.0/Documentation.htm#Routestopped
   shorewall::managed_file { routestopped: }
-  # See http://www.shorewall.net/3.0/Documentation.htm#Variables 
+  # See http://www.shorewall.net/3.0/Documentation.htm#Variables
   shorewall::managed_file { params: }
   # http://www.shorewall.net/manpages/shorewall-providers.html
   shorewall::managed_file { providers: }
index 0beb22126f9d7acb151b9f1dc241da40add379bd..d564daa7ef27baa56cf732820d433d9c6d935734 100644 (file)
@@ -1,17 +1,17 @@
 define shorewall::managed_file () {
-  concat{ "/etc/shorewall/puppet/$name":
+  concat{ "/etc/shorewall/puppet/${name}":
     notify => Service['shorewall'],
     require => File['/etc/shorewall/puppet'],
     owner => root, group => 0, mode => 0600;
-  }       
+  }
   concat::fragment {
     "${name}-header":
       source => "puppet:///modules/shorewall/boilerplate/${name}.header",
-      target => "/etc/shorewall/puppet/$name",
+      target => "/etc/shorewall/puppet/${name}",
       order => '000';
     "${name}-footer":
       source => "puppet:///modules/shorewall/boilerplate/${name}.footer",
-      target => "/etc/shorewall/puppet/$name",
+      target => "/etc/shorewall/puppet/${name}",
       order => '999';
-  }       
-} 
+  }
+}
index 0b53a1b0b23bc1cc6fd188bee4911cb4d520da08..cd39762d2d7748eb8a63fa62523a53a2385162ea 100644 (file)
@@ -1,14 +1,10 @@
 define shorewall::routestopped(
-    $interface = '',
+    $interface = $name,
     $host = '-',
     $options = '',
     $order='100'
 ){
-    $real_interface = $interface ? { 
-        '' => $name,
-        default => $interface,
-    }   
     shorewall::entry{"routestopped-${order}-${name}":
-        line => "${real_interface} ${host} ${options}",
-    }           
+        line => "${interface} ${host} ${options}",
+    }
 }
index be19622cadd8179c79f046e40342bae2cef4fa90..4c0652bec86351b7a6558d907ed21ea17310c5d8 100644 (file)
@@ -2,7 +2,7 @@ class shorewall::rules::jetty::http {
     # dnat
     shorewall::rule {
         'dnat-http-to-jetty':
-            destination     =>      "net:${ipaddress}:8080",
+            destination     =>      "net:${::ipaddress}:8080",
             destinationport =>      '80',
             source          =>      'net', proto => 'tcp', order => 140, action => 'DNAT';
     }
index ec12c8b2a07255e20e72af7d3e16a3f252cbdcd3..48714affcc8869272b778031d8543e8ed8c9d057 100644 (file)
@@ -1,10 +1,9 @@
-class shorewall::rules::out::ibackup {
-    case $shorewall_ibackup_host {
-      '': { fail("You need to define \$shorewall_ibackup_host for ${fqdn}") }
-    }
+class shorewall::rules::out::ibackup(
+  $backup_host = hiera('shorewall_ibackup_host')
+) {
     shorewall::rule { 'me-net-tcp_backupssh':
         source          => '$FW',
-        destination     => "net:${shorewall_ibackup_host}",
+        destination     => "net:${backup_host}",
         proto           => 'tcp',
         destinationport => 'ssh',
         order           => 240,
index b53c726e52062e911898908c7084a73431b20de6..c6fc09b3e1b1d7009697a4b40e0ad47543ba5411 100644 (file)
@@ -1,16 +1,11 @@
-class shorewall::rules::puppet {
-  case $shorewall_puppetserver {
-    '': { $shorewall_puppetserver = "puppet.${domain}" } 
-  }
-  case $shorewall_puppetserver_port {
-    '': { $shorewall_puppetserver_port = '8140' }
-  }
-  case $shorewall_puppetserver_signport {
-    '': { $shorewall_puppetserver_signport = '8141' }
-  }
+class shorewall::rules::puppet(
+  $puppetserver = hiera('shorewall_puppetserver',"puppet.${domain}"),
+  $puppetserver_port = hiera('shorewall_puppetserver_port',8140) ,
+  $puppetserver_signport = hiera('shorewall_puppetserver_signport',8141) ,
+) {
   shorewall::params{
-        'PUPPETSERVER':             value => $shorewall_puppetserver;
-        'PUPPETSERVER_PORT':        value => $shorewall_puppetserver_port;
-        'PUPPETSERVER_SIGN_PORT':   value => $shorewall_puppetserver_signport;
+        'PUPPETSERVER':             value => $puppetserver;
+        'PUPPETSERVER_PORT':        value => $puppetserver_port;
+        'PUPPETSERVER_SIGN_PORT':   value => $puppetserver_signport;
   }
 }
index 96621f5ba7bf9d8006682e9fcbf41ca1e0038058..ec64cbe0e36a67719c5dc38b29e0fa3d44286d78 100644 (file)
@@ -3,11 +3,7 @@
 
 # This file is brought to you by puppet
 
-<% if shorewall_startup == "0" -%>
-startup=0
-<% else -%>
-startup=1
-<% end -%>
+startup=<%= scope.lookupvar('shorewall::startup') == "0" ? '0' : '1' %>
 
 # if your Shorewall configuration requires detection of the ip address of a ppp
 # interface, you must list such interfaces in "wait_interface" to get Shorewall to