Merge tag 'xinetd-0.1.99.0' into HEAD

This commit is contained in:
Eugene Kirpichov 2012-11-08 18:24:16 +04:00
commit ed20b50b4d
18 changed files with 332 additions and 0 deletions

View File

@ -0,0 +1,3 @@
fixtures:
symlinks:
"xinetd": "#{source_dir}"

View File

@ -0,0 +1,5 @@
source :rubygems
puppetversion = ENV.key?('PUPPET_VERSION') ? "= #{ENV['PUPPET_VERSION']}" : ['>= 2.7']
gem 'puppet', puppetversion
gem 'puppetlabs_spec_helper', '>= 0.1.0'

4
deployment/puppet/xinetd/.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
metadata.json
pkg/
.DS_Store
*.swp

View File

@ -0,0 +1,9 @@
* 2012-06-07 1.1.0
- Add port and bind options to services
- make services deletable
1.0.1 - 20100812
* added documentation
1.0.0 - 20100624
* initial release

View File

@ -0,0 +1,17 @@
Xinetd Puppet Module. Copyright (C) 2010 Garrett Honeycutt
Garrett Honeycutt can be contacted at: contact@garretthoneycutt.com.
This program and entire repository is free software; you can
redistribute it and/or modify it under the terms of the GNU
General Public License version 2 as published by the Free Software
Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

View File

@ -0,0 +1,8 @@
name 'puppetlabs-xinetd'
version '1.1.0'
source 'https://github.com/puppetlabs/puppetlabs-xinetd'
author 'Puppet Labs'
license 'Apache License 2.0'
summary 'Puppet Labs Xinetd Module'
description 'Puppet module to configure xinetd services'
project_page 'https://github.com/puppetlabs/puppetlabs-xinetd'

View File

@ -0,0 +1,43 @@
xinetd
This is the xinetd module.
# Definition: xinetd::service
#
# sets up a xinetd service
# all parameters match up with xinetd.conf(5) man page
#
# Parameters:
# $cps - optional
# $flags - optional
# $per_source - optional
# $port - required - determines the service port
# $server - required - determines the program to execute for this service
# $server_args - optional
# $disable - optional - defaults to "no"
# $socket_type - optional - defaults to "stream"
# $protocol - optional - defaults to "tcp"
# $user - optional - defaults to "root"
# $group - optional - defaults to "root"
# $instances - optional - defaults to "UNLIMITED"
# $wait - optional - based on $protocol will default to "yes" for udp and "no" for tcp
# $service_type - optional - type setting in xinetd
#
# Actions:
# setups up a xinetd service by creating a file in /etc/xinetd.d/
#
# Requires:
# $server must be set
#
# Sample Usage:
# # setup tftp service
# xinetd::service {"tftp":
# port => "69",
# server => "/usr/sbin/in.tftpd",
# server_args => "-s $base",
# socket_type => "dgram",
# protocol => "udp",
# cps => "100 2",
# flags => "IPv4",
# per_source => "11",
# } # xinetd::service

View File

@ -0,0 +1,2 @@
require 'rubygems'
require 'puppetlabs_spec_helper/rake_tasks'

View File

@ -0,0 +1,52 @@
# This file is being maintained by Puppet.
# DO NOT EDIT
#
# This is the master xinetd configuration file. Settings in the
# default section will be inherited by all service configurations
# unless explicitly overridden in the service configuration. See
# xinetd.conf in the man pages for a more detailed explanation of
# these attributes.
defaults
{
# The next two items are intended to be a quick access place to
# temporarily enable or disable services.
#
# enabled =
# disabled =
# Define general logging characteristics.
log_type = SYSLOG daemon info
log_on_failure = HOST
log_on_success = PID HOST DURATION EXIT
# Define access restriction defaults
#
# no_access =
# only_from =
# max_load = 0
cps = 50 10
instances = 50
per_source = 10
# Address and networking defaults
#
# bind =
# mdns = yes
v6only = no
# setup environmental attributes
#
# passenv =
groups = yes
umask = 002
# Generally, banners are not used. This sets up their global defaults
#
# banner =
# banner_fail =
# banner_success =
}
includedir /etc/xinetd.d

View File

@ -0,0 +1,27 @@
# Class: xinetd
#
# This module manages xinetd
#
# Sample Usage:
# xinetd::service { 'rsync':
# port => '873',
# server => '/usr/bin/rsync',
# server_args => '--daemon --config /etc/rsync.conf',
# }
#
class xinetd {
package { 'xinetd': }
file { '/etc/xinetd.conf':
source => 'puppet:///modules/xinetd/xinetd.conf',
}
service { 'xinetd':
ensure => running,
enable => true,
restart => '/etc/init.d/xinetd reload',
require => [ Package['xinetd'],
File['/etc/xinetd.conf'] ],
}
}

