Puppet-lint / Refactor meetbot module

This started as a puppet-lint clean up and ended up more a refactoring
of some of the logic.

Change-Id: I5315571fbef8ff4ebe2ae77d2d2b19a6fcd5798d
Signed-off-by: Paul Belanger <paul.belanger@polybeacon.com>
Reviewed-on: https://review.openstack.org/14113
Reviewed-by: James E. Blair <corvus@inaugust.com>
Approved: Monty Taylor <mordred@inaugust.com>
Reviewed-by: Monty Taylor <mordred@inaugust.com>
Tested-by: Jenkins
This commit is contained in:
Paul Belanger 2012-10-05 17:49:57 -04:00 committed by Jenkins
parent 39494862c8
commit da3e3b72e9
2 changed files with 117 additions and 107 deletions

View File

@ -1,47 +1,54 @@
class meetbot { class meetbot {
include apache include apache
vcsrepo { "/opt/meetbot": vcsrepo { '/opt/meetbot':
ensure => latest, ensure => latest,
provider => git, provider => git,
source => "https://github.com/openstack-ci/meetbot.git", source => 'https://github.com/openstack-ci/meetbot.git',
} }
user { "meetbot": user { 'meetbot':
shell => "/sbin/nologin", gid => 'meetbot',
home => "/var/lib/meetbot", home => '/var/lib/meetbot',
shell => '/sbin/nologin',
system => true, system => true,
gid => "meetbot", require => Group['meetbot'],
require => Group["meetbot"]
} }
group { "meetbot": group { 'meetbot':
ensure => present ensure => present,
} }
package { ['supybot', 'python-twisted']: $packages = [
ensure => present 'supybot',
'python-twisted'
]
package { $packages:
ensure => present,
} }
file { "/var/lib/meetbot": file { '/var/lib/meetbot':
ensure => directory, ensure => directory,
owner => 'meetbot', owner => 'meetbot',
require => User['meetbot'] require => User['meetbot'],
} }
file { "/usr/share/pyshared/supybot/plugins/MeetBot": file { '/usr/share/pyshared/supybot/plugins/MeetBot':
ensure => directory, ensure => directory,
recurse => true, recurse => true,
source => "/opt/meetbot/MeetBot", require => [
require => [Package["supybot"], Package['supybot'],
Vcsrepo["/opt/meetbot"]] Vcsrepo['/opt/meetbot']
],
source => '/opt/meetbot/MeetBot',
} }
file { "/etc/nginx/sites-enabled/default": file { '/etc/nginx/sites-enabled/default':
ensure => absent, ensure => absent,
notify => Service['nginx'],
require => Package['nginx'], require => Package['nginx'],
notify => Service['nginx']
} }
} }
# vim:sw=2:ts=2:expandtab:textwidth=79

View File

