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 its 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 set up the master (anything but 'absent' or 'purged') or |
| 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 # [*config*] |
| 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*] |
| 42 # Translates directly into the BuildmasterConfig['slavePortnum'] option |
| 43 # within the master.cfg file. |
| 44 # |
| 45 # [*system*] |
| 46 # Any value beside 'false' will cause the master operations to also |
| 47 # affect the buildbot::buildmaster service. Use this option to include |
| 48 # the master instance with the system daemon. |
| 49 # |
| 50 # [*user*] |
| 51 # The user to whom the master instance belongs to. Note that the user |
| 52 # is not created implicitly by this setup, except if the creation is |
| 53 # implied with any of the $buildbot::master_packages. |
| 54 # |
| 55 # === Examples: |
| 56 # |
| 57 # buildbot::master {'primary': |
| 58 # basedir => '/var/primary-buildmaster', |
| 59 # config => {'title' => 'Awesomeness'}, |
| 60 # } |
| 61 # |
| 62 # buildbot::master {'secondary': |
| 63 # basedir => '/var/secondary-buildmaster', |
| 64 # ensure => absent, |
| 65 # } |
| 66 # |
| 67 define buildbot::master ( |
| 68 $basedir = "$::buildbot::master_directory/$name", |
| 69 $database = "sqlite:///state.sqlite", |
| 70 $ensure = 'present', |
| 71 $http_port = 8010, |
| 72 $config = {}, |
| 73 $slaves = {}, |
| 74 $slave_credentials = {}, |
| 75 $slave_port = 9989, |
| 76 $system = false, |
| 77 $user = $::buildbot::master_user, |
| 78 ) { |
| 79 |
| 80 if $ensure !~ /^(absent|purged)$/ { |
| 81 ensure_packages($::buildbot::master_packages) |
| 82 realize(File[$::buildbot::master_directory]) |
| 83 |
| 84 exec {"buildmaster#$title": |
| 85 command => shellquote([ |
| 86 $::buildbot::master_runner, |
| 87 'create-master', |
| 88 $basedir, |
| 89 ]), |
| 90 creates => "$basedir/buildbot.tac", |
| 91 require => [ |
| 92 File[$::buildbot::master_directory], |
| 93 Package[$::buildbot::master_packages], |
| 94 ], |
| 95 user => $user, |
| 96 } |
| 97 |
| 98 Exec["buildmaster#$title"] <- Exec <|creates == $basedir|> |
| 99 Exec["buildmaster#$title"] <- File <|path == $basedir|> |
| 100 |
| 101 $config_file = "$basedir/master.cfg" |
| 102 |
| 103 @concat {$config_file: |
| 104 owner => $user, |
| 105 require => Exec["buildmaster#$title"], |
| 106 } |
| 107 |
| 108 @concat::fragment {$config_file: |
| 109 content => template('buildbot/master.cfg.erb'), |
| 110 target => $config_file, |
| 111 } |
| 112 |
| 113 if !empty($slaves) { |
| 114 create_resources('buildbot::slave', $slaves) |
| 115 realize(Concat[$config_file]) |
| 116 realize(Concat::Fragment[$config_file]) |
| 117 } |
| 118 } |
| 119 |
| 120 if $system != false { |
| 121 ensure_packages($::buildbot::master_packages) |
| 122 realize(Concat['buildmaster']) |
| 123 realize(Concat::Fragment['buildmaster']) |
| 124 realize(Service['buildmaster']) |
| 125 |
| 126 concat::fragment {"buildmaster#$title": |
| 127 content => template('buildbot/buildmaster_fragment.erb'), |
| 128 ensure => $ensure ? {'present' => $ensure, default => 'absent'}, |
| 129 notify => Service['buildmaster'], |
| 130 order => 1, |
| 131 target => 'buildmaster', |
| 132 } |
| 133 |
| 134 Service['buildmaster'] <~ Exec <|creates == "$basedir"|> |
| 135 Service['buildmaster'] <~ Exec <|creates == "$basedir/buildbot.tac"|> |
| 136 Service['buildmaster'] <~ Exec <|creates == "$basedir/master.cfg"|> |
| 137 |
| 138 Service['buildmaster'] <~ File <|path == "$basedir"|> |
| 139 Service['buildmaster'] <~ File <|path == "$basedir/master.cfg"|> |
| 140 } |
| 141 |
| 142 if $ensure == 'purged' { |
| 143 file {$basedir: ensure => 'absent'} |
| 144 } |
| 145 } |
OLD | NEW |