Skip to content
This repository has been archived by the owner on Jun 11, 2019. It is now read-only.

Commit

Permalink
Merge pull request #19 from associatedpress/ap-fix
Browse files Browse the repository at this point in the history
Fix namespace clash with Firewall module when using hiera. Addresses Issue #18
  • Loading branch information
alvagante authored Jul 21, 2016
2 parents 5c7c94c + 806de68 commit 47998c0
Show file tree
Hide file tree
Showing 16 changed files with 223 additions and 53 deletions.
3 changes: 2 additions & 1 deletion .fixtures.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ fixtures:
"monitor": "git://github.com/example42/puppet-monitor.git"
"firewall": "git://github.com/example42/puppet-firewall.git"
"iptables": "git://github.com/example42/puppet-iptables.git"
"concat": "git://github.com/example42/puppet-concat.git"
"concat": "git://github.com/puppetlabs/puppetlabs-concat.git"
"stdlib": "git://github.com/puppetlabs/puppetlabs-stdlib.git"
symlinks:
"monit": "#{source_dir}"

1 change: 1 addition & 0 deletions .gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ puppetversion = ENV['PUPPET_VERSION']
gem 'puppet', puppetversion, :require => false
gem 'puppet-lint'
gem 'puppetlabs_spec_helper', '>= 0.1.0'
gem 'rspec', '~> 3.1.0', :platforms => :ruby_18
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ Session.vim
spec/fixtures
.*.sw[a-z]
*.un~
vendor
.bundle
.gemfile.lock
4 changes: 2 additions & 2 deletions .project
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</projects>
<buildSpec>
<buildCommand>
<name>org.cloudsmith.geppetto.pp.dsl.ui.modulefileBuilder</name>
<name>com.puppetlabs.geppetto.pp.dsl.ui.modulefileBuilder</name>
<arguments>
</arguments>
</buildCommand>
Expand All @@ -17,7 +17,7 @@
</buildCommand>
</buildSpec>
<natures>
<nature>org.cloudsmith.geppetto.pp.dsl.ui.puppetNature</nature>
<nature>com.puppetlabs.geppetto.pp.dsl.ui.puppetNature</nature>
<nature>org.eclipse.xtext.ui.shared.xtextNature</nature>
</natures>
</projectDescription>
9 changes: 2 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,14 @@ rvm:
- 1.8.7
- 1.9.3
script:
- "rake spec SPEC_OPTS='--format documentation'"
- "bundle exec rake spec SPEC_OPTS='--format documentation'"
env:
- PUPPET_VERSION="~> 2.6.0"
- PUPPET_VERSION="~> 2.7.0"
- PUPPET_VERSION="~> 3.0.0"
- PUPPET_VERSION="~> 3.1.0"
matrix:
exclude:
- rvm: 1.9.3
env: PUPPET_VERSION="~> 2.6.0"
gemfile: .gemfile

gemfile: .gemfile
sudo: false
notifications:
email:
- [email protected]
12 changes: 0 additions & 12 deletions Modulefile

This file was deleted.

