From e3e9aaba10f4435280f0c6885755a5d4a7121607 Mon Sep 17 00:00:00 2001 From: Monty Taylor Date: Mon, 23 Jul 2012 09:22:57 -0500 Subject: [PATCH] Split gerritbot into its own module. Change-Id: Ia9034d87321624006ccf447b058ee828a97fcc7a --- modules/gerrit/manifests/init.pp | 52 ----------------- modules/{gerrit => gerritbot}/files/gerritbot | 0 .../files/gerritbot.init | 0 .../files/gerritbot_channel_config.yaml | 0 modules/gerritbot/manifests/init.pp | 56 +++++++++++++++++++ .../templates/gerritbot.config.erb | 8 +-- modules/openstack_project/manifests/gerrit.pp | 8 --- modules/openstack_project/manifests/review.pp | 10 ++-- 8 files changed, 66 insertions(+), 68 deletions(-) rename modules/{gerrit => gerritbot}/files/gerritbot (100%) rename modules/{gerrit => gerritbot}/files/gerritbot.init (100%) rename modules/{gerrit => gerritbot}/files/gerritbot_channel_config.yaml (100%) create mode 100644 modules/gerritbot/manifests/init.pp rename modules/{gerrit => gerritbot}/templates/gerritbot.config.erb (64%) diff --git a/modules/gerrit/manifests/init.pp b/modules/gerrit/manifests/init.pp index cbab26f556..8fab2cf3ab 100644 --- a/modules/gerrit/manifests/init.pp +++ b/modules/gerrit/manifests/init.pp @@ -46,7 +46,6 @@ # Gerrit will be upgraded on the next puppet run. # TODO: move closing github pull requests to another module -# TODO: move gerritbot configuration to another module # TODO: move apache configuration to another module # TODO: move mysql configuration to another module # TODO: make more gerrit options configurable here @@ -90,10 +89,6 @@ class gerrit($virtual_hostname='', $script_site, $enable_melody = 'false', $melody_session = 'false', - $gerritbot_nick, - $gerritbot_password, - $gerritbot_server, - $gerritbot_user, $github_user, $github_token, $mysql_password, @@ -191,43 +186,6 @@ class gerrit($virtual_hostname='', require => File['/usr/local/gerrit/scripts'], } - file { "/usr/local/gerrit/gerritbot": - owner => 'root', - group => 'root', - mode => 555, - ensure => 'present', - source => 'puppet:///modules/gerrit/gerritbot', - } - - file { "/etc/init.d/gerritbot": - owner => 'root', - group => 'root', - mode => 555, - ensure => 'present', - source => 'puppet:///modules/gerrit/gerritbot.init', - require => File['/usr/local/gerrit/gerritbot'], - } - - file { "/home/gerrit2/gerritbot_channel_config.yaml": - owner => 'root', - group => 'gerrit2', - mode => 440, - ensure => 'present', - source => 'puppet:///modules/gerrit/gerritbot_channel_config.yaml', - replace => true, - require => User['gerrit2'] - } - - service { 'gerritbot': - name => 'gerritbot', - ensure => running, - enable => true, - hasrestart => true, - require => File['/etc/init.d/gerritbot'], - subscribe => [File["/usr/local/gerrit/gerritbot"], - File["/home/gerrit2/gerritbot_channel_config.yaml"]], - } - } # testmode==false file { "/var/log/gerrit": @@ -376,16 +334,6 @@ class gerrit($virtual_hostname='', require => User['gerrit2'] } - file { '/home/gerrit2/gerritbot.config': - owner => 'root', - group => 'gerrit2', - mode => 440, - ensure => 'present', - content => template('gerrit/gerritbot.config.erb'), - replace => 'true', - require => User['gerrit2'] - } - # Gerrit sets these permissions in 'init'; don't fight them. If # these permissions aren't set correctly, gerrit init will write a # new secure.config file and lose the mysql password. diff --git a/modules/gerrit/files/gerritbot b/modules/gerritbot/files/gerritbot similarity index 100% rename from modules/gerrit/files/gerritbot rename to modules/gerritbot/files/gerritbot diff --git a/modules/gerrit/files/gerritbot.init b/modules/gerritbot/files/gerritbot.init similarity index 100% rename from modules/gerrit/files/gerritbot.init rename to modules/gerritbot/files/gerritbot.init diff --git a/modules/gerrit/files/gerritbot_channel_config.yaml b/modules/gerritbot/files/gerritbot_channel_config.yaml similarity index 100% rename from modules/gerrit/files/gerritbot_channel_config.yaml rename to modules/gerritbot/files/gerritbot_channel_config.yaml diff --git a/modules/gerritbot/manifests/init.pp b/modules/gerritbot/manifests/init.pp new file mode 100644 index 0000000000..e5ab9abc52 --- /dev/null +++ b/modules/gerritbot/manifests/init.pp @@ -0,0 +1,56 @@ +class gerritbot( + $nick, + $password, + $server, + $user + ) { + + file { "/usr/local/gerrit/gerritbot": + owner => 'root', + group => 'root', + mode => 555, + ensure => 'present', + source => 'puppet:///modules/gerrit/gerritbot', + require => File['/usr/local/gerrit'], + } + + file { "/etc/init.d/gerritbot": + owner => 'root', + group => 'root', + mode => 555, + ensure => 'present', + source => 'puppet:///modules/gerrit/gerritbot.init', + require => File['/usr/local/gerrit/gerritbot'], + } + + file { "/home/gerrit2/gerritbot_channel_config.yaml": + owner => 'root', + group => 'gerrit2', + mode => 440, + ensure => 'present', + source => 'puppet:///modules/gerrit/gerritbot_channel_config.yaml', + replace => true, + require => User['gerrit2'], + } + + service { 'gerritbot': + name => 'gerritbot', + ensure => running, + enable => true, + hasrestart => true, + require => File['/etc/init.d/gerritbot'], + subscribe => [File["/usr/local/gerrit/gerritbot"], + File["/home/gerrit2/gerritbot_channel_config.yaml"]], + } + + file { '/home/gerrit2/gerritbot.config': + owner => 'root', + group => 'gerrit2', + mode => 440, + ensure => 'present', + content => template('gerrit/gerritbot.config.erb'), + replace => 'true', + require => User['gerrit2'] + } + +} diff --git a/modules/gerrit/templates/gerritbot.config.erb b/modules/gerritbot/templates/gerritbot.config.erb similarity index 64% rename from modules/gerrit/templates/gerritbot.config.erb rename to modules/gerritbot/templates/gerritbot.config.erb index a4f373f75b..5bcb5658ca 100644 --- a/modules/gerrit/templates/gerritbot.config.erb +++ b/modules/gerritbot/templates/gerritbot.config.erb @@ -1,13 +1,13 @@ [ircbot] -nick=<%= gerritbot_nick %> -pass=<%= gerritbot_password %> -server=<%= gerritbot_server %> +nick=<%= nick %> +pass=<%= password %> +server=<%= server %> port=6667 channel_config=/home/gerrit2/gerritbot_channel_config.yaml lockfile=/var/run/gerritbot/gerritbot.pid [gerrit] -user=<%= gerritbot_user %> +user=<%= user %> key=/home/gerrit2/.ssh/gerritbot_rsa host=<%= virtual_hostname %> port=29418 diff --git a/modules/openstack_project/manifests/gerrit.pp b/modules/openstack_project/manifests/gerrit.pp index adcf531120..15616bbf35 100644 --- a/modules/openstack_project/manifests/gerrit.pp +++ b/modules/openstack_project/manifests/gerrit.pp @@ -18,10 +18,6 @@ class openstack_project::gerrit ( $war, $script_user, $script_key_file, - $gerritbot_nick='', - $gerritbot_password='', - $gerritbot_server='', - $gerritbot_user='', $github_user, $github_token, $mysql_password, @@ -59,10 +55,6 @@ class openstack_project::gerrit ( war => $war, script_user => $script_user, script_key_file => $script_key_file, - gerritbot_nick => $gerritbot_nick, - gerritbot_password => $gerritbot_password, - gerritbot_server => $gerritbot_server, - gerritbot_user => $gerritbot_user, github_user => $github_user, github_token => $github_token, mysql_password => $mysql_password, diff --git a/modules/openstack_project/manifests/review.pp b/modules/openstack_project/manifests/review.pp index 306caa20d7..325cfe3c69 100644 --- a/modules/openstack_project/manifests/review.pp +++ b/modules/openstack_project/manifests/review.pp @@ -45,13 +45,15 @@ class openstack_project::review { war => 'http://tarballs.openstack.org/ci/gerrit-2.4.1-10-g63110fd.war', script_user => 'launchpadsync', script_key_file => '/home/gerrit2/.ssh/launchpadsync_rsa', - gerritbot_nick => 'openstackgerrit', - gerritbot_password => hiera('gerrit_gerritbot_password'), - gerritbot_server => 'irc.freenode.net', - gerritbot_user => 'gerritbot', github_user => 'openstack-gerrit', github_token => hiera('gerrit_github_token'), mysql_password => hiera('gerrit_mysql_password'), email_private_key => hiera('gerrit_email_private_key'), } + class { 'gerritbot': + gerritbot_nick => 'openstackgerrit', + gerritbot_password => hiera('gerrit_gerritbot_password'), + gerritbot_server => 'irc.freenode.net', + gerritbot_user => 'gerritbot' + } }