mirror of
https://github.com/ardichoke/puppet-arpwatch.git
synced 2026-05-11 02:15:37 -04:00
Add Debian support
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1 +1,3 @@
|
||||
pkg/
|
||||
.yardoc
|
||||
doc
|
||||
|
||||
12
README.md
12
README.md
@@ -57,6 +57,9 @@ Specifies the email address to send arpwatch alerts to. Valid options: string. D
|
||||
|
||||
Specifies the interface to monitor for arp changes. Valid options: string containing an interface name. Default: eth0
|
||||
|
||||
#### `opts`
|
||||
|
||||
Specify additional options to pass to arpwatch at start. Valid options: string of command line options. Default: OS dependant
|
||||
#### `package_ensure`
|
||||
|
||||
Tells Puppet whether the arpwatch package should be installed, and what version. Valid options: 'present', 'latest', or a specific version number. Default value: 'present'
|
||||
@@ -83,11 +86,12 @@ Specifies which user account arpwatch should run under. Valid options: string. D
|
||||
|
||||
#### `source_email`
|
||||
|
||||
Specifies the source email address for arpwatch emails. Valid options: string. Default value: 'arpwatch@${::fqdn}'
|
||||
Specifies the source email address for arpwatch emails. Only works under RedHat family distributions. Valid options: string. Default value: 'arpwatch@${::fqdn}'
|
||||
|
||||
## Limitations
|
||||
|
||||
arpwatch currently only supports RedHat based distributions. Pull requests are welcome to add support for other platforms.
|
||||
This module currently supports RedHat and Debian distributions. It has only been thoroughly tested under RedHat.
|
||||
Pull requests are welcome to add support for other platforms.
|
||||
|
||||
## Development
|
||||
|
||||
@@ -95,4 +99,8 @@ Pull requests are welcome. Please make sure to properly document any additions o
|
||||
|
||||
## Release Notes
|
||||
|
||||
v0.2.0 - Add support for Debian
|
||||
|
||||
v0.1.2 - Add spec tests and dependencies
|
||||
|
||||
v0.1.0 - Initial release of arpwatch module
|
||||
|
||||
@@ -1,68 +1,34 @@
|
||||
# Class: arpwatch
|
||||
# ===========================
|
||||
#
|
||||
# Install and configure arpwatch
|
||||
#
|
||||
# Parameters
|
||||
# ----------
|
||||
# @example Basic installation and configuration of arpwatch
|
||||
# include ::arpwatch
|
||||
#
|
||||
# * `config_file`
|
||||
# The confiugration file on the server to manage.
|
||||
#
|
||||
# * `config_template`
|
||||
# The template to use when generating the config file.
|
||||
#
|
||||
# * `dest_email`
|
||||
# The email address to send arpwatch alerts to.
|
||||
#
|
||||
# * `interface`
|
||||
# Which interface to watch for arp traffic
|
||||
#
|
||||
# * `package_ensure`
|
||||
# Ensure value passed to the package resource
|
||||
#
|
||||
# * `package_name`
|
||||
# Name of the package to manage
|
||||
#
|
||||
# * `service_enable`
|
||||
# Enable value, passed to the service resource
|
||||
#
|
||||
# * `service_ensure`
|
||||
# Ensure value, passed to the service resource
|
||||
#
|
||||
# * `service_name`
|
||||
# Name of the service to manage
|
||||
#
|
||||
# * `service_user`
|
||||
# Defines the user account that arpwatch will run under
|
||||
#
|
||||
# * `source_email`
|
||||
# Define the source email address for arpwatch alerts
|
||||
#
|
||||
# Examples
|
||||
# --------
|
||||
#
|
||||
# @example
|
||||
# @example Install service and set it to send email alerts
|
||||
# class { 'arpwatch':
|
||||
# dest_email => 'foo@bar.org',
|
||||
# source_email => 'arpwatch@baz.com',
|
||||
# }
|
||||
#
|
||||
# Authors
|
||||
# -------
|
||||
#
|
||||
# Ryan DeShone <rfdeshon@gmail.com>
|
||||
#
|
||||
# Copyright
|
||||
# ---------
|
||||
#
|
||||
# Copyright 2016 Ryan DeShone, unless otherwise noted.
|
||||
# @param [String] config_file The configuration file on the server to manage.
|
||||
# @param [String] config_template The template to use when generating the config file
|
||||
# @param [String] dest_email The email address to send arpwatch alerts to.
|
||||
# @param [String] interface Which interface to watch for arp traffic
|
||||
# @param [String] opts Additional command line options to pass to arpwatch at start
|
||||
# @param [String] package_ensure Ensure value passed to the package resource
|
||||
# @param [String] package_name Name of the package to manage
|
||||
# @param [Boolean] service_enable Enable value, passed to the service resource
|
||||
# @param [String] service_ensure Ensure value, passed to the service resource
|
||||
# @param [String] service_name Name of the service to manage
|
||||
# @param [String] service_user Defines the user account that arpwatch will run under
|
||||
# @param [String] source_email Define the source email address for arpwatch alerts (RedHat only)
|
||||
#
|
||||
class arpwatch (
|
||||
$config_file = $arpwatch::params::config_file,
|
||||
$config_template = $arpwatch::params::config_template,
|
||||
$dest_email = '-',
|
||||
$interface = $arpwatch::params::interface,
|
||||
$opts = $arpwatch::params::opts,
|
||||
$package_ensure = 'installed',
|
||||
$package_name = $arpwatch::params::package_name,
|
||||
$service_enable = true,
|
||||
|
||||
@@ -1,18 +1,27 @@
|
||||
# Class: arpwatch::params
|
||||
# ========================
|
||||
class arpwatch::params {
|
||||
case $::osfamily {
|
||||
'RedHat': {
|
||||
$package_name = 'arpwatch'
|
||||
$service_name = 'arpwatch'
|
||||
|
||||
case $::osfamily {
|
||||
'RedHat': {
|
||||
$interface = 'eth0'
|
||||
$config_file = '/etc/sysconfig/arpwatch'
|
||||
$config_template = 'arpwatch/conf.rhel.erb'
|
||||
$opts = ''
|
||||
$service_user = $::operatingsystemmajrelease ? {
|
||||
'5' => 'pcap',
|
||||
default => 'arpwatch',
|
||||
}
|
||||
}
|
||||
'Debian': {
|
||||
$interface = 'eth0'
|
||||
$config_file = '/etc/default/arpwatch'
|
||||
$config_template = 'arpwatch/conf.deb.erb'
|
||||
$service_user = 'arpwatch'
|
||||
$opts = '-N -p'
|
||||
}
|
||||
default: {
|
||||
fail("The ${module_name} module is not supported on an ${::osfamily} distribution.")
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "ardichoke-arpwatch",
|
||||
"version": "0.1.2",
|
||||
"version": "0.2.0",
|
||||
"author": "ardichoke",
|
||||
"summary": "Install and manage arpwatch",
|
||||
"license": "Apache-2.0",
|
||||
@@ -15,10 +15,17 @@
|
||||
"6",
|
||||
"7"
|
||||
]
|
||||
},
|
||||
{
|
||||
"operatingsystem": "Debian",
|
||||
"operatingsystemrelease": [
|
||||
"6",
|
||||
"7"
|
||||
]
|
||||
}
|
||||
],
|
||||
"dependencies": [
|
||||
{ "name": "puppetlabs/stdlib", "version_requirement": ">=1.0.0 <5.0.0"},
|
||||
{ "name": "puppetlabs/stdlib", "version_requirement": ">=1.0.0 <5.0.0"}
|
||||
],
|
||||
"tags": ["arpwatch","network","monitoring"]
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ describe 'arpwatch', type: 'class' do
|
||||
it {
|
||||
should contain_package('arpwatch').with({'ensure'=>'installed'})
|
||||
should contain_file('/etc/sysconfig/arpwatch').with({'ensure'=>'file'})
|
||||
should contain_service('arpwatch').with({'ensure'=>'running', 'enable'=>true})
|
||||
}
|
||||
end
|
||||
context 'On RedHat 6 with no parameters' do
|
||||
@@ -12,6 +13,7 @@ describe 'arpwatch', type: 'class' do
|
||||
it {
|
||||
should contain_package('arpwatch').with({'ensure'=>'installed'})
|
||||
should contain_file('/etc/sysconfig/arpwatch').with({'ensure'=>'file'})
|
||||
should contain_service('arpwatch').with({'ensure'=>'running', 'enable'=>true})
|
||||
}
|
||||
end
|
||||
context 'On RedHat 5 with no parameters' do
|
||||
@@ -19,6 +21,23 @@ describe 'arpwatch', type: 'class' do
|
||||
it {
|
||||
should contain_package('arpwatch').with({'ensure'=>'installed'})
|
||||
should contain_file('/etc/sysconfig/arpwatch').with({'ensure'=>'file'})
|
||||
should contain_service('arpwatch').with({'ensure'=>'running', 'enable'=>true})
|
||||
}
|
||||
end
|
||||
context 'On Debian 6 with no parameters' do
|
||||
let (:facts) { { osfamily: 'Debian', operatingsystemmajrelease: '6' }}
|
||||
it {
|
||||
should contain_package('arpwatch').with({'ensure'=>'installed'})
|
||||
should contain_file('/etc/default/arpwatch').with({'ensure'=>'file'})
|
||||
should contain_service('arpwatch').with({'ensure'=>'running', 'enable'=>true})
|
||||
}
|
||||
end
|
||||
context 'On Debian 7 with no parameters' do
|
||||
let (:facts) { { osfamily: 'Debian', operatingsystemmajrelease: '7' }}
|
||||
it {
|
||||
should contain_package('arpwatch').with({'ensure'=>'installed'})
|
||||
should contain_file('/etc/default/arpwatch').with({'ensure'=>'file'})
|
||||
should contain_service('arpwatch').with({'ensure'=>'running', 'enable'=>true})
|
||||
}
|
||||
end
|
||||
context 'On an unknown OS' do
|
||||
|
||||
4
templates/conf.deb.erb
Normal file
4
templates/conf.deb.erb
Normal file
@@ -0,0 +1,4 @@
|
||||
# THIS FILE MANAGED BY PUPPET
|
||||
# CHANGES WILL BE OVERWRITTEN
|
||||
ARGS="-i <%= @interface -%> -m <%= @dest_email -%> <%= @opts -%>"
|
||||
RUNAS="<%= @service_user -%>"
|
||||
@@ -1,3 +1,3 @@
|
||||
# THIS FILE MANAGED BY PUPPET
|
||||
# CHANGES WILL BE OVERWRITTEN
|
||||
OPTIONS="-i <%= @interface -%> -u <%= @service_user -%> -e <%= @dest_email -%> -s <%= @source_email -%>"
|
||||
OPTIONS="-i <%= @interface -%> -u <%= @service_user -%> -e <%= @dest_email -%> -s <%= @source_email -%> <%= @opts -%>"
|
||||
|
||||
Reference in New Issue
Block a user