Puppet Class: gerrit::install
- Defined in:
- manifests/install.pp
Overview
Class: gerrit::install
This class does the base installation of Gerrit any any required supporting applications. This class should not be called directly but only via Class
Parameters
This class accepts no parameters directly
Variables
The following variables are required
- download_location
-
Base location for downloading the Gerrit war from
- gerrit_home
-
The home directory for the gerrit user / installation path
- gerrit_site_options
-
Override options for installation of the 3 Gerrit site files. The format of this option hash is as follows: gerrit_site_options =>
'GerritSite.css' => [valid_file_resource_source], 'GerritSiteHeader.html' => [valid_file_resource_source], 'GerritSiteFooter.html' => [valid_file_resource_source],
If an option is not present then the default “blank” file will be used.
This hash is only used if manage_site_skin is true (default)
- gerrit_version
-
The version of the Gerrit war that will be downloaded
- install_default_plugins
-
Should the default plugins be installed? If true (default) then use the plugin_list array to specify which plugins specifically should be installed.
- install_git
-
Should this module make sure that git is installed? (NOTE: a git installation is required for Gerrit to be able to operate. If this is enabled [the default] then a module named ::git will be included puppetlabs/git is the expected module)
- install_gitweb
-
Should this module make sure that gitweb is installed? (NOTE: This will use the system package manager to install gitweb but will do no extra configuration as it will be expected to be managed via gerrit)
- install_java
-
Should this module make sure that a jre is installed? (NOTE: a jre installation is required for Gerrit to operate. If this is enabled
- the default
-
then a module named ::java will be included
puppetlabs/java is the expected module)
- manage_site_skin
-
Should the Gerrit site theming be managed by the module. If true passing an options hash to gerrit_site_options will override the default “blank” skin files.
- manage_static_site
-
Should the ~gerrit/static structure be managed by the module. If true then static_source must be set. default false
- plugin_list
-
An array specifying the default plugins that should be installed. The names are specified without the .jar The current plugins auto-installed are all from gerrit v2.9.3
- options
-
A variable hash for configuration settings of Gerrit. The base class will take the default options from gerrit::params and combine it with anything in override_options (if defined) and use that as the hash that is passed to gerrit::install
- static_source
-
A File resource source that will be recursively pushed if manage_static_site is set to true. All files in the source will be pushed to the ~gerrit/site
- third_party_plugins
-
A hash declaring all the third party plugins that are to be installed and where to acquire them.
Default: {}
example:
third_party_plugins => {
'delete-project' => { plugin_source => 'https://gerrit-ci.gerritforge.com/view/Plugins-stable-2.11/job/plugin-delete-project-stable-2.11/lastSuccessfulBuild/artifact/buck-out/gen/plugins/delete-project/delete-project.jar', }
}
Authors
Andrew Grimberg <agrimberg@linuxfoundation.org>
Copyright
Copyright 2014 Andrew Grimberg
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 |
# File 'manifests/install.pp', line 109
class gerrit::install (
$download_location,
$gerrit_home,
$gerrit_site_options,
$gerrit_version,
$install_default_plugins,
$install_git,
$install_gitweb,
$manage_site_skin,
$manage_static_site,
$install_java,
$options,
$plugin_list,
$static_source,
$third_party_plugins
) {
# Revalidate our variables just to be safe
validate_string($download_location)
validate_absolute_path($gerrit_home)
validate_hash($gerrit_site_options)
validate_string($gerrit_version)
validate_bool($install_default_plugins)
validate_bool($install_git)
validate_bool($install_gitweb)
validate_bool($install_java)
validate_bool($manage_site_skin)
validate_bool($manage_static_site)
validate_array($plugin_list)
validate_hash($options)
validate_hash($third_party_plugins)
# include the java class if we are to install java
if ($install_java) {
include '::java'
}
# include the git class if we are to install git
if ($install_git) {
include '::git'
}
# install gitweb if desired
if ($install_gitweb) {
package { 'gitweb':
ensure => installed,
}
}
# manage the user
$gerrit_user = $options['container']['user']
validate_string($gerrit_user)
user { $gerrit_user:
ensure => present,
comment => 'Gerrit Service User',
home => $gerrit_home,
managehome => true,
shell => '/bin/bash',
system => true,
}
# service script installation
case $::osfamily {
'RedHat': {
case $::operatingsystem {
'Fedora': {
if versioncmp($::operatingsystemrelease, '14') >= 0 {
$use_systemd = true
} else {
$use_systemd = false
}
}
# Default to EL systems
default: {
if versioncmp($::operatingsystemrelease, '7.0') >= 0 {
$use_systemd = true
} else {
$use_systemd = false
}
}
}
}
# We don't currently support not RH based systems
default: {
fail("${::osfamily} is not presently supported")
}
}
if ($use_systemd) {
# Previous versions of this module always used the shipped script
# this was a bad thing as puppet on systemd systems has issues
# knowing if a service was actually enabled for start on boot so
# we're going to make sure the old script is gone
file { 'gerrit_init_script':
ensure => absent,
path => '/etc/init.d/gerrit',
}
file { 'gerrit_systemd_script':
ensure => file,
path => '/usr/lib/systemd/system/gerrit.service',
owner => 'root',
group => 'root',
mode => '0644',
content => template("${module_name}/gerrit.service.erb"),
}
} else {
# link to the init script that ships with gerrit
file { 'gerrit_init_script':
ensure => link,
path => '/etc/init.d/gerrit',
target => "${gerrit_home}/bin/gerrit.sh",
}
}
# install gerrit site skin bits
if ($manage_site_skin) {
## GerritSite.css
if has_key($gerrit_site_options, 'GerritSite.css') {
validate_string($gerrit_site_options['GerritSite.css'])
$gerrit_css = $gerrit_site_options['GerritSite.css']
}
else {
$gerrit_css = 'puppet:///modules/gerrit/skin/GerritSite.css'
}
file { "${gerrit_home}/etc/GerritSite.css":
owner => $gerrit_user,
group => $gerrit_user,
source => $gerrit_css,
require => User[$gerrit_user],
}
## GerritSiteHeader.html
if has_key($gerrit_site_options, 'GerritSiteHeader.html') {
validate_string($gerrit_site_options['GerritSiteHeader.html'])
$gerrit_header = $gerrit_site_options['GerritSiteHeader.html']
}
else {
$gerrit_header = 'puppet:///modules/gerrit/skin/GerritSiteHeader.html'
}
file { "${gerrit_home}/etc/GerritSiteHeader.html":
owner => $gerrit_user,
group => $gerrit_user,
source => $gerrit_header,
require => User[$gerrit_user],
}
## GerritSiteFooter.html
if has_key($gerrit_site_options, 'GerritSiteFooter.html') {
validate_string($gerrit_site_options['GerritSiteFooter.html'])
$gerrit_footer = $gerrit_site_options['GerritSiteFooter.html']
}
else {
$gerrit_footer = 'puppet:///modules/gerrit/skin/GerritSiteFooter.html'
}
file { "${gerrit_home}/etc/GerritSiteFooter.html":
owner => $gerrit_user,
group => $gerrit_user,
source => $gerrit_footer,
require => User[$gerrit_user],
}
}
# manage static site content
if $manage_static_site {
# we need something, we can't easily check for all types of valid
# File resource sources, but it should be something _other_ than ''
if empty($static_source) {
fail('No static_source defined for gerrit static site')
}
# we could still do a validate string but at this point we should be
# pretty confidant we're dealing with something relatively valid
file { "${gerrit_home}/static":
ensure => directory,
owner => $gerrit_user,
group => $gerrit_user,
source => $static_source,
recurse => true,
purge => true,
require => User[$gerrit_user],
}
}
else {
# we still want to make sure that ${gerrit_home}/static is created
file { "${gerrit_home}/static":
ensure => directory,
owner => $gerrit_user,
group => $gerrit_user,
require => User[$gerrit_user],
}
}
# setup the installation directory structure and git storage
$gitpath = $options['gerrit']['basePath']
validate_absolute_path($gitpath)
file { [
"${gerrit_home}/bin",
"${gerrit_home}/etc",
"${gerrit_home}/lib",
"${gerrit_home}/logs",
"${gerrit_home}/plugins",
"${gerrit_home}/tmp",
$gitpath,
]:
ensure => directory,
owner => $gerrit_user,
group => $gerrit_user,
require => User[$gerrit_user],
}
# download gerrit
exec { "download gerrit ${gerrit_version}":
cwd => "${gerrit_home}/bin",
path => [ '/usr/bin', '/usr/sbin' ],
command => "curl -s -O ${download_location}/gerrit-${gerrit_version}.war",
creates => "${gerrit_home}/bin/gerrit-${gerrit_version}.war",
user => $gerrit_user,
group => $gerrit_user,
}
# install default plugins if needed
if ($install_default_plugins) {
file { "${gerrit_home}/extract_plugins":
ensure => directory,
owner => $gerrit_user,
group => $gerrit_user,
require => User[$gerrit_user],
}
exec{ 'extract_plugins':
cwd => "${gerrit_home}/extract_plugins",
path => [ '/usr/bin', '/usr/sbin' ],
command => "jar \
xf ${gerrit_home}/bin/gerrit-${gerrit_version}.war WEB-INF/plugins",
creates => "${gerrit_home}/extract_plugins/WEB-INF/plugins",
user => $gerrit_user,
group => $gerrit_user,
require => [
File["${gerrit_home}/extract_plugins"],
Exec["download gerrit ${gerrit_version}"]
],
}
gerrit::install::plugin_files { $plugin_list:
gerrit_home => $gerrit_home,
gerrit_user => $gerrit_user,
require => [
File["${gerrit_home}/plugins"],
Exec['extract_plugins']
],
}
}
# install third party plugins if needed
if (keys($third_party_plugins)) {
$third_party_plugin_defaults = {
gerrit_home => $gerrit_home,
gerrit_user => $gerrit_user,
}
create_resources('gerrit::install::third_party_plugin',
$third_party_plugins, $third_party_plugin_defaults
)
}
}
|