@ -1,117 +1,120 @@
define meetbot::site($nick, $nickpass, $network, $server, $vhost_name=$fqdn, $channels, $use_ssl) { define meetbot::site(
$channels,
$network,
$nick,
$nickpass,
$server,
$use_ssl,
$vhost_name = $::fqdn
) {
include remove_nginx include remove_nginx
$varlib = "/var/lib/meetbot/${name}"
$meetbot = "/srv/meetbot-${name}"
apache::vhost { $vhost_name: apache::vhost { $vhost_name:
port => 80, port => 80,
docroot => "/srv/meetbot-$name", docroot => "/srv/meetbot-${name}",
priority => '50', priority => '50',
} }
file { "/var/lib/meetbot/${name}": file { $varlib:
ensure => directory, ensure => directory,
owner => 'meetbot', owner => 'meetbot',
require => File["/var/lib/meetbot"] require => File['/var/lib/meetbot'],
} }
file { "/srv/meetbot-${name}": file { $meetbot:
ensure => directory, ensure => directory,
} }
file { "/srv/meetbot-${name}/index.html": file { "${meetbot}/index.html":
ensure => present, ensure => present,
content => template("meetbot/index.html.erb"), content => template('meetbot/index.html.erb'),
require => File["/srv/meetbot-${name}"] require => File[$meetbot],
} }
file { "/srv/meetbot-${name}/irclogs": file { "${meetbot}/irclogs":
ensure => link, ensure => link,
target => "/var/lib/meetbot/${name}/logs/ChannelLogger/${network}/", target => "${varlib}/logs/ChannelLogger/${network}",
require => File["/srv/meetbot-${name}"] require => File[$meetbot],
} }
file { "/srv/meetbot-${name}/meetings": file { "${meetbot}/meetings":
ensure => link, ensure => link,
target => "/var/lib/meetbot/${name}/meetings/", target => "${varlib}/meetings",
require => File["/srv/meetbot-${name}"] require => File[$meetbot],
} }
file { [
file { "/var/lib/meetbot/${name}/conf": "${varlib}/conf",
"${varlib}/data",
"${varlib}/backup",
"${varlib}/logs"
]:
ensure => directory, ensure => directory,
owner => 'meetbot', owner => 'meetbot',
require => File["/var/lib/meetbot/${name}"] require => File[$varlib],
} }
file { "/var/lib/meetbot/${name}/data": file { "${varlib}/data/tmp":
ensure => directory, ensure => directory,
owner => 'meetbot', owner => 'meetbot',
require => File["/var/lib/meetbot/${name}"] require => File["${varlib}/data"],
}
file { "/var/lib/meetbot/${name}/data/tmp":
ensure => directory,
owner => 'meetbot',
require => File["/var/lib/meetbot/${name}/data"]
}
file { "/var/lib/meetbot/${name}/backup":
ensure => directory,
owner => 'meetbot',
require => File["/var/lib/meetbot/${name}"]
}
file { "/var/lib/meetbot/${name}/logs":
ensure => directory,
owner => 'meetbot',
require => File["/var/lib/meetbot/${name}"]
} }
# set to root/root so meetbot doesn't overwrite # set to root/root so meetbot doesn't overwrite
file { "/var/lib/meetbot/${name}.conf": file { "${varlib}.conf":
ensure => present, ensure => present,
content => template("meetbot/supybot.conf.erb"), content => template('meetbot/supybot.conf.erb'),
owner => 'root',
group => 'root', group => 'root',
require => File["/var/lib/meetbot"], notify => Service["${name}-meetbot"],
notify => Service["${name}-meetbot"] owner => 'root',
require => File['/var/lib/meetbot'],
} }
file { "/var/lib/meetbot/${name}/ircmeeting": file { "${varlib}/ircmeeting":
ensure => directory, ensure => directory,
recurse => true,
source => "/opt/meetbot/ircmeeting",
owner => 'meetbot', owner => 'meetbot',
require => [Vcsrepo["/opt/meetbot"], recurse => true,
File["/var/lib/meetbot/${name}"]] require => [
Vcsrepo['/opt/meetbot'],
File[$varlib]
],
source => '/opt/meetbot/ircmeeting',
} }
file { "/var/lib/meetbot/${name}/ircmeeting/meetingLocalConfig.py": file { "${varlib}/ircmeeting/meetingLocalConfig.py":
ensure => present, ensure => present,
content => template("meetbot/meetingLocalConfig.py.erb"), content => template('meetbot/meetingLocalConfig.py.erb'),
notify => Service["${name}-meetbot"],
owner => 'meetbot', owner => 'meetbot',
require => File["/var/lib/meetbot/${name}/ircmeeting"], require => File["${varlib}/ircmeeting"],
notify => Service["${name}-meetbot"]
} }
# we set this file as root ownership because meetbot overwrites it on shutdown # we set this file as root ownership because meetbot overwrites it on shutdown
# this means when puppet changes it and restarts meetbot the file is reset # this means when puppet changes it and restarts meetbot the file is reset
file { "/etc/init/${name}-meetbot.conf": file { "/etc/init/${name}-meetbot.conf":
ensure => 'present', ensure => present,
content => template("meetbot/upstart.erb"), content => template('meetbot/upstart.erb'),
replace => 'true', notify => Service["${name}-meetbot"],
require => File["/var/lib/meetbot/${name}.conf"],
owner => 'root', owner => 'root',
notify => Service["${name}-meetbot"] replace => true,
require => File["${varlib}.conf"],
} }
service { "${name}-meetbot": service { "${name}-meetbot":
provider => upstart,
ensure => running, ensure => running,
require => [Vcsrepo["/opt/meetbot"], provider => upstart,
File["/etc/init/${name}-meetbot.conf"]], require => [
subscribe => [File["/usr/share/pyshared/supybot/plugins/MeetBot"], Vcsrepo['/opt/meetbot'],
File["/var/lib/meetbot/${name}/ircmeeting"]] File["/etc/init/${name}-meetbot.conf"]
],
subscribe => [
File['/usr/share/pyshared/supybot/plugins/MeetBot'],
File["${varlib}/ircmeeting"]
],
} }
} }
# vim:sw=2:ts=2:expandtab:textwidth=79