Left: | ||
Right: |
OLD | NEW |
---|---|
(Empty) | |
1 # == Class: buildbot | |
2 # | |
3 # Manage Buildbot (https://buildbot.net/) master and slave setups. | |
4 # | |
5 # Class buildbot acts as the root namespace for the buildbot integration | |
6 # with Puppet, while also providing a variety of setup parameters that can | |
7 # be used to adjust the software setup. | |
8 # | |
9 # It defines a set of virtual resources titled 'buildmaster' and 'buildslave'. | |
10 # Those are realized implicitly when required by any of the various entities | |
11 # within the module, but may become realized explicitely when necessary: | |
12 # | |
13 # - Concat[]: The 'buildmaster' and 'buildslave' system daemon configuration | |
14 # - Concat::Fragment[]: The respective root or configuration head fragment | |
15 # - File[]: The anchestor of default for master and slave $basedir resources | |
16 # - Service[]: The actual services running the master and slave instances | |
17 # | |
18 # Note, however, that the respective instances are rather implementation | |
19 # specific and thus may become subject to change in the future. | |
20 # | |
21 # === Parameters: | |
22 # | |
23 # [*master_service*] | |
24 # The 'buildmaster' service status to ensure, if any. | |
25 # | |
26 # [*slave_service*] | |
27 # The 'buildslave' service status to ensure, if any. | |
28 # | |
29 # === Examples: | |
30 # | |
31 # class {'buildbot': | |
32 # master_service => 'running', | |
33 # } | |
34 # | |
35 class buildbot ( | |
36 $master_service = undef, | |
37 $slave_service = undef, | |
38 ) { | |
39 | |
40 $master_config = '/etc/default/buildmaster' | |
41 $master_directory = '/var/buildmaster' | |
42 $master_packages = ['buildbot'] | |
43 $master_runner = '/usr/bin/buildbot' | |
44 $master_user = 'buildbot' | |
45 | |
46 $slave_config = '/etc/default/buildslave' | |
47 $slave_directory = '/var/buildslave' | |
48 $slave_packages = ['buildbot-slave'] | |
49 $slave_runner = '/usr/bin/buildslave' | |
50 $slave_user = 'buildbot' | |
51 | |
52 @concat { | |
53 'buildmaster': | |
54 owner => $master_user, | |
55 path => $master_config, | |
56 require => Package[$master_packages]; | |
57 'buildslave': | |
58 owner => $slave_user, | |
59 path => $slave_config, | |
60 require => Package[$slave_packages]; | |
61 } | |
62 | |
63 @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
| |
64 'buildmaster': | |
65 content => template('buildbot/buildmaster.erb'), | |
66 order => 0, | |
67 target => 'buildmaster'; | |
68 'buildslave': | |
69 content => template('buildbot/buildslave.erb'), | |
70 order => 0, | |
71 target => 'buildslave'; | |
72 } | |
73 | |
74 @file { | |
75 $master_directory: | |
76 ensure => 'directory', | |
77 owner => $master_user, | |
78 require => Package[$master_packages]; | |
79 $slave_directory: | |
80 ensure => 'directory', | |
81 owner => $slave_user, | |
82 require => Package[$slave_packages]; | |
83 } | |
84 | |
85 Service { | |
86 hasrestart => true, | |
87 hasstatus => false, | |
88 } | |
89 | |
90 @service { | |
91 'buildmaster': | |
92 ensure => $master_service ? { | |
93 /^(running|started|true)$/ => 'running', | |
94 default => 'stopped', | |
95 }, | |
96 pattern => "^$master_user.*python.*$master_runner", | |
97 require => Package[$master_packages]; | |
98 'buildslave': | |
99 ensure => $slave_service ? { | |
100 /^(running|started|true)$/ => 'running', | |
101 default => 'stopped', | |
102 }, | |
103 pattern => "^$slave_user.*python.*$slave_runner", | |
104 require => Package[$slave_packages]; | |
105 } | |
106 | |
107 Service['buildmaster'] <~ Exec <|creates == $master_config|> | |
108 Service['buildmaster'] <~ File <|path == $master_config|> | |
109 Service['buildmaster'] ~> | |
110 | |
111 Service['buildslave'] <~ Exec <|creates == $slave_config|> | |
112 Service['buildslave'] <~ File <|path == $slave_config|> | |
113 | |
114 if $master_service != undef { | |
115 ensure_packages($master_packages) | |
116 realize(Service['buildmaster']) | |
117 } | |
118 | |
119 if $slave_service != undef { | |
120 ensure_packages($slave_packages) | |
121 realize(Service['buildslave']) | |
122 } | |
123 } | |
OLD | NEW |