Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
  • 3 commits
  • 2 files changed
  • 0 commit comments
  • 2 contributors
Showing with 184 additions and 16 deletions.
  1. +155 −7 manifests/init.pp
  2. +29 −9 templates/supervisord.conf.erb
View
162 manifests/init.pp
@@ -1,14 +1,160 @@
-class supervisor {
- include supervisor::params
+# Class: supervisor
+#
+# This module manages supervisor
+#
+# Parameters:
+# [*ensure*]
+# Ensure if present or absent.
+# Default: present
+#
+# [*autoupgrade*]
+# Upgrade package automatically, if there is a newer version.
+# Default: false
+#
+# [*service_ensure*]
+# Ensure if service is running or stopped.
+# Default: running
+#
+# [*service_enable*]
+# Start service at boot.
+# Default: true
+#
+# [*enable_inet_server*]
+# Enable inet_http_server.
+# Default: false
+#
+# [*inet_server_port*]
+# inet_http_server ip:port to listen on.
+# Only used if inet_http_server is set to true.
+# Default: *:9000
+#
+# [*inet_server_user*]
+# If set, this is the name of the user to authenticate as.
+# Only used if inet_http_server is set to true.
+# Default: undef
+#
+# [*inet_server_password*]
+# Password for the inet_http_server.
+# Only used if inet_http_server is set to true and inet_server_user is set.
+# Default: undef
+#
+# [*logfile*]
+# Main log file.
+# Default: /var/log/supervisor/supervisord.log
+#
+# [*logfile_maxbytes*]
+# The maximum number of bytes that may be consumed by the activity log
+# file before it is rotated.
+# Default: 500MB
+#
+# [*logfile_backups*]
+# The number of backups to keep around resulting from activity log
+# file rotation.
+# Default: 10
+#
+# [*minfds*]
+# The minimum number of file descriptors that must be available before
+# supervisord will start successfully.
+# Default: 1024
+#
+# [*minprocs*]
+# The minimum number of process descriptors that must be available before
+# supervisord will start successfully.
+# Default: 200
+#
+# [*childlogdir*]
+# The directory used for AUTO child log files.
+# Default: /var/log/supervisor
+#
+# [*user*]
+# If supervisord is run as the root user, switch users to this UNIX user
+# account before doing any meaningful processing.
+# Default: undef
+#
+# [*umask*]
+# The umask of the supervisord process.
+# Default: 022
+#
+# [*supervisor_environment*]
+# A list of key/value pairs in the form KEY=val,KEY2=val2 that will be
+# placed in the supervisord process’ environment.
+# Default: undef
+#
+# [*identifier*]
+# The identifier string for this supervisor process,
+# used by the RPC interface.
+# Default: undef
+#
+# Actions:
+# Installs supervisor.
+#
+# Sample Usage:
+# class { 'supervisor': }
+#
+#
+# [Remember: No empty lines between comments and class definition]
+class supervisor(
+ $ensure = 'present',
+ $autoupgrade = false,
+ $service_ensure = 'running',
+ $service_enable = true,
+ $enable_inet_server = false,
+ $inet_server_port = '*:9000',
+ $inet_server_user = undef,
+ $inet_server_pass = undef,
+ $logfile = '/var/log/supervisor/supervisord.log',
+ $logfile_maxbytes = '500MB',
+ $logfile_backups = 10,
+ $loglevel = 'info',
+ $minfds = 1024,
+ $minprocs = 200,
+ $childlogdir = '/var/log/supervisor',
+ $nocleanup = false,
+ $user = undef,
+ $umask = '022',
+ $supervisor_environment = undef,
+ $identifier = undef
+) inherits supervisor::params {
+
+ case $ensure {
+ present: {
+ if $autoupgrade == true {
+ $package_ensure = 'latest'
+ } else {
+ $package_ensure = 'present'
+ }
+
+ case $service_ensure {
+ running, stopped: {
+ $service_ensure_real = $service_ensure
+ }
+ default: {
+ fail('service_ensure parameter must be running or stopped')
+ }
+ }
+
+ $dir_ensure = 'directory'
+ $file_ensure = 'file'
+ }
+ absent: {
+ $package_ensure = 'absent'
+ $service_ensure_real = 'stopped'
+ $dir_ensure = 'absent'
+ $file_ensure = 'absent'
+ }
+ default: {
+ fail('ensure parameter must be present or absent')
+ }
+ }
if ! defined(Package[$supervisor::params::package]) {
package { $supervisor::params::package:
- ensure => installed,
+ ensure => $package_ensure,
}
}
file { $supervisor::params::conf_dir:
- ensure => directory,
+ ensure => $dir_ensure,
purge => true,
require => Package[$supervisor::params::package],
}
@@ -17,26 +163,28 @@
'/var/log/supervisor',
'/var/run/supervisor'
]:
- ensure => directory,
+ ensure => $dir_ensure,
purge => true,
backup => false,
require => Package[$supervisor::params::package],
}
file { $supervisor::params::conf_file:
+ ensure => $file_ensure,
content => template('supervisor/supervisord.conf.erb'),
require => Package[$supervisor::params::package],
notify => Service[$supervisor::params::system_service],
}
file { '/etc/logrotate.d/supervisor':
+ ensure => $file_ensure,
source => 'puppet:///modules/supervisor/logrotate',
require => Package[$supervisor::params::package],
}
service { $supervisor::params::system_service:
- ensure => running,
- enable => true,
+ ensure => $service_ensure_real,
+ enable => $service_enable,
hasrestart => true,
require => Package[$supervisor::params::package],
}
View
38 templates/supervisord.conf.erb
@@ -1,16 +1,36 @@
[unix_http_server]
file=/var/run/supervisor.sock ; (the path to the socket file)
+<% if enable_inet_server -%>
+[inet_http_server]
+port=<%= inet_server_port %>
+<% if @inet_server_user && @inet_server_pass -%>
+user=<%= inet_server_user %>
+pass=<%= inet_server_pass %>
+<% end -%>
+<% end -%>
+
[supervisord]
-logfile=/var/log/supervisor/supervisord.log ; (main log file;default $CWD/supervisord.log)
-logfile_maxbytes=500MB ; (max main logfile bytes b4 rotation;default 50MB)
-logfile_backups=10 ; (num of main logfile rotation backups;default 10)
-loglevel=info ; (log level;default info; others: debug,warn,trace)
-pidfile=/var/run/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
-nodaemon=false ; (start in foreground if true;default false)
-minfds=1024 ; (min. avail startup file descriptors;default 1024)
-minprocs=200 ; (min. avail process descriptors;default 200)
-childlogdir=/var/log/supervisor ; ('AUTO' child log dir, default $TEMP)
+logfile=<%= logfile %> ; (main log file;default $CWD/supervisord.log)
+logfile_maxbytes=<%= logfile_maxbytes %> ; (max main logfile bytes b4 rotation;default 50MB)
+logfile_backups=<%= logfile_backups %> ; (num of main logfile rotation backups;default 10)
+loglevel=<%= loglevel %> ; (log level;default info; others: debug,warn,trace)
+pidfile=/var/run/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
+nodaemon=false ; (start in foreground if true;default false)
+minfds=<%= minfds %> ; (min. avail startup file descriptors;default 1024)
+minprocs=<%= minprocs %> ; (min. avail process descriptors;default 200)
+childlogdir=<%= childlogdir %> ; ('AUTO' child log dir, default $TEMP)
+nocleanup=<%= nocleanup %>
+umask=<%= umask %>
+<% if @user -%>
+user=<%= user %>
+<% end -%>
+<% if @supervisor_environment -%>
+environment=<%= supervisor_environment %>
+<% end -%>
+<% if @identifier -%>
+identifier=<%= identifier %>
+<% end -%>
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface

No commit comments for this range

Something went wrong with that request. Please try again.