From 3f225ced9b02ddf31ac43120d0597485b8769ee6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20M=E4kinen?= Date: Thu, 20 Aug 2009 00:24:14 +0300 Subject: [PATCH] Import rest of modules. --- apcupsd/manifests/init.pp | 14 + backuppc/files/default.pl | 1 + backuppc/files/hosts.in | 56 ++++ backuppc/manifests/init.pp | 102 +++++++ custom/manifests/init.pp | 20 ++ custom/plugins/facter/puppet_ssldir.rb | 8 + .../puppet/provider/service/openbsd.rb | 106 +++++++ dhcp/files/dhcpdump.py | 52 ++++ dhcp/manifests/init.pp | 75 +++++ git/files/gitweb_config.perl | 3 + git/manifests/init.pp | 37 +++ inetd/manifests/init.pp | 91 ++++++ iscsi/files/targets.conf | 5 + iscsi/manifests/init.pp | 98 ++++++ iscsi/templates/tid.conf.erb | 4 + kerberos/manifests/init.pp | 44 +++ kerberos/templates/keytab.erb | 73 +++++ munin/files/munin.conf.in | 78 +++++ munin/files/plugin-conf/vmware | 2 + munin/files/plugins/vmware_vms | 56 ++++ munin/files/plugins/vmware_vms,v | 79 +++++ munin/manifests/init.pp | 141 +++++++++ munin/templates/munin-node.conf.erb | 44 +++ ssh/manifests/init.pp | 23 ++ ssh/templates/ssh_known_hosts.erb | 66 +++++ sysctl/manifests/init.pp | 31 ++ time/manifests/init.pp | 11 + vmware/files/scripts/vmware-console | 93 ++++++ vmware/files/scripts/vmware-list | 28 ++ vmware/files/scripts/vmware-register | 16 + vmware/files/scripts/vmware-start | 18 ++ vmware/files/scripts/vmware-stop | 33 +++ vmware/files/scripts/vmware-suspend | 18 ++ vmware/files/scripts/vmware-unregister | 18 ++ vmware/files/scripts/vmware.sh | 113 +++++++ vmware/manifests/guest.pp | 34 +++ vmware/manifests/init.pp | 3 + vmware/manifests/server.pp | 280 ++++++++++++++++++ vmware/plugins/puppet/type/vmware_config.rb | 82 +++++ 39 files changed, 2056 insertions(+) create mode 100644 apcupsd/manifests/init.pp create mode 100644 backuppc/files/default.pl create mode 100644 backuppc/files/hosts.in create mode 100644 backuppc/manifests/init.pp create mode 100644 custom/manifests/init.pp create mode 100644 custom/plugins/facter/puppet_ssldir.rb create mode 100644 custom/plugins/puppet/provider/service/openbsd.rb create mode 100755 dhcp/files/dhcpdump.py create mode 100644 dhcp/manifests/init.pp create mode 100644 git/files/gitweb_config.perl create mode 100644 git/manifests/init.pp create mode 100644 inetd/manifests/init.pp create mode 100644 iscsi/files/targets.conf create mode 100644 iscsi/manifests/init.pp create mode 100644 iscsi/templates/tid.conf.erb create mode 100644 kerberos/manifests/init.pp create mode 100644 kerberos/templates/keytab.erb create mode 100644 munin/files/munin.conf.in create mode 100644 munin/files/plugin-conf/vmware create mode 100755 munin/files/plugins/vmware_vms create mode 100755 munin/files/plugins/vmware_vms,v create mode 100644 munin/manifests/init.pp create mode 100644 munin/templates/munin-node.conf.erb create mode 100644 ssh/manifests/init.pp create mode 100644 ssh/templates/ssh_known_hosts.erb create mode 100644 sysctl/manifests/init.pp create mode 100644 time/manifests/init.pp create mode 100755 vmware/files/scripts/vmware-console create mode 100755 vmware/files/scripts/vmware-list create mode 100755 vmware/files/scripts/vmware-register create mode 100755 vmware/files/scripts/vmware-start create mode 100755 vmware/files/scripts/vmware-stop create mode 100755 vmware/files/scripts/vmware-suspend create mode 100755 vmware/files/scripts/vmware-unregister create mode 100644 vmware/files/scripts/vmware.sh create mode 100644 vmware/manifests/guest.pp create mode 100644 vmware/manifests/init.pp create mode 100644 vmware/manifests/server.pp create mode 100644 vmware/plugins/puppet/type/vmware_config.rb diff --git a/apcupsd/manifests/init.pp b/apcupsd/manifests/init.pp new file mode 100644 index 0000000..70a6e6e --- /dev/null +++ b/apcupsd/manifests/init.pp @@ -0,0 +1,14 @@ + +class apcupsd { + + package { "apcupsd": + ensure => installed, + } + + service { "apcupsd": + ensure => running, + enable => true, + require => Package["apcupsd"], + } + +} diff --git a/backuppc/files/default.pl b/backuppc/files/default.pl new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/backuppc/files/default.pl @@ -0,0 +1 @@ + diff --git a/backuppc/files/hosts.in b/backuppc/files/hosts.in new file mode 100644 index 0000000..8484e8b --- /dev/null +++ b/backuppc/files/hosts.in @@ -0,0 +1,56 @@ +#============================================================= -*-perl-*- +# +# Host file list for BackupPC. +# +# DESCRIPTION +# +# This file lists all the hosts that should be backed up by +# BackupPC. +# +# Each line in the hosts file contains three fields, separated +# by white space: +# +# - The host name. If this host is a static IP address this +# must the machine's IP host name (ie: something that can +# be looked up using nslookup or DNS). If this is a DHCP +# host then the host name must be the netbios name of the +# machine. It is possible to have a host name that contains +# spaces, but that is discouraged. Escape a space with "\", eg: +# +# craigs\ pc +# +# - DHCP flag. Set to 0 if this is a static IP address host +# or if the machine can be found using nmblookup. Otherwise, +# if the client can only be found by looking through the DHCP +# pool then set this to 1. +# +# - User name (unix login/email name) of the user who "owns" +# or uses this machine. This is the user who will be sent +# email about this machine, and this user will have permission +# to stop/start/browse/restore backups for this host. This +# user name must match the name the user authenticates with +# via apache. +# +# - Optional additional user names (comma separated, no white space) of +# users who are also allowed to stop/start/browse/restore backups +# for this client via the CGI interface. These users are not sent +# email. These do not need to be valid email names; they simply +# need to match the name the user authenticates with via apache. +# +# AUTHOR +# Craig Barratt +# +# COPYRIGHT +# Copyright (C) 2001 Craig Barratt +# +# See http://backuppc.sourceforge.net. +# +#======================================================================== + +# +# The first non-comment non-empty line gives the field names and should +# not be edited!! +# +host dhcp user moreUsers # <--- do not edit this line +#farside 0 craig jill,jeff # <--- example static IP host entry +#larson 1 bill # <--- example DHCP host entry diff --git a/backuppc/manifests/init.pp b/backuppc/manifests/init.pp new file mode 100644 index 0000000..b452a79 --- /dev/null +++ b/backuppc/manifests/init.pp @@ -0,0 +1,102 @@ + +define backuppc::manualclient($ensure = "present", $operatingsystem = "default") { + + @@file { "/etc/BackupPC/pc/${name}.pl": + ensure => "${ensure}", + source => [ "puppet:///files/backuppc/${fqdn}.pl", + "puppet:///files/backuppc/${operatingsystem}.pl", + "puppet:///files/backuppc/default.pl", + "puppet:///backuppc/default.pl", ], + mode => 0640, + owner => root, + group => backuppc, + tag => "backuppc", + require => File["/etc/BackupPC/pc"], + notify => Exec["generate-backuppc-hosts"], + } + +} + +class backuppc::client { + + backuppc::manualclient { "${fqdn}": + ensure => present, + operatingsystem => "${operatingsystem}", + } + +} + +class backuppc::server { + + package { "BackupPC": + ensure => installed, + } + + file { [ "/export/backuppc", + "/export/backuppc/cpool", + "/export/backuppc/pc", + "/export/backuppc/pool", + "/export/backuppc/trash", ]: + ensure => directory, + mode => 0750, + owner => backuppc, + group => root, + require => Package["BackupPC"], + } + file { "/srv/backuppc": + ensure => "/export/backuppc", + require => File["/export/backuppc"], + } + file { "/var/lib/BackupPC": + ensure => "/srv/backuppc", + force => true, + require => File["/srv/backuppc"], + } + + file { "/etc/BackupPC/config.pl": + ensure => present, + source => "puppet:///files/backuppc/config.pl", + mode => 0640, + owner => root, + group => backuppc, + require => Package["BackupPC"], + notify => Service["backuppc"], + } + + file { "/etc/BackupPC/hosts.in": + ensure => present, + source => [ "puppet:///files/backuppc/hosts.in", + "puppet:///backuppc/hosts.in", ], + mode => 0644, + owner => root, + group => backuppc, + require => Package["BackupPC"], + notify => Exec["generate-backuppc-hosts"], + } + + file { "/etc/BackupPC/pc": + ensure => directory, + purge => true, + mode => 0750, + owner => root, + group => backuppc, + require => Package["BackupPC"], + } + + exec { "generate-backuppc-hosts": + command => '(cat /etc/BackupPC/hosts.in ; find /etc/BackupPC/pc/ -name \*.pl -exec basename {} .pl \; | sed -e "s/$/ 0 adm/") > /etc/BackupPC/hosts', + path => "/bin:/usr/bin:/sbin:/usr/sbin", + refreshonly => true, + require => File["/etc/BackupPC/hosts.in"], + notify => Service["backuppc"], + } + + File <<| tag == "backuppc" |>> + + service { "backuppc": + ensure => running, + enable => true, + require => Package["BackupPC"], + } + +} diff --git a/custom/manifests/init.pp b/custom/manifests/init.pp new file mode 100644 index 0000000..4b37c4c --- /dev/null +++ b/custom/manifests/init.pp @@ -0,0 +1,20 @@ + +class custom { + + file { "/srv": + ensure => directory, + mode => 0755, + owner => root, + group => $operatingsystem ? { + OpenBSD => wheel, + default => root, + }, + } + + if $kernel == OpenBSD { + Service { + provider => openbsd, + } + } + +} diff --git a/custom/plugins/facter/puppet_ssldir.rb b/custom/plugins/facter/puppet_ssldir.rb new file mode 100644 index 0000000..202301c --- /dev/null +++ b/custom/plugins/facter/puppet_ssldir.rb @@ -0,0 +1,8 @@ +require 'puppet' + +Facter.add('puppet_ssldir') do + setcode do + Puppet.parse_config + Puppet.settings.value('ssldir') + end +end diff --git a/custom/plugins/puppet/provider/service/openbsd.rb b/custom/plugins/puppet/provider/service/openbsd.rb new file mode 100644 index 0000000..1e25883 --- /dev/null +++ b/custom/plugins/puppet/provider/service/openbsd.rb @@ -0,0 +1,106 @@ +# Manage OpenBSD services. Enable/disable using /etc/rc.local, /etc/rc.conf.local + +Puppet::Type.type(:service).provide :openbsd, :parent => :base do + desc "OpenBSD service management." + + defaultfor :operatingsystem => [:openbsd] + + @@rclocal = "/etc/rc.local" + @@rcconf = "/etc/rc.conf" + @@rcconflocal = "/etc/rc.conf.local" + + def getrcconf + File.readlines(@@rcconf).each { |line| + if line =~ /^#{@resource[:name]}_flags=.*/ + return "#{@resource[:name]}_flags" + elsif line =~ /^#{@resource[:name]}=.*/ + return @resource[:name] + end + } + return false + end + + def enabled? + if not defined? @resource[:start] + raise Puppet::Error, + "Services must specify a start command or a binary" + end + flag = getrcconf() + if flag + File.readlines(@@rcconflocal).each { |line| + line = line.strip.split(/=/, 2) + next unless line[0] == flag + if line[1] == "NO" + return :false + end + return :true + } + return :false + else + inlocal = false + File.readlines(@@rclocal).each { |line| + line = line.strip + if not inlocal + next unless \ + line == "# Add your local startup actions here." + inlocal = true + else + if line == "echo '.'" + inlocal = false + break + end + next unless line =~ /^echo -n \" #{@resource[:name]}\" ; .*/ + return :true + end + } + return :false + end + end + + def enable + flag = getrcconf() + if flag + newdata = "" + File.readlines(@@rcconflocal).each { |line| + if line.strip.split(/=/, 2)[0] == flag + next + else + newdata += line + end + } + if flag == @resource[:name] + newdata += "%s=YES\n" % flag + elsif flag == "#{@resource[:name]}_flags" + if @resource[:start] != nil and @resource[:binary] != nil + args = @resource[:start][/^#{@resource[:binary]} (.*)/, 1] + end + newdata += "%s=\"%s\"\n" % [flag, args] + end + f = File.open(@@rcconflocal, "w") + f.write(newdata) + f.close + else + newdata = "" + inlocal = false + File.readlines(@@rclocal).each { |line| + if line == "# Add your local startup actions here.\n" + newdata += line + newdata += "echo -n \" %s\" ; %s\n" % [@resource[:name], + @resource[:start]] + next + end + newdata += line + } + f = File.open(@@rclocal, "w") + f.write(newdata) + f.close + end + return :true + end + + def disable + print "disabling #{@resource[:name]}\n" + return :true + end + +end \ No newline at end of file diff --git a/dhcp/files/dhcpdump.py b/dhcp/files/dhcpdump.py new file mode 100755 index 0000000..4493269 --- /dev/null +++ b/dhcp/files/dhcpdump.py @@ -0,0 +1,52 @@ +#!/usr/bin/env python + +import re +import sys +from subprocess import Popen, PIPE + + +def main(): + if len(sys.argv) < 2: + print >>sys.stderr, 'Usage: %s