View File

@ -0,0 +1,83 @@
# Definition: xinetd::service
#
# sets up a xinetd service
# all parameters match up with xinetd.conf(5) man page
#
# Parameters:
# $port - required - determines the service port
# $server - required - determines the executable for this service
# $ensure - optional - defaults to 'present'
# $cps - optional
# $flags - optional
# $per_source - optional
# $server_args - optional
# $log_on_failure - optional - may contain any combination of
# 'HOST', 'USERID', 'ATTEMPT'
# $disable - optional - defaults to 'no'
# $socket_type - optional - defaults to 'stream'
# $protocol - optional - defaults to 'tcp'
# $user - optional - defaults to 'root'
# $group - optional - defaults to 'root'
# $instances - optional - defaults to 'UNLIMITED'
# $wait - optional - based on $protocol
# will default to 'yes' for udp and 'no' for tcp
# $bind - optional - defaults to '0.0.0.0'
# $service_type - optional - type setting in xinetd
# may contain any combinarion of 'RPC', 'INTERNAL',
# 'TCPMUX/TCPMUXPLUS', 'UNLISTED'
#
# Actions:
# setups up a xinetd service by creating a file in /etc/xinetd.d/
#
# Requires:
# $server must be set
# $port must be set
#
# Sample Usage:
# # setup tftp service
# xinetd::service { 'tftp':
# port => '69',
# server => '/usr/sbin/in.tftpd',
# server_args => '-s $base',
# socket_type => 'dgram',
# protocol => 'udp',
# cps => '100 2',
# flags => 'IPv4',
# per_source => '11',
# } # xinetd::service
#
define xinetd::service (
$port,
$server,
$ensure = present,
$cps = undef,
$flags = undef,
$log_on_failure = undef,
$per_source = undef,
$server_args = undef,
$disable = 'no',
$socket_type = 'stream',
$protocol = 'tcp',
$user = 'root',
$group = 'root',
$instances = 'UNLIMITED',
$wait = undef,
$bind = '0.0.0.0',
$service_type = undef
) {
if $wait {
$mywait = $wait
} else {
$mywait = $protocol ? {
tcp => 'no',
udp => 'yes'
}
}
file { "/etc/xinetd.d/${name}":
ensure => $ensure,
content => template('xinetd/service.erb'),
notify => Service['xinetd'],
}
}

View File

@ -0,0 +1,9 @@
require 'spec_helper'
describe 'xinetd' do
it {
should contain_package('xinetd')
should contain_file('/etc/xinetd.conf')
should contain_service('xinetd').with_restart('/etc/init.d/xinetd reload')
}
end

View File

@ -0,0 +1,41 @@
require 'spec_helper'
describe 'xinetd::service' do
let :default_params do
{
'port' => '80',
'server' => 'httpd'
}
end
let :title do
"httpd"
end
describe 'with default ensure' do
let :params do
default_params
end
it {
should contain_file('/etc/xinetd.d/httpd').with_ensure('present')
}
end
describe 'with ensure=present' do
let :params do
default_params.merge({'ensure' => 'present'})
end
it {
should contain_file('/etc/xinetd.d/httpd').with_ensure('present')
}
end
describe 'with ensure=absent' do
let :params do
default_params.merge({'ensure' => 'absent'})
end
it {
should contain_file('/etc/xinetd.d/httpd').with_ensure('absent')
}
end
end

View File

@ -0,0 +1,6 @@
--format
s
--colour
--loadby
mtime
--backtrace

View File

@ -0,0 +1 @@
require 'puppetlabs_spec_helper/module_spec_helper'

View File

@ -0,0 +1,21 @@
# This file is being maintained by Puppet.
# DO NOT EDIT
service <%= name %>
{
port = <%= port %>
disable = <%= disable %>
socket_type = <%= socket_type %>
protocol = <%= protocol %>
wait = <%= mywait %>
user = <%= user %>
group = <%= group %>
server = <%= server %>
bind = <%= bind %>
<% if server_args != :undef %> server_args = <%= server_args %><% end %>
<% if per_source != :undef %> per_source = <%= per_source %><% end %>
<% if log_on_failure != :undef %> log_on_failure += <%= log_on_failure %><% end %>
<% if cps != :undef %> cps = <%= cps %><% end %>
<% if flags != :undef %> flags = <%= flags %><% end %>
<% if service_type != :undef %> type = <%= service_type %><% end %>
}

View File

@ -0,0 +1 @@
include xinetd