puppetize installation of gerrit third party plugins

This change automates the installation of gerrit third party plugins.  This
does not include core plugins, which have already been automated.  The first
third party plugin that we automate is the javamelody plugin.

Change-Id: I163353c2e9d59e4815b4544f983b54d68ede70a8
This commit is contained in:
Khai Do 2014-04-29 16:17:23 -07:00
parent 8bf3764d9c
commit 583be07992
6 changed files with 127 additions and 13 deletions

View File

@ -164,19 +164,7 @@ class gerrit(
$gerrit_war = '/home/gerrit2/review_site/bin/gerrit.war'
$gerrit_site = '/home/gerrit2/review_site'
user { 'gerrit2':
ensure => present,
comment => 'Gerrit',
home => '/home/gerrit2',
shell => '/bin/bash',
gid => 'gerrit2',
managehome => true,
require => Group['gerrit2'],
}
group { 'gerrit2':
ensure => present,
}
include gerrit::user
if ($gitweb) {
package { 'gitweb':

View File

@ -0,0 +1,78 @@
# Copyright (C) 2014 R. Tyler Croy <tyler@monkeypox.org>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Defined resource type to install gerrit plugins.
#
# Borrowed from: https://github.com/jenkinsci/puppet-jenkins
#
define gerrit::plugin(
$version=0,
) {
$base_plugin = "${name}.jar"
$plugin = "${name}-${version}.jar"
$plugin_cache_dir = '/home/gerrit2/gerrit-plugins'
$plugin_dir = '/home/gerrit2/review_site/plugins'
$plugin_parent_dir = '/home/gerrit2/review_site'
$base_url = "http://tarballs.openstack.org/ci/gerrit/plugins/${name}"
include gerrit::user
# This directory is used to download and cache gerrit plugin files.
# That way the download and install steps are kept separate.
if (!defined(File[$plugin_cache_dir])) {
file { $plugin_cache_dir:
ensure => directory,
owner => 'gerrit2',
group => 'gerrit2',
require => [
File[$plugin_parent_dir],
Class['gerrit::user'],
],
}
}
# If we don't already have the specified plugin, download it.
exec { "download-${plugin}":
command => "wget ${base_url}/${plugin} -O ${plugin_cache_dir}/${plugin}",
path => ['/bin','/usr/bin', '/usr/sbin', '/usr/local/bin'],
creates => "${plugin_cache_dir}/${plugin}",
user => 'gerrit2',
require => [
File[$plugin_cache_dir],
Class['gerrit::user'],
],
}
if (!defined(File[$plugin_dir])) {
file { $plugin_dir:
ensure => directory,
owner => 'gerrit2',
group => 'gerrit2',
require => [
File[$plugin_parent_dir],
Class['gerrit::user'],
],
}
}
exec { "install-${base_plugin}":
command => "cp ${plugin_cache_dir}/${plugin} ${plugin_dir}/${base_plugin}",
path => ['/bin','/usr/bin', '/usr/sbin', '/usr/local/bin'],
require => Exec["download-${plugin}"],
user => 'gerrit2',
unless => "test -f ${plugin_dir}/${base_plugin}",
}
}

View File

@ -0,0 +1,27 @@
# == Class: gerrit::user
#
class gerrit::user {
group { 'gerrit2':
ensure => present,
}
user { 'gerrit2':
ensure => present,
comment => 'Gerrit2 User',
home => '/home/gerrit2',
gid => 'gerrit2',
shell => '/bin/bash',
membership => 'minimum',
require => Group['gerrit2'],
}
file { '/home/gerrit2':
ensure => directory,
owner => 'gerrit2',
group => 'gerrit2',
mode => '0644',
require => User['gerrit2'],
}
}

View File

@ -1,3 +1,16 @@
# Copyright (C) 2014 R. Tyler Croy <tyler@monkeypox.org>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Defined resource type to install jenkins plugins.
#

View File

@ -182,6 +182,10 @@ class openstack_project::review (
],
}
gerrit::plugin { 'javamelody':
version => 'e00d5af',
}
class { 'gerritbot':
nick => 'openstackgerrit',
password => $gerritbot_password,

View File

@ -83,6 +83,10 @@ class openstack_project::review_dev (
],
}
gerrit::plugin { 'javamelody':
version => 'e00d5af',
}
file { '/home/gerrit2/.launchpadlib':
ensure => directory,
owner => 'gerrit2',