69 changes: 69 additions & 0 deletions manifests/checkfile.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Define: monit::checkfile
#
# Basic file checking define that works by pattern matching
#
# Usage:
# With standard template:
# monit::checkfile { "name":
# pattern => 'string to search'}
#
define monit::checkfile (
$process = '',
$processuid = '',
$processgid = '',
$file = '',
$template = 'monit/checkfile.erb',
$pattern = '',
$startprogram = '',
$stopprogram = '',
$restarts = '5',
$cycles = '5',
$failaction = 'timeout',
$depends = [],
$enable = true ) {

$ensure=bool2ensure($enable)

include monit

$real_file = $file ? {
'' => $name,
default => $file,
}

$real_pattern = $pattern
$real_process = $process

$real_startprogram = $startprogram ? {
'' => "/etc/init.d/${process} start",
default => $startprogram,
}

$real_stopprogram = $stopprogram ? {
'' => "/etc/init.d/${process} stop",
default => $stopprogram,
}

$real_processuid = $processuid ? {
'' => $monit::process_user,
default => $processuid,
}

$real_processgid = $processgid ? {
'' => $monit::process_group,
default => $processgid,
}

file { "MonitCheckFile_${name}":
ensure => $ensure,
path => "${monit::plugins_dir}/${name}",
mode => $monit::config_file_mode,
owner => $monit::config_file_owner,
group => $monit::config_file_group,
require => Package[$monit::package],
notify => $monit::manage_service_autorestart,
content => template($template),
replace => $monit::manage_file_replace,
}

}
17 changes: 15 additions & 2 deletions manifests/checkpid.pp
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,25 @@
#
define monit::checkpid (
$process = '',
$processuid = '',
$processgid = '',
$template = 'monit/checkpid.erb',
$pidfile = '',
$startprogram = '',
$stopprogram = '',
$restarts = '5',
$cycles = '5',
$failaction = 'timeout',
$depends = [],
$enable = true ) {

$ensure=bool2ensure($enable)

include monit

$real_process = $process ? {
'' => $process,
default => $name,
'' => $name,
default => $process,
}

$real_pidfile = $pidfile ? {
Expand All @@ -41,6 +44,16 @@
default => $stopprogram,
}

$real_processuid = $processuid ? {
'' => $monit::process_user,
default => $processuid,
}

$real_processgid = $processgid ? {
'' => $monit::process_group,
default => $processgid,
}

file { "MonitCheckPid_${name}":
ensure => $ensure,
path => "${monit::plugins_dir}/${name}",
Expand Down
70 changes: 70 additions & 0 deletions manifests/checkprocessmatch.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Define: monit::checkprocessmatch
#
# Basic processs checking define that works by pattern matching
# against the process name (command line) in the process table.
#
# Usage:
# With standard template:
# monit::checkprocessmatch { "name": }
#
define monit::checkprocessmatch (
$process = '',
$processuid = '',
$processgid = '',
$template = 'monit/checkprocessmatch.erb',
$pattern = '',
$startprogram = '',
$stopprogram = '',
$restarts = '5',
$cycles = '5',
$failaction = 'timeout',
$depends = [],
$enable = true ) {

$ensure=bool2ensure($enable)

include monit

$real_process = $process ? {
'' => $name,
default => $process,
}

$real_pattern = $pattern ? {
'' => $real_process,
default => $pattern,
}

$real_startprogram = $startprogram ? {
'' => "/etc/init.d/${process} start",
default => $startprogram,
}

$real_stopprogram = $stopprogram ? {
'' => "/etc/init.d/${process} stop",
default => $stopprogram,
}

$real_processuid = $processuid ? {
'' => $monit::process_user,
default => $processuid,
}

$real_processgid = $processgid ? {
'' => $monit::process_group,
default => $processgid,
}

file { "MonitCheckProcessMatch_${name}":
ensure => $ensure,
path => "${monit::plugins_dir}/${name}",
mode => $monit::config_file_mode,
owner => $monit::config_file_owner,
group => $monit::config_file_group,
require => Package[$monit::package],
notify => $monit::manage_service_autorestart,
content => template($template),
replace => $monit::manage_file_replace,
}

}
22 changes: 13 additions & 9 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,9 @@
# [*process_user*]
# The name of the user monit runs with. Used by puppi and monitor.
#
# [*process_group*]
# The name of the group monit runs with. Used by puppi and monitor.
#
# [*config_dir*]
# Main configuration directory. Used by puppi
#
Expand Down Expand Up @@ -316,7 +319,7 @@
$monitor_target = params_lookup( 'monitor_target' , 'global' ),
$puppi = params_lookup( 'puppi' , 'global' ),
$puppi_helper = params_lookup( 'puppi_helper' , 'global' ),
$firewall = params_lookup( 'firewall' , 'global' ),
$fw = params_lookup( 'fw' , 'global' ),
$firewall_tool = params_lookup( 'firewall_tool' , 'global' ),
$firewall_src = params_lookup( 'firewall_src' , 'global' ),
$firewall_dst = params_lookup( 'firewall_dst' , 'global' ),
Expand All @@ -327,6 +330,7 @@
$process = params_lookup( 'process' ),
$process_args = params_lookup( 'process_args' ),
$process_user = params_lookup( 'process_user' ),
$process_group = params_lookup( 'process_group' ),
$config_dir = params_lookup( 'config_dir' ),
$config_file = params_lookup( 'config_file' ),
$config_file_mode = params_lookup( 'config_file_mode' ),
Expand All @@ -350,7 +354,7 @@
$bool_disableboot=any2bool($disableboot)
$bool_monitor=any2bool($monitor)
$bool_puppi=any2bool($puppi)
$bool_firewall=any2bool($firewall)
$bool_firewall=any2bool($fw)
$bool_debug=any2bool($debug)

### Definition of some variables used in the module
Expand Down Expand Up @@ -455,12 +459,12 @@
}

service { 'monit':
ensure => $monit::manage_service_ensure,
name => $monit::service,
enable => $monit::manage_service_enable,
hasstatus => $monit::service_status,
pattern => $monit::process,
require => Package[$monit::package],
ensure => $monit::manage_service_ensure,
name => $monit::service,
enable => $monit::manage_service_enable,
hasstatus => $monit::service_status,
pattern => $monit::process,
require => Package[$monit::package],
}

file { 'monit.conf':
Expand Down Expand Up @@ -489,7 +493,7 @@
}

# The whole monit configuration directory can be recursively overriden
if $monit::source_dir {
if $monit::source_dir and $monit::source_dir != '' {
file { 'monit.dir':
ensure => directory,
path => $monit::config_dir,
Expand Down
6 changes: 5 additions & 1 deletion manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@
default => 'monit',
}

$process_group = $::operatingsystem ? {
default => 'monit',
}

$config_dir = $::operatingsystem ? {
default => '/etc/monit',
}
Expand Down Expand Up @@ -144,7 +148,7 @@
$monitor = false
$monitor_tool = ''
$monitor_target = $::ipaddress
$firewall = false
$fw = false
$firewall_tool = ''
$firewall_src = '0.0.0.0/0'
$firewall_dst = $::ipaddress
Expand Down
Loading

0 comments on commit 47998c0

Please sign in to comment.