diff --git a/deployment/puppet/xinetd/.fixtures.yml b/deployment/puppet/xinetd/.fixtures.yml new file mode 100644 index 0000000000..3affff371e --- /dev/null +++ b/deployment/puppet/xinetd/.fixtures.yml @@ -0,0 +1,3 @@ +fixtures: + symlinks: + "xinetd": "#{source_dir}" diff --git a/deployment/puppet/xinetd/.gemfile b/deployment/puppet/xinetd/.gemfile new file mode 100644 index 0000000000..9aad840c0a --- /dev/null +++ b/deployment/puppet/xinetd/.gemfile @@ -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' diff --git a/deployment/puppet/xinetd/.gitignore b/deployment/puppet/xinetd/.gitignore new file mode 100644 index 0000000000..c0a345d5c2 --- /dev/null +++ b/deployment/puppet/xinetd/.gitignore @@ -0,0 +1,4 @@ +metadata.json +pkg/ +.DS_Store +*.swp diff --git a/deployment/puppet/xinetd/CHANGELOG b/deployment/puppet/xinetd/CHANGELOG new file mode 100644 index 0000000000..1d15e60efe --- /dev/null +++ b/deployment/puppet/xinetd/CHANGELOG @@ -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 diff --git a/deployment/puppet/xinetd/LICENSE b/deployment/puppet/xinetd/LICENSE new file mode 100644 index 0000000000..863fe90b69 --- /dev/null +++ b/deployment/puppet/xinetd/LICENSE @@ -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 diff --git a/deployment/puppet/xinetd/Modulefile b/deployment/puppet/xinetd/Modulefile new file mode 100644 index 0000000000..f9ad266408 --- /dev/null +++ b/deployment/puppet/xinetd/Modulefile @@ -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' diff --git a/deployment/puppet/xinetd/README b/deployment/puppet/xinetd/README new file mode 100644 index 0000000000..3a98af5501 --- /dev/null +++ b/deployment/puppet/xinetd/README @@ -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 diff --git a/deployment/puppet/xinetd/Rakefile b/deployment/puppet/xinetd/Rakefile new file mode 100644 index 0000000000..14f1c24622 --- /dev/null +++ b/deployment/puppet/xinetd/Rakefile @@ -0,0 +1,2 @@ +require 'rubygems' +require 'puppetlabs_spec_helper/rake_tasks' diff --git a/deployment/puppet/xinetd/files/xinetd.conf b/deployment/puppet/xinetd/files/xinetd.conf new file mode 100644 index 0000000000..3dfd4c94cb --- /dev/null +++ b/deployment/puppet/xinetd/files/xinetd.conf @@ -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 + diff --git a/deployment/puppet/xinetd/manifests/init.pp b/deployment/puppet/xinetd/manifests/init.pp new file mode 100644 index 0000000000..16589ebd18 --- /dev/null +++ b/deployment/puppet/xinetd/manifests/init.pp @@ -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'] ], + } +} diff --git a/deployment/puppet/xinetd/manifests/service.pp b/deployment/puppet/xinetd/manifests/service.pp new file mode 100644 index 0000000000..5761dd6443 --- /dev/null +++ b/deployment/puppet/xinetd/manifests/service.pp @@ -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'], + } +} diff --git a/deployment/puppet/xinetd/spec/classes/xinetd_init_spec.rb b/deployment/puppet/xinetd/spec/classes/xinetd_init_spec.rb new file mode 100644 index 0000000000..167e7532ad --- /dev/null +++ b/deployment/puppet/xinetd/spec/classes/xinetd_init_spec.rb @@ -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 diff --git a/deployment/puppet/xinetd/spec/defines/xinetd_service_spec.rb b/deployment/puppet/xinetd/spec/defines/xinetd_service_spec.rb new file mode 100644 index 0000000000..01901fb350 --- /dev/null +++ b/deployment/puppet/xinetd/spec/defines/xinetd_service_spec.rb @@ -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 diff --git a/deployment/puppet/xinetd/spec/fixtures/manifests/site.pp b/deployment/puppet/xinetd/spec/fixtures/manifests/site.pp new file mode 100644 index 0000000000..e69de29bb2 diff --git a/deployment/puppet/xinetd/spec/spec.opts b/deployment/puppet/xinetd/spec/spec.opts new file mode 100644 index 0000000000..91cd6427ed --- /dev/null +++ b/deployment/puppet/xinetd/spec/spec.opts @@ -0,0 +1,6 @@ +--format +s +--colour +--loadby +mtime +--backtrace diff --git a/deployment/puppet/xinetd/spec/spec_helper.rb b/deployment/puppet/xinetd/spec/spec_helper.rb new file mode 100644 index 0000000000..2c6f56649a --- /dev/null +++ b/deployment/puppet/xinetd/spec/spec_helper.rb @@ -0,0 +1 @@ +require 'puppetlabs_spec_helper/module_spec_helper' diff --git a/deployment/puppet/xinetd/templates/service.erb b/deployment/puppet/xinetd/templates/service.erb new file mode 100644 index 0000000000..03b2bf7d0e --- /dev/null +++ b/deployment/puppet/xinetd/templates/service.erb @@ -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 %> +} diff --git a/deployment/puppet/xinetd/tests/init.pp b/deployment/puppet/xinetd/tests/init.pp new file mode 100644 index 0000000000..92ceb53c16 --- /dev/null +++ b/deployment/puppet/xinetd/tests/init.pp @@ -0,0 +1 @@ +include xinetd