Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: modules/buildbot/manifests/init.pp

Issue 29325436: Issue 1281 - Introduce module buildbot (Closed)
Patch Set: Issue 1281 - Address review feedback Created Oct. 20, 2015, 8:35 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: modules/buildbot/manifests/init.pp
diff --git a/modules/buildbot/manifests/init.pp b/modules/buildbot/manifests/init.pp
new file mode 100644
index 0000000000000000000000000000000000000000..7991f4395ed38c23466daf6ac292e8ce3711aef3
--- /dev/null
+++ b/modules/buildbot/manifests/init.pp
@@ -0,0 +1,123 @@
+# == Class: buildbot
+#
+# Manage Buildbot (https://buildbot.net/) master and slave setups.
+#
+# Class buildbot acts as the root namespace for the buildbot integration
+# with Puppet, while also providing a variety of setup parameters that can
+# be used to adjust the software setup.
+#
+# It defines a set of virtual resources titled 'buildmaster' and 'buildslave'.
+# Those are realized implicitly when required by any of the various entities
+# within the module, but may become realized explicitely when necessary:
+#
+# - Concat[]: The 'buildmaster' and 'buildslave' system daemon configuration
+# - Concat::Fragment[]: The respective root or configuration head fragment
+# - File[]: The anchestor of default for master and slave $basedir resources
+# - Service[]: The actual services running the master and slave instances
+#
+# Note, however, that the respective instances are rather implementation
+# specific and thus may become subject to change in the future.
+#
+# === Parameters:
+#
+# [*master_service*]
+# The 'buildmaster' service status to ensure, if any.
+#
+# [*slave_service*]
+# The 'buildslave' service status to ensure, if any.
+#
+# === Examples:
+#
+# class {'buildbot':
+# master_service => 'running',
+# }
+#
+class buildbot (
+ $master_service = undef,
+ $slave_service = undef,
+) {
+
+ $master_config = '/etc/default/buildmaster'
+ $master_directory = '/var/buildmaster'
+ $master_packages = ['buildbot']
+ $master_runner = '/usr/bin/buildbot'
+ $master_user = 'buildbot'
+
+ $slave_config = '/etc/default/buildslave'
+ $slave_directory = '/var/buildslave'
+ $slave_packages = ['buildbot-slave']
+ $slave_runner = '/usr/bin/buildslave'
+ $slave_user = 'buildbot'
+
+ @concat {
+ 'buildmaster':
+ owner => $master_user,
+ path => $master_config,
+ require => Package[$master_packages];
+ 'buildslave':
+ owner => $slave_user,
+ path => $slave_config,
+ require => Package[$slave_packages];
+ }
+
+ @concat::fragment {
Felix Dahlke 2015/11/19 19:50:01 So, do I understand it correctly that using concat
mathias 2016/01/20 16:13:51 Yes we can have multiple masters and slaves per ho
+ 'buildmaster':
+ content => template('buildbot/buildmaster.erb'),
+ order => 0,
+ target => 'buildmaster';
+ 'buildslave':
+ content => template('buildbot/buildslave.erb'),
+ order => 0,
+ target => 'buildslave';
+ }
+
+ @file {
+ $master_directory:
+ ensure => 'directory',
+ owner => $master_user,
+ require => Package[$master_packages];
+ $slave_directory:
+ ensure => 'directory',
+ owner => $slave_user,
+ require => Package[$slave_packages];
+ }
+
+ Service {
+ hasrestart => true,
+ hasstatus => false,
+ }
+
+ @service {
+ 'buildmaster':
+ ensure => $master_service ? {
+ /^(running|started|true)$/ => 'running',
+ default => 'stopped',
+ },
+ pattern => "^$master_user.*python.*$master_runner",
+ require => Package[$master_packages];
+ 'buildslave':
+ ensure => $slave_service ? {
+ /^(running|started|true)$/ => 'running',
+ default => 'stopped',
+ },
+ pattern => "^$slave_user.*python.*$slave_runner",
+ require => Package[$slave_packages];
+ }
+
+ Service['buildmaster'] <~ Exec <|creates == $master_config|>
+ Service['buildmaster'] <~ File <|path == $master_config|>
+ Service['buildmaster'] ~>
+
+ Service['buildslave'] <~ Exec <|creates == $slave_config|>
+ Service['buildslave'] <~ File <|path == $slave_config|>
+
+ if $master_service != undef {
+ ensure_packages($master_packages)
+ realize(Service['buildmaster'])
+ }
+
+ if $slave_service != undef {
+ ensure_packages($slave_packages)
+ realize(Service['buildslave'])
+ }
+}

Powered by Google App Engine
This is Rietveld