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

Delta Between Two Patch Sets: modules/buildbot/manifests/master.pp

Issue 29325436: Issue 1281 - Introduce module buildbot (Closed)
Left Patch Set: Issue 1281 - Rebase branch buildbot on top of upstream Created Sept. 5, 2015, 11:27 p.m.
Right Patch Set: Issue 1281 - Fix documentation, improve configuration parameter handling Created Jan. 20, 2016, 4:13 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
LEFTRIGHT
1 # == Type: buildbot::master 1 # == Type: buildbot::master
2 # 2 #
3 # Manage Buildbot (http://buildbot.net/) master instances. 3 # Manage Buildbot (http://buildbot.net/) master instances.
4 # 4 #
5 # Note that each instance implies the creation of a virtual Concat and 5 # Note that each instance implies the creation of a virtual Concat and
6 # a virtual Concat::Fragment resource for setting up the master.cfg file. 6 # a virtual Concat::Fragment resource for setting up the master.cfg file.
7 # One may either realize these resources (as done so by master::fragment 7 # One may either realize these resources (as done so by master::fragment
8 # implicitly, for example) or use a custom aproach for setting up the 8 # implicitly, for example) or use a custom approach for setting up the
Felix Dahlke 2015/10/02 12:39:42 Typo.
mathias 2015/10/02 13:47:41 Acknowledged.
9 # configuration. 9 # configuration.
10 # 10 #
11 # === Parameters: 11 # === Parameters:
12 # 12 #
13 # [*basedir*] 13 # [*basedir*]
14 # The base directory of the master, which can be configured elsewhere or, 14 # The base directory of the master, which can be configured elsewhere or,
15 # if it's anchestors are present, relied upon the builtin defaults. 15 # if its ancestors are present, relied upon the builtin defaults.
Felix Dahlke 2015/10/02 12:39:43 Typo.
mathias 2015/10/02 13:47:40 Acknowledged.
16 # 16 #
17 # [*database*] 17 # [*database*]
18 # Translates directly into the BuildmasterConfig['db_url'] configuration 18 # Translates directly into the BuildmasterConfig['db_url'] configuration
19 # option within the master.cfg file. 19 # option within the master.cfg file.
20 # 20 #
21 # [*ensure*] 21 # [*ensure*]
22 # Whether to setup the master (anything but 'absent' or 'purged') or 22 # Whether to set up the master (anything but 'absent' or 'purged') or
23 # remove the associated resources. Note that only 'purged' implies the 23 # remove the associated resources. Note that only 'purged' implies the
24 # removal of $basedir. 24 # removal of $basedir.
25 # 25 #
26 # [*http_port*] 26 # [*http_port*]
Felix Dahlke 2015/10/02 12:39:42 Nit: Maybe call this one "web_port" or something,
mathias 2015/10/02 13:47:40 Frankly I believe the http_* prefix to be better.
Felix Dahlke 2015/10/02 15:44:27 The problem with "http" is that it is a protocol -
mathias 2015/10/02 16:25:53 Acknowledged.
27 # Translates directly into the port portion of the BuildmasterConfig's 27 # Translates directly into the port portion of the BuildmasterConfig's
28 # 'buildbotURL', but may be used in other places as well. 28 # 'buildbotURL', but may be used in other places as well.
29 # 29 #
30 # [*port*] 30 # [*config*]
Felix Dahlke 2015/10/02 12:39:43 Maybe we should call this "slave_port" or somethin
mathias 2015/10/02 13:47:40 Acknowledged.
31 # A hash to use for initalizing the BuildmasterConfig ("c") within the
32 # master.cfg file. Can be used to customize "title"/"titleURL" and the
33 # "buildbotURL", for example.
34 #
35 # [*slaves*]
36 # Local buildbot::slave records to set up with the master.
37 #
38 # [*slave_credentials*]
39 # Name => password pairs of e.g. remote build slaves.
40 #
41 # [*slave_port*]
31 # Translates directly into the BuildmasterConfig['slavePortnum'] option 42 # Translates directly into the BuildmasterConfig['slavePortnum'] option
32 # within the master.cfg file. 43 # within the master.cfg file.
33 #
34 # [*project*]
35 # A hash to optionally contain a 'title' (which translats into the config
36 # 'title' option) and an 'url' (translates into the 'titleURL').
37 #
38 # [*slaves*]
39 # Local buildbot::slave records to setup with the master.
40 #
41 # [*slots*]
Felix Dahlke 2015/10/02 12:39:42 Frankly, I didn't understand what this is for, wit
mathias 2015/10/02 13:47:40 Acknowledged.
42 # Name => password pairs of e.g. remote build slaves.
43 # 44 #
44 # [*system*] 45 # [*system*]
45 # Any value beside 'false' will cause the master operations to also 46 # Any value beside 'false' will cause the master operations to also
46 # affect the buildbot::buildmaster service. Use this option to include 47 # affect the buildbot::buildmaster service. Use this option to include
47 # the master instance with the system daemon. 48 # the master instance with the system daemon.
48 # 49 #
49 # [*user*] 50 # [*user*]
50 # The user to whom the master instance belongs to. Note that the user 51 # The user to whom the master instance belongs to. Note that the user
51 # is not created implicitly by this setup, except if the creation is 52 # is not created implicitly by this setup, except if the creation is
52 # implied with any of the $buildbot::master_packages. 53 # implied with any of the $buildbot::master_packages.
53 # 54 #
54 # === Examples: 55 # === Examples:
55 # 56 #
56 # buildbot::master {'primary': 57 # buildbot::master {'primary':
57 # basedir => '/var/primary-buildmaster', 58 # basedir => '/var/primary-buildmaster',
58 # project => {'title' => 'Awesomeness'}, 59 # config => {'title' => 'Awesomeness'},
59 # } 60 # }
60 # 61 #
61 # buildbot::master {'secondary': 62 # buildbot::master {'secondary':
62 # basedir => '/var/secondary-buildmaster', 63 # basedir => '/var/secondary-buildmaster',
63 # ensure => absent, 64 # ensure => absent,
64 # } 65 # }
65 # 66 #
66 define buildbot::master ( 67 define buildbot::master (
67 $basedir = "$::buildbot::master_directory/$name", 68 $basedir = "$::buildbot::master_directory/$name",
68 $database = "sqlite:///state.sqlite", 69 $database = "sqlite:///state.sqlite",
69 $ensure = 'present', 70 $ensure = 'present',
70 $http_port = 8010, 71 $http_port = 8010,
71 $port = 9989, 72 $config = {},
72 $project = {},
73 $slaves = {}, 73 $slaves = {},
74 $slots = {}, 74 $slave_credentials = {},
75 $slave_port = 9989,
75 $system = false, 76 $system = false,
76 $user = $::buildbot::master_user, 77 $user = $::buildbot::master_user,
77 ) { 78 ) {
78 79
79 if $ensure !~ /^(absent|purged)$/ { 80 if $ensure !~ /^(absent|purged)$/ {
80 ensure_packages($::buildbot::master_packages) 81 ensure_packages($::buildbot::master_packages)
81 realize(File[$::buildbot::master_directory]) 82 realize(File[$::buildbot::master_directory])
82 83
83 exec {"buildmaster#$title": 84 exec {"buildmaster#$title":
84 command => shellquote([ 85 command => shellquote([
85 $::buildbot::master_runner, 86 $::buildbot::master_runner,
86 'create-master', 87 'create-master',
87 $basedir, 88 $basedir,
88 ]), 89 ]),
89 creates => "$basedir/buildbot.tac", 90 creates => "$basedir/buildbot.tac",
90 require => [ 91 require => [
91 File[$::buildbot::master_directory], 92 File[$::buildbot::master_directory],
92 Package[$::buildbot::master_packages], 93 Package[$::buildbot::master_packages],
93 ], 94 ],
94 user => $user, 95 user => $user,
95 } 96 }
96 97
97 Exec["buildmaster#$title"] <- Exec <|creates == $basedir|> 98 Exec["buildmaster#$title"] <- Exec <|creates == $basedir|>
98 Exec["buildmaster#$title"] <- File <|path == $basedir|> 99 Exec["buildmaster#$title"] <- File <|path == $basedir|>
99 100
100 $config = "$basedir/master.cfg" 101 $config_file = "$basedir/master.cfg"
101 102
102 @concat {$config: 103 @concat {$config_file:
103 owner => $user, 104 owner => $user,
104 require => Exec["buildmaster#$title"], 105 require => Exec["buildmaster#$title"],
105 } 106 }
106 107
107 @concat::fragment {$config: 108 @concat::fragment {$config_file:
108 content => template('buildbot/master.cfg.erb'), 109 content => template('buildbot/master.cfg.erb'),
109 target => $config, 110 target => $config_file,
110 } 111 }
111 112
112 if !empty($slaves) { 113 if !empty($slaves) {
113 create_resources('buildbot::slave', $slaves) 114 create_resources('buildbot::slave', $slaves)
114 realize(Concat[$config]) 115 realize(Concat[$config_file])
115 realize(Concat::Fragment[$config]) 116 realize(Concat::Fragment[$config_file])
116 } 117 }
117 } 118 }
118 119
119 if $system != false { 120 if $system != false {
120 ensure_packages($::buildbot::master_packages) 121 ensure_packages($::buildbot::master_packages)
121 realize(Concat['buildmaster']) 122 realize(Concat['buildmaster'])
122 realize(Concat::Fragment['buildmaster']) 123 realize(Concat::Fragment['buildmaster'])
123 realize(Service['buildmaster']) 124 realize(Service['buildmaster'])
124 125
125 concat::fragment {"buildmaster#$title": 126 concat::fragment {"buildmaster#$title":
126 content => template('buildbot/buildmaster_fragment.erb'), 127 content => template('buildbot/buildmaster_fragment.erb'),
127 ensure => $ensure ? {'present' => $ensure, default => 'absent'}, 128 ensure => $ensure ? {'present' => $ensure, default => 'absent'},
128 notify => Service['buildmaster'], 129 notify => Service['buildmaster'],
129 order => 1, 130 order => 1,
130 target => 'buildmaster', 131 target => 'buildmaster',
131 } 132 }
132 133
133 Service['buildmaster'] <~ Exec <|creates == "$basedir"|> 134 Service['buildmaster'] <~ Exec <|creates == "$basedir"|>
134 Service['buildmaster'] <~ Exec <|creates == "$basedir/buildbot.tac"|> 135 Service['buildmaster'] <~ Exec <|creates == "$basedir/buildbot.tac"|>
135 Service['buildmaster'] <~ Exec <|creates == "$basedir/master.cfg"|> 136 Service['buildmaster'] <~ Exec <|creates == "$basedir/master.cfg"|>
136 137
137 Service['buildmaster'] <~ File <|path == "$basedir"|> 138 Service['buildmaster'] <~ File <|path == "$basedir"|>
138 Service['buildmaster'] <~ File <|path == "$basedir/master.cfg"|> 139 Service['buildmaster'] <~ File <|path == "$basedir/master.cfg"|>
139 } 140 }
140 141
141 if $ensure == 'purged' { 142 if $ensure == 'purged' {
142 file {$basedir: ensure => 'absent'} 143 file {$basedir: ensure => 'absent'}
143 } 144 }
144 } 145 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld