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_config*] |
| 24 # The path to the 'buildmaster' system configuration. |
| 25 # |
| 26 # [*master_directory*] |
| 27 # The anchestor of the default buildbot::master $basedir. |
| 28 # |
| 29 # [*master_pacakges*] |
| 30 # The packages that provide the buildbot::master dependencies. |
| 31 # |
| 32 # [*master_runner*] |
| 33 # The path to the runner used for buildbot::master instances. |
| 34 # |
| 35 # [*master_service*] |
| 36 # The status 'buildmaster' service status to ensure, if any. |
| 37 # |
| 38 # [*master_user*] |
| 39 # The user operating the 'buildmaster' service. |
| 40 # |
| 41 # [*slave_config*] |
| 42 # The path to the 'buildslave' system configuration. |
| 43 # |
| 44 # [*slave_directory*] |
| 45 # The anchestor of the default buildbot::slave $basedir. |
| 46 # |
| 47 # [*slave_pacakges*] |
| 48 # The packages that provide the buildbot::slave dependencies. |
| 49 # |
| 50 # [*slave_runner*] |
| 51 # The path to the runner used for buildbot::slave instances. |
| 52 # |
| 53 # [*slave_service*] |
| 54 # The status 'buildslave' service status to ensure, if any. |
| 55 # |
| 56 # [*slave_user*] |
| 57 # The user operating the 'buildslave' service. |
| 58 # |
| 59 # === Examples: |
| 60 # |
| 61 # class {'buildbot': |
| 62 # master => 'running', |
| 63 # } |
| 64 # |
| 65 class buildbot ( |
| 66 $master_config = '/etc/default/buildmaster', |
| 67 $master_directory = '/var/buildmaster', |
| 68 $master_packages = ['buildbot'], |
| 69 $master_runner = '/usr/bin/buildbot', |
| 70 $master_service = undef, |
| 71 $master_user = 'buildbot', |
| 72 $slave_config = '/etc/default/buildslave', |
| 73 $slave_directory = '/var/buildslave', |
| 74 $slave_packages = ['buildbot-slave'], |
| 75 $slave_runner = '/usr/bin/buildslave', |
| 76 $slave_service = undef, |
| 77 $slave_user = 'buildbot', |
| 78 ) { |
| 79 |
| 80 @concat { |
| 81 'buildmaster': |
| 82 owner => $master_user, |
| 83 path => $master_config, |
| 84 require => Package[$master_packages]; |
| 85 'buildslave': |
| 86 owner => $slave_user, |
| 87 path => $slave_config, |
| 88 require => Package[$slave_packages]; |
| 89 } |
| 90 |
| 91 @concat::fragment { |
| 92 'buildmaster': |
| 93 content => template('buildbot/buildmaster.erb'), |
| 94 order => 0, |
| 95 target => 'buildmaster'; |
| 96 'buildslave': |
| 97 content => template('buildbot/buildslave.erb'), |
| 98 order => 0, |
| 99 target => 'buildslave'; |
| 100 } |
| 101 |
| 102 @file { |
| 103 $master_directory: |
| 104 ensure => 'directory', |
| 105 owner => $master_user, |
| 106 require => Package[$master_packages]; |
| 107 $slave_directory: |
| 108 ensure => 'directory', |
| 109 owner => $slave_user, |
| 110 require => Package[$slave_packages]; |
| 111 } |
| 112 |
| 113 Service { |
| 114 hasrestart => true, |
| 115 hasstatus => false, |
| 116 } |
| 117 |
| 118 @service { |
| 119 'buildmaster': |
| 120 ensure => $master_service ? { |
| 121 /^(running|started|true)$/ => 'running', |
| 122 default => 'stopped', |
| 123 }, |
| 124 pattern => "^$master_user.*python.*$master_runner", |
| 125 require => Package[$master_packages]; |
| 126 'buildslave': |
| 127 ensure => $slave_service ? { |
| 128 /^(running|started|true)$/ => 'running', |
| 129 default => 'stopped', |
| 130 }, |
| 131 pattern => "^$slave_user.*python.*$slave_runner", |
| 132 require => Package[$slave_packages]; |
| 133 } |
| 134 |
| 135 Service['buildmaster'] <~ Exec <|creates == $master_config|> |
| 136 Service['buildmaster'] <~ File <|path == $master_config|> |
| 137 Service['buildmaster'] ~> |
| 138 |
| 139 Service['buildslave'] <~ Exec <|creates == $slave_config|> |
| 140 Service['buildslave'] <~ File <|path == $slave_config|> |
| 141 |
| 142 if $master_service != undef { |
| 143 ensure_packages($master_packages) |
| 144 realize(Service['buildmaster']) |
| 145 } |
| 146 |
| 147 if $slave_service != undef { |
| 148 ensure_packages($slave_packages) |
| 149 realize(Service['buildslave']) |
| 150 } |
| 151 } |
OLD | NEW |