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 - Rebase branch buildbot on top of upstream Created Sept. 5, 2015, 11:27 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..1e8b43cfbe649ce05714fe7f618ea60b5451f68f
--- /dev/null
+++ b/modules/buildbot/manifests/init.pp
@@ -0,0 +1,151 @@
+# == 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_config*]
+# The path to the 'buildmaster' system configuration.
+#
+# [*master_directory*]
+# The anchestor of the default buildbot::master $basedir.
Felix Dahlke 2015/10/02 12:16:26 Typo.
mathias 2015/10/02 13:47:40 Acknowledged.
+#
+# [*master_pacakges*]
Felix Dahlke 2015/10/02 12:16:26 Typo.
mathias 2015/10/02 13:47:40 Acknowledged.
+# The packages that provide the buildbot::master dependencies.
+#
+# [*master_runner*]
+# The path to the runner used for buildbot::master instances.
+#
+# [*master_service*]
+# The status 'buildmaster' service status to ensure, if any.
Felix Dahlke 2015/10/02 12:16:26 One "status" should suffice.
mathias 2015/10/02 13:47:40 Acknowledged.
+#
+# [*master_user*]
+# The user operating the 'buildmaster' service.
+#
+# [*slave_config*]
+# The path to the 'buildslave' system configuration.
+#
+# [*slave_directory*]
+# The anchestor of the default buildbot::slave $basedir.
+#
+# [*slave_pacakges*]
+# The packages that provide the buildbot::slave dependencies.
+#
+# [*slave_runner*]
+# The path to the runner used for buildbot::slave instances.
+#
+# [*slave_service*]
+# The status 'buildslave' service status to ensure, if any.
+#
+# [*slave_user*]
+# The user operating the 'buildslave' service.
+#
+# === Examples:
+#
+# class {'buildbot':
+# master => 'running',
+# }
+#
+class buildbot (
Felix Dahlke 2015/10/02 12:16:26 For some reason, I haven't yet found the part wher
mathias 2015/10/02 13:47:40 Types buildbot::master and buildbot::slave will en
Felix Dahlke 2015/10/02 15:44:27 Oh, now I get it, the packages to use and some det
mathias 2015/10/02 16:25:53 Providing those options is a trait of this approac
Felix Dahlke 2015/10/02 16:48:48 Please note that I'm fine with what the buildbot c
mathias 2015/10/20 20:36:16 Acknowledged.
+ $master_config = '/etc/default/buildmaster',
+ $master_directory = '/var/buildmaster',
+ $master_packages = ['buildbot'],
+ $master_runner = '/usr/bin/buildbot',
+ $master_service = undef,
+ $master_user = 'buildbot',
+ $slave_config = '/etc/default/buildslave',
+ $slave_directory = '/var/buildslave',
+ $slave_packages = ['buildbot-slave'],
+ $slave_runner = '/usr/bin/buildslave',
+ $slave_service = undef,
+ $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 {
+ '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