Left: | ||
Right: |
OLD | NEW |
---|---|
(Empty) | |
1 # == Type: buildbot::master | |
2 # | |
3 # Manage Buildbot (http://buildbot.net/) master instances. | |
4 # | |
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. | |
7 # One may either realize these resources (as done so by master::fragment | |
8 # implicitly, for example) or use a custom approach for setting up the | |
9 # configuration. | |
10 # | |
11 # === Parameters: | |
12 # | |
13 # [*basedir*] | |
14 # The base directory of the master, which can be configured elsewhere or, | |
15 # if it's ancestors are present, relied upon the builtin defaults. | |
16 # | |
17 # [*database*] | |
18 # Translates directly into the BuildmasterConfig['db_url'] configuration | |
19 # option within the master.cfg file. | |
20 # | |
21 # [*ensure*] | |
22 # 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.
| |
23 # remove the associated resources. Note that only 'purged' implies the | |
24 # removal of $basedir. | |
25 # | |
26 # [*http_port*] | |
27 # Translates directly into the port portion of the BuildmasterConfig's | |
28 # 'buildbotURL', but may be used in other places as well. | |
29 # | |
30 # [*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
| |
31 # A hash to optionally contain a 'title' (which translats into the config | |
32 # 'title' option) and an 'url' (translates into the 'titleURL'). | |
33 # | |
34 # [*slaves*] | |
35 # 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.
| |
36 # | |
37 # [*slave_credentials*] | |
38 # Name => password pairs of e.g. remote build slaves. | |
39 # | |
40 # [*slave_port*] | |
41 # Translates directly into the BuildmasterConfig['slavePortnum'] option | |
42 # within the master.cfg file. | |
43 # | |
44 # [*system*] | |
45 # Any value beside 'false' will cause the master operations to also | |
46 # affect the buildbot::buildmaster service. Use this option to include | |
47 # the master instance with the system daemon. | |
48 # | |
49 # [*user*] | |
50 # 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 # implied with any of the $buildbot::master_packages. | |
53 # | |
54 # === Examples: | |
55 # | |
56 # buildbot::master {'primary': | |
57 # basedir => '/var/primary-buildmaster', | |
58 # project => {'title' => 'Awesomeness'}, | |
59 # } | |
60 # | |
61 # buildbot::master {'secondary': | |
62 # basedir => '/var/secondary-buildmaster', | |
63 # ensure => absent, | |
64 # } | |
65 # | |
66 define buildbot::master ( | |
67 $basedir = "$::buildbot::master_directory/$name", | |
68 $database = "sqlite:///state.sqlite", | |
69 $ensure = 'present', | |
70 $http_port = 8010, | |
71 $project = {}, | |
72 $slaves = {}, | |
73 $slave_credentials = {}, | |
74 $slave_port = 9989, | |
75 $system = false, | |
76 $user = $::buildbot::master_user, | |
77 ) { | |
78 | |
79 if $ensure !~ /^(absent|purged)$/ { | |
80 ensure_packages($::buildbot::master_packages) | |
81 realize(File[$::buildbot::master_directory]) | |
82 | |
83 exec {"buildmaster#$title": | |
84 command => shellquote([ | |
85 $::buildbot::master_runner, | |
86 'create-master', | |
87 $basedir, | |
88 ]), | |
89 creates => "$basedir/buildbot.tac", | |
90 require => [ | |
91 File[$::buildbot::master_directory], | |
92 Package[$::buildbot::master_packages], | |
93 ], | |
94 user => $user, | |
95 } | |
96 | |
97 Exec["buildmaster#$title"] <- Exec <|creates == $basedir|> | |
98 Exec["buildmaster#$title"] <- File <|path == $basedir|> | |
99 | |
100 $config = "$basedir/master.cfg" | |
101 | |
102 @concat {$config: | |
103 owner => $user, | |
104 require => Exec["buildmaster#$title"], | |
105 } | |
106 | |
107 @concat::fragment {$config: | |
108 content => template('buildbot/master.cfg.erb'), | |
109 target => $config, | |
110 } | |
111 | |
112 if !empty($slaves) { | |
113 create_resources('buildbot::slave', $slaves) | |
114 realize(Concat[$config]) | |
115 realize(Concat::Fragment[$config]) | |
116 } | |
117 } | |
118 | |
119 if $system != false { | |
120 ensure_packages($::buildbot::master_packages) | |
121 realize(Concat['buildmaster']) | |
122 realize(Concat::Fragment['buildmaster']) | |
123 realize(Service['buildmaster']) | |
124 | |
125 concat::fragment {"buildmaster#$title": | |
126 content => template('buildbot/buildmaster_fragment.erb'), | |
127 ensure => $ensure ? {'present' => $ensure, default => 'absent'}, | |
128 notify => Service['buildmaster'], | |
129 order => 1, | |
130 target => 'buildmaster', | |
131 } | |
132 | |
133 Service['buildmaster'] <~ Exec <|creates == "$basedir"|> | |
134 Service['buildmaster'] <~ Exec <|creates == "$basedir/buildbot.tac"|> | |
135 Service['buildmaster'] <~ Exec <|creates == "$basedir/master.cfg"|> | |
136 | |
137 Service['buildmaster'] <~ File <|path == "$basedir"|> | |
138 Service['buildmaster'] <~ File <|path == "$basedir/master.cfg"|> | |
139 } | |
140 | |
141 if $ensure == 'purged' { | |
142 file {$basedir: ensure => 'absent'} | |
143 } | |
144 } | |
OLD | NEW |