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

Unified Diff: modules/buildbot/manifests/master.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/master.pp
diff --git a/modules/buildbot/manifests/master.pp b/modules/buildbot/manifests/master.pp
new file mode 100644
index 0000000000000000000000000000000000000000..9c1f726a01c69c43662035daa3481c20beb292ff
--- /dev/null
+++ b/modules/buildbot/manifests/master.pp
@@ -0,0 +1,144 @@
+# == Type: buildbot::master
+#
+# Manage Buildbot (http://buildbot.net/) master instances.
+#
+# Note that each instance implies the creation of a virtual Concat and
+# a virtual Concat::Fragment resource for setting up the master.cfg file.
+# One may either realize these resources (as done so by master::fragment
+# implicitly, for example) or use a custom approach for setting up the
+# configuration.
+#
+# === Parameters:
+#
+# [*basedir*]
+# The base directory of the master, which can be configured elsewhere or,
+# if it's ancestors are present, relied upon the builtin defaults.
+#
+# [*database*]
+# Translates directly into the BuildmasterConfig['db_url'] configuration
+# option within the master.cfg file.
+#
+# [*ensure*]
+# Whether to setup the master (anything but 'absent' or 'purged') or
Felix Dahlke 2015/11/19 19:50:01 Typo: "set up"
mathias 2016/01/20 16:13:52 Acknowledged.
+# remove the associated resources. Note that only 'purged' implies the
+# removal of $basedir.
+#
+# [*http_port*]
+# Translates directly into the port portion of the BuildmasterConfig's
+# 'buildbotURL', but may be used in other places as well.
+#
+# [*project*]
Felix Dahlke 2015/11/19 19:50:01 Wouldn't it be simpler to have two separate parame
mathias 2016/01/20 16:13:52 Yes, it would be simpler. Though the idea is that
+# A hash to optionally contain a 'title' (which translats into the config
+# 'title' option) and an 'url' (translates into the 'titleURL').
+#
+# [*slaves*]
+# Local buildbot::slave records to setup with the master.
Felix Dahlke 2015/11/19 19:50:01 Typo: "set up"
mathias 2016/01/20 16:13:51 Acknowledged.
+#
+# [*slave_credentials*]
+# Name => password pairs of e.g. remote build slaves.
+#
+# [*slave_port*]
+# Translates directly into the BuildmasterConfig['slavePortnum'] option
+# within the master.cfg file.
+#
+# [*system*]
+# Any value beside 'false' will cause the master operations to also
+# affect the buildbot::buildmaster service. Use this option to include
+# the master instance with the system daemon.
+#
+# [*user*]
+# The user to whom the master instance belongs to. Note that the user
+# is not created implicitly by this setup, except if the creation is
+# implied with any of the $buildbot::master_packages.
+#
+# === Examples:
+#
+# buildbot::master {'primary':
+# basedir => '/var/primary-buildmaster',
+# project => {'title' => 'Awesomeness'},
+# }
+#
+# buildbot::master {'secondary':
+# basedir => '/var/secondary-buildmaster',
+# ensure => absent,
+# }
+#
+define buildbot::master (
+ $basedir = "$::buildbot::master_directory/$name",
+ $database = "sqlite:///state.sqlite",
+ $ensure = 'present',
+ $http_port = 8010,
+ $project = {},
+ $slaves = {},
+ $slave_credentials = {},
+ $slave_port = 9989,
+ $system = false,
+ $user = $::buildbot::master_user,
+) {
+
+ if $ensure !~ /^(absent|purged)$/ {
+ ensure_packages($::buildbot::master_packages)
+ realize(File[$::buildbot::master_directory])
+
+ exec {"buildmaster#$title":
+ command => shellquote([
+ $::buildbot::master_runner,
+ 'create-master',
+ $basedir,
+ ]),
+ creates => "$basedir/buildbot.tac",
+ require => [
+ File[$::buildbot::master_directory],
+ Package[$::buildbot::master_packages],
+ ],
+ user => $user,
+ }
+
+ Exec["buildmaster#$title"] <- Exec <|creates == $basedir|>
+ Exec["buildmaster#$title"] <- File <|path == $basedir|>
+
+ $config = "$basedir/master.cfg"
+
+ @concat {$config:
+ owner => $user,
+ require => Exec["buildmaster#$title"],
+ }
+
+ @concat::fragment {$config:
+ content => template('buildbot/master.cfg.erb'),
+ target => $config,
+ }
+
+ if !empty($slaves) {
+ create_resources('buildbot::slave', $slaves)
+ realize(Concat[$config])
+ realize(Concat::Fragment[$config])
+ }
+ }
+
+ if $system != false {
+ ensure_packages($::buildbot::master_packages)
+ realize(Concat['buildmaster'])
+ realize(Concat::Fragment['buildmaster'])
+ realize(Service['buildmaster'])
+
+ concat::fragment {"buildmaster#$title":
+ content => template('buildbot/buildmaster_fragment.erb'),
+ ensure => $ensure ? {'present' => $ensure, default => 'absent'},
+ notify => Service['buildmaster'],
+ order => 1,
+ target => 'buildmaster',
+ }
+
+ Service['buildmaster'] <~ Exec <|creates == "$basedir"|>
+ Service['buildmaster'] <~ Exec <|creates == "$basedir/buildbot.tac"|>
+ Service['buildmaster'] <~ Exec <|creates == "$basedir/master.cfg"|>
+
+ Service['buildmaster'] <~ File <|path == "$basedir"|>
+ Service['buildmaster'] <~ File <|path == "$basedir/master.cfg"|>
+ }
+
+ if $ensure == 'purged' {
+ file {$basedir: ensure => 'absent'}
+ }
+}

Powered by Google App Engine
This is Rietveld