diff --git a/modules/gerrit/manifests/init.pp b/modules/gerrit/manifests/init.pp index 900c4525d3..a086a7df4a 100644 --- a/modules/gerrit/manifests/init.pp +++ b/modules/gerrit/manifests/init.pp @@ -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': diff --git a/modules/gerrit/manifests/plugin.pp b/modules/gerrit/manifests/plugin.pp new file mode 100644 index 0000000000..828a598aa2 --- /dev/null +++ b/modules/gerrit/manifests/plugin.pp @@ -0,0 +1,78 @@ +# Copyright (C) 2014 R. Tyler Croy +# +# 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}", + } + +} diff --git a/modules/gerrit/manifests/user.pp b/modules/gerrit/manifests/user.pp new file mode 100644 index 0000000000..58fd610331 --- /dev/null +++ b/modules/gerrit/manifests/user.pp @@ -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'], + } + +} diff --git a/modules/jenkins/manifests/plugin.pp b/modules/jenkins/manifests/plugin.pp index f1b5f303d6..639df96830 100644 --- a/modules/jenkins/manifests/plugin.pp +++ b/modules/jenkins/manifests/plugin.pp @@ -1,3 +1,16 @@ +# Copyright (C) 2014 R. Tyler Croy +# +# 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. # diff --git a/modules/openstack_project/manifests/review.pp b/modules/openstack_project/manifests/review.pp index 6cd7ad2a41..ef9b31dbc7 100644 --- a/modules/openstack_project/manifests/review.pp +++ b/modules/openstack_project/manifests/review.pp @@ -182,6 +182,10 @@ class openstack_project::review ( ], } + gerrit::plugin { 'javamelody': + version => 'e00d5af', + } + class { 'gerritbot': nick => 'openstackgerrit', password => $gerritbot_password, diff --git a/modules/openstack_project/manifests/review_dev.pp b/modules/openstack_project/manifests/review_dev.pp index d5fb535218..3ec85bc298 100644 --- a/modules/openstack_project/manifests/review_dev.pp +++ b/modules/openstack_project/manifests/review_dev.pp @@ -83,6 +83,10 @@ class openstack_project::review_dev ( ], } + gerrit::plugin { 'javamelody': + version => 'e00d5af', + } + file { '/home/gerrit2/.launchpadlib': ensure => directory, owner => 'gerrit2',