| LEFT | RIGHT |
| 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 |
| 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. |
| 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*] |
| 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*] |
| 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*] | |
| 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 } |
| LEFT | RIGHT |