Skip to content

/ Zope / gocept svn checkins / Archive / 2008 / 2008-12 / SVN: r7350 - in gocept.infrastructure/feature_vm_starting: lib lib/puppet lib/puppet/parser/functions puppet/modules/app_admin/manifests puppet/modules/app_admin/templates puppet/modules/sys_apps/manifests

[ << ] [ >> ]

[ SVN: r7348 - in gocept.infrastructure/feature_vm_s... ] [ SVN: r7366 - gocept.devtools/trunk / Michael ... ]

SVN: r7350 - in gocept.infrastructure/feature_vm_starting: lib lib/puppet lib/puppet/parser/functions puppet/modules/app_admin/manifests puppet/modules/app_admin/templates puppet/modules/sys_apps/manifests
Christian Kauhaus <kc(at)gocept.com>
2008-12-19 13:58:26 [ FULL ]
Author: ckauhaus
Date: Fri Dec 19 13:58:24 2008
New Revision: 7350

Log:
relocated parser functions from puppet/plugins to a separate lib dir which is
independent of the manifests and does not go through the plugin sync


Added:
   gocept.infrastructure/feature_vm_starting/lib/
   gocept.infrastructure/feature_vm_starting/lib/puppet/   (props changed)
      - copied from r7348,
gocept.infrastructure/feature_vm_starting/puppet/plugins/puppet/
  
gocept.infrastructure/feature_vm_starting/lib/puppet/parser/functions/strip_netmask.rb
  
gocept.infrastructure/feature_vm_starting/puppet/modules/app_admin/templates/conf.d_puppetmaster.erb
Modified:
  
gocept.infrastructure/feature_vm_starting/puppet/modules/app_admin/manifests/puppet.pp
  
gocept.infrastructure/feature_vm_starting/puppet/modules/sys_apps/manifests/network_interface.pp

Added:
gocept.infrastructure/feature_vm_starting/lib/puppet/parser/functions/strip_netmask.rb
==============================================================================
--- (empty file)
+++
gocept.infrastructure/feature_vm_starting/lib/puppet/parser/functions/strip_netmask.rb	Fri
Dec 19 13:58:24 2008
(at)(at) -0,0 +1,14 (at)(at)
+# Copyright (c) 2008 gocept gmbh & co. kg
+# See also LICENSE.txt
+
+module Puppet::Parser::Functions
+
+  newfunction(:strip_netmask, :type => :rvalue, :doc => "
+    Return IP address without subnet notation 
+    (e.g. '192.168.1.0/24' => '192.168.1.0').
+  ") do |args|
+    ipaddr = args[0]
+    ipaddr.gsub(/\/[0-9.:]+$/, '')
+  end
+
+end

Modified:
gocept.infrastructure/feature_vm_starting/puppet/modules/app_admin/manifests/puppet.pp
==============================================================================
---
gocept.infrastructure/feature_vm_starting/puppet/modules/app_admin/manifests/puppet.pp	(original)
+++
gocept.infrastructure/feature_vm_starting/puppet/modules/app_admin/manifests/puppet.pp	Fri
Dec 19 13:58:24 2008
(at)(at) -64,8 +64,12 (at)(at)
             content => template("app_admin/puppetmaster.cron.erb"),
             mode => 0711;
         "/etc/puppet/fileserver.conf":
-            content => template("app_admin/fileserver.conf.erb");
-        ["/var/lib/puppet/state", "/var/lib/puppet/hosts"]:
+            content => template("app_admin/fileserver.conf.erb"),
+            notify => Service["puppetmaster"];
+        "/etc/conf.d/puppetmaster":
+            content => template("app_admin/conf.d_puppetmaster.erb"),
+            notify => Service["puppetmaster"];
+        "/var/lib/puppet/state":
             ensure => directory,
             owner => "puppet";
         "/usr/local/bin/update-puppet":
(at)(at) -88,7 +92,7 (at)(at)
         source => "puppet:///app_admin/logrotate_puppet"
     }
 
-    File <<| tag == "puppet_hosts" |>>
+    dump_services { "puppetmaster": }
 
     $snapshot = $sys_portage::portage::snapshot
 

Added:
gocept.infrastructure/feature_vm_starting/puppet/modules/app_admin/templates/conf.d_puppetmaster.erb
==============================================================================
--- (empty file)
+++
gocept.infrastructure/feature_vm_starting/puppet/modules/app_admin/templates/conf.d_puppetmaster.erb	Fri
Dec 19 13:58:24 2008
(at)(at) -0,0 +1,12 (at)(at)
+# Location of PID files
+PUPPETMASTER_PID_DIR="/var/run/puppet"
+
+# Where to log general messages to.
+# Specify syslog to send log messages to the system log.
+#PUPPETMASTER_LOG="syslog"
+
+# You may specify other parameters to the puppetmaster here
+#PUPPETMASTER_EXTRA_OPTS="--noca"
+
+# Load custom parser functions from the correct environment
+export RUBYLIB=/home/puppet/<%= environment %>/lib

Modified:
gocept.infrastructure/feature_vm_starting/puppet/modules/sys_apps/manifests/network_interface.pp
==============================================================================
---
gocept.infrastructure/feature_vm_starting/puppet/modules/sys_apps/manifests/network_interface.pp	(original)
+++
gocept.infrastructure/feature_vm_starting/puppet/modules/sys_apps/manifests/network_interface.pp	Fri
Dec 19 13:58:24 2008
(at)(at) -22,11 +22,11 (at)(at)
 
         if $ip4_addr {
             sys_apps::check_ip4 { $iface:
-                ip4 => $ip4_addr,
+                ip4_addr => $ip4_addr,
                 extra => $extra_alias
             }
             sys_apps::etc_hosts { $fullname:
-                ip4 => $ip4_addr,
+                ip4_addr => $ip4_addr,
                 canonical_alias => $canonical_alias
             }
         }
(at)(at) -75,29 +75,29 (at)(at)
 }
 
 
-define sys_apps::check_ip4($ip4, $extra=false) {
+define sys_apps::check_ip4($ip4_addr, $extra=false) {
     $iface = $name
-    $ip4_addr = strip_netmask($ip4)
+    $addr = strip_netmask($ip4_addr)
 
     # Define ping checks. We assume that the Nagios server has connectivity
     # to all interfaces
     net_analyzer::service { "ping $iface":
-        command => "icmp!-w 100,20% -c 200,40% -H $ip4_addr"
+        command => "icmp!-w 100,20% -c 200,40% -H $addr"
     }
 
     # Check nameserver
-    if public_address($ip4_addr) {
-        $reverse = dns_reverse($ip4_addr)
+    if public_address($addr) {
+        $reverse = dns_reverse($addr)
         net_analyzer::service {
             "DNS $fullname/A":
-                command => "dig!-H ns1 -T A -l $fullname -a $ip4_addr";
-            "DNS $ip4_addr/PTR":
+                command => "dig!-H ns1 -T A -l $fullname -a $addr";
+            "DNS $addr/PTR":
                 command => "dig!-H ns1 -T PTR -l $reverse -a $fullname";
         }
         if $extra {
             net_analyzer::service {
                 "DNS $extra/A":
-                    command => "dig!-H ns1 -T A -l $extra -a $ip4_addr"
+                    command => "dig!-H ns1 -T A -l $extra -a $addr"
             }
         }
     }
(at)(at) -131,14 +131,15 (at)(at)
 }
 
 
-define sys_apps::etc_hosts($ip4=false, $ip6=false,
+define sys_apps::etc_hosts($ip4_addr=false, $ip6=false,
                            $canonical_alias=false) {
-    $ip4_addr = strip_netmask($ip4)
-    (at)(at)host { $name: ip => $ip4_addr }
+    $addr = strip_netmask($ip4_addr)
+
+    (at)(at)host { $name: ip => $addr }
 
     if $canonical_alias {
         (at)(at)host { $canonical_alias:
-            ip => $ip4_addr,
+            ip => $addr,
             alias => $hostname
         }
     }

SVN: r7352 - in gocept.infrastructure/feature_vm_starting: lib/puppet/parser/functions puppet/manifests puppet/modules/app_admin/templates puppet/modules/sys_portage/manifests puppet/modules/sys_portage/templates
Christian Kauhaus <kc(at)gocept.com>
2008-12-19 14:16:19 [ FULL ]
Author: ckauhaus
Date: Fri Dec 19 14:16:18 2008
New Revision: 7352

Log:
Complemented register_service definition with lookup_service function


Added:
  
gocept.infrastructure/feature_vm_starting/lib/puppet/parser/functions/lookup_service.rb
Modified:
  
gocept.infrastructure/feature_vm_starting/lib/puppet/parser/functions/public_address.rb
   gocept.infrastructure/feature_vm_starting/puppet/manifests/defines.pp
  
gocept.infrastructure/feature_vm_starting/puppet/modules/app_admin/templates/puppet.conf.erb
  
gocept.infrastructure/feature_vm_starting/puppet/modules/sys_portage/manifests/portage.pp
  
gocept.infrastructure/feature_vm_starting/puppet/modules/sys_portage/templates/make.conf.erb

Added:
gocept.infrastructure/feature_vm_starting/lib/puppet/parser/functions/lookup_service.rb
==============================================================================
--- (empty file)
+++
gocept.infrastructure/feature_vm_starting/lib/puppet/parser/functions/lookup_service.rb	Fri
Dec 19 14:16:18 2008
(at)(at) -0,0 +1,19 (at)(at)
+# Copyright (c) 2008 gocept gmbh & co. kg
+# See also LICENSE.txt
+
+
+module Puppet::Parser::Functions
+
+    newfunction(:lookup_service, :type => :rvalue, :doc => "\
+            Find service address by name. Complements the register_service and
+            dump_services definitions. Returns nil if the service has not been
+            registered before.") do |args|
+        service = args[0]
+        begin
+            File.read("/var/lib/puppet/services/#{service}").chomp
+        rescue Errno::ENOENT
+            nil
+        end
+    end
+
+end

Modified:
gocept.infrastructure/feature_vm_starting/lib/puppet/parser/functions/public_address.rb
==============================================================================
---
gocept.infrastructure/feature_vm_starting/lib/puppet/parser/functions/public_address.rb	(original)
+++
gocept.infrastructure/feature_vm_starting/lib/puppet/parser/functions/public_address.rb	Fri
Dec 19 14:16:18 2008
(at)(at) -6,13 +6,12 (at)(at)
 
 module Puppet::Parser::Functions
 
-    # Determine public/non-public state of a given IP address.
-    # See RFC3330 for IPv4 and RFC4291 for IPv6.
     newfunction(:public_address, :type => :rvalue, :doc => "\
             Decide if the given address (IPv4 or IPv6) is public unicast."
             ) do |args|
         return false unless args[0]
         addr = IPAddr.new args[0]
+        # See RFC3330 for IPv4 and RFC4291 for IPv6.
         if addr.ipv4?
             case addr
             when IPAddr.new('0.0.0.0/8') then return false

Modified: gocept.infrastructure/feature_vm_starting/puppet/manifests/defines.pp
==============================================================================
---
gocept.infrastructure/feature_vm_starting/puppet/manifests/defines.pp	(original)
+++ gocept.infrastructure/feature_vm_starting/puppet/manifests/defines.pp	Fri
Dec 19 14:16:18 2008
(at)(at) -28,18 +28,18 (at)(at)
 }
 
 
-# Service registration for singleton services. The location defaults to the
+# Service registration for singleton services. The address defaults to the
 # (unqualified) host name, but can be any string like an URL.
-define register_service($location=false) {
+define register_service($address=false) {
     $servicename = $title
 
-    $_location = $location ? {
+    $_address = $address ? {
         false => $hostname,
-        default => $location
+        default => $address
     }
 
     (at)(at)file { "/var/lib/puppet/services/$servicename":
-        content => "$_location\n",
+        content => "$_address\n",
         tag => "services"
     }
 }

Modified:
gocept.infrastructure/feature_vm_starting/puppet/modules/app_admin/templates/puppet.conf.erb
==============================================================================
---
gocept.infrastructure/feature_vm_starting/puppet/modules/app_admin/templates/puppet.conf.erb	(original)
+++
gocept.infrastructure/feature_vm_starting/puppet/modules/app_admin/templates/puppet.conf.erb	Fri
Dec 19 14:16:18 2008
(at)(at) -37,7 +37,7 (at)(at)
     # Where Puppet should look for facts.  Multiple directories should
     # be colon-separated, like normal PATH variables.
     # The default value is '$vardir/facts'.
-    factpath = $vardir/lib/facter
+    factpath = $libdir/facter
 
 <% for path in envpaths.split %>
 [<%= File.basename(path) %>]

Modified:
gocept.infrastructure/feature_vm_starting/puppet/modules/sys_portage/manifests/portage.pp
==============================================================================
---
gocept.infrastructure/feature_vm_starting/puppet/modules/sys_portage/manifests/portage.pp	(original)
+++
gocept.infrastructure/feature_vm_starting/puppet/modules/sys_portage/manifests/portage.pp	Fri
Dec 19 14:16:18 2008
(at)(at) -42,6 +42,7 (at)(at)
     $portage_module = "$puppet_root/$environment/puppet/modules/sys_portage"
     $portage_md5 = portage_md5(
         $portage_module, "$portage_chost $portage_cflags $portage_profile")
+    $binhost = lookup_service("binhost.$architecture.$location")
 
     file {
         "/etc/make.conf":

Modified:
gocept.infrastructure/feature_vm_starting/puppet/modules/sys_portage/templates/make.conf.erb
==============================================================================
---
gocept.infrastructure/feature_vm_starting/puppet/modules/sys_portage/templates/make.conf.erb	(original)
+++
gocept.infrastructure/feature_vm_starting/puppet/modules/sys_portage/templates/make.conf.erb	Fri
Dec 19 14:16:18 2008
(at)(at) -17,14 +17,7 (at)(at)
 LINGUAS="de en"
 
 # System update related settings
-<%
-binhost = nil
-begin
-    binhost =
File.read("/var/lib/puppet/services/binhost.#{architecture}.#{location}").chomp
-rescue Errno::ENOENT
-    nil
-end
-if binhost and binhost != hostname -%>
+<% if binhost and binhost != hostname -%>
 PORTAGE_BINHOST="ftp://anonymous:portage(at)<%= binhost
%>/pub/packages/<%= portage_md5 %>/All"
 EMERGE_DEFAULT_OPTS="--getbinpkg"
 PKGDIR="/var/tmp/portage/packages"

MailBoxer