From 5d5a435dbfc183780cdc9382f0ac6d9c90930e06 Mon Sep 17 00:00:00 2001 From: Elizabeth Krumbach Date: Wed, 20 Mar 2013 10:39:08 -0700 Subject: [PATCH] Refactor reviewday into class and definition The reviewday puppet files have been split between static class and a definition that pulls several variables for openstack-specific use. Change-Id: Ibeb450900a75269c4c8a5aaaa51fb105aff7af15 Reviewed-on: https://review.openstack.org/24915 Reviewed-by: Jeremy Stanley Approved: James E. Blair Reviewed-by: James E. Blair Tested-by: Jenkins --- modules/openstack_project/manifests/static.pp | 10 ++- .../templates/status.vhost.erb | 10 +-- modules/reviewday/manifests/init.pp | 66 +++-------------- modules/reviewday/manifests/site.pp | 71 ++++++++++++++----- .../reviewday/templates/reviewday.vhost.erb | 10 --- modules/reviewday/templates/ssh_config.erb | 4 +- 6 files changed, 73 insertions(+), 98 deletions(-) delete mode 100644 modules/reviewday/templates/reviewday.vhost.erb diff --git a/modules/openstack_project/manifests/static.pp b/modules/openstack_project/manifests/static.pp index d8b3ada536..fd28b521fc 100644 --- a/modules/openstack_project/manifests/static.pp +++ b/modules/openstack_project/manifests/static.pp @@ -156,12 +156,10 @@ class openstack_project::static ( include reviewday - reviewday::site { 'reviewday.openstack.org': - git_url => 'https://github.com/openstack-infra/reviewday.git', - serveradmin => 'webmaster@openstack.org', - httproot => "/srv/static/${name}", - } - reviewday::init { 'reviewday.openstack.org': + reviewday::site { 'reviewday': + git_url => 'https://github.com/openstack-infra/reviewday.git', + serveradmin => 'webmaster@openstack.org', + httproot => '/srv/static/reviewday', gerrit_url => 'review.openstack.org', gerrit_port => '29418', gerrit_user => 'reviewday', diff --git a/modules/openstack_project/templates/status.vhost.erb b/modules/openstack_project/templates/status.vhost.erb index 60b0e2bdea..20d5ae3df0 100644 --- a/modules/openstack_project/templates/status.vhost.erb +++ b/modules/openstack_project/templates/status.vhost.erb @@ -35,13 +35,6 @@ NameVirtualHost <%= vhost_name %>:<%= port %> Allow from all - RewriteRule ^/reviews$ /reviews/ [R] - RewriteRule ^/reviews/(.*)$ http://old-wiki.openstack.org/reviews/$1 [P] - - Order allow,deny - Allow from all - - RewriteRule ^/bugday$ /bugday/ [R] RewriteRule ^/bugday/(.*)$ http://old-wiki.openstack.org/bugday/$1 [P] @@ -49,12 +42,15 @@ NameVirtualHost <%= vhost_name %>:<%= port %> Allow from all + Alias /reviews <%= $reviewday::site::httproot %> + > Options <%= options %> AllowOverride None Order allow,deny allow from all + ErrorLog /var/log/apache2/<%= name %>_error.log LogLevel warn CustomLog /var/log/apache2/<%= name %>_access.log combined diff --git a/modules/reviewday/manifests/init.pp b/modules/reviewday/manifests/init.pp index 2fa07c3afd..830afefb8f 100644 --- a/modules/reviewday/manifests/init.pp +++ b/modules/reviewday/manifests/init.pp @@ -12,24 +12,17 @@ # License for the specific language governing permissions and limitations # under the License. # -# Define: reviewday +# Class: reviewday # -define reviewday::init( - $gerrit_url = '', - $gerrit_port = '', - $gerrit_user = '', - $reviewday_rsa_key_contents = '', - $reviewday_rsa_pubkey_contents = '', - $reviewday_gerrit_ssh_key = '' -) { - if ! defined(Package['python-launchpadlib']) { - package { 'python-launchpadlib': - ensure => present, - } - } - package { 'python-cheetah': +class reviewday { + if ! defined(Package['python-launchpadlib']) { + package { 'python-launchpadlib': ensure => present, } + } + package { 'python-cheetah': + ensure => present, + } group { 'reviewday': ensure => present, @@ -37,54 +30,13 @@ define reviewday::init( user { 'reviewday': ensure => present, - home => "/var/lib/${name}", + home => '/var/lib/reviewday', shell => '/bin/bash', gid => 'reviewday', managehome => true, require => Group['reviewday'], } - file { "/var/lib/${name}/.ssh/": - ensure => directory, - owner => 'reviewday', - group => 'reviewday', - mode => '0700', - require => User['reviewday'], - } - - if $reviewday_rsa_key_contents != '' { - file { "/var/lib/${name}/.ssh/id_rsa": - owner => 'reviewday', - group => 'reviewday', - mode => '0600', - content => $reviewday_rsa_key_contents, - replace => true, - require => File["/var/lib/${name}/.ssh/"] - } - } - - if $reviewday_rsa_pubkey_contents != '' { - file { "/var/lib/${name}/.ssh/id_rsa.pub": - owner => 'reviewday', - group => 'reviewday', - mode => '0600', - content => $reviewday_rsa_pubkey_contents, - replace => true, - require => File["/var/lib/${name}/.ssh/"] - } - } - - if $reviewday_gerrit_ssh_key != '' { - file { "/var/lib/${name}/.ssh/known_hosts": - owner => 'reviewday', - group => 'reviewday', - mode => '0600', - content => $reviewday_gerrit_ssh_key, - replace => true, - require => File["/var/lib/${name}/.ssh/"] - } - } - } # vim:sw=2:ts=2:expandtab:textwidth=79 diff --git a/modules/reviewday/manifests/site.pp b/modules/reviewday/manifests/site.pp index 9581b455c1..59268392d7 100644 --- a/modules/reviewday/manifests/site.pp +++ b/modules/reviewday/manifests/site.pp @@ -15,26 +15,64 @@ # == Define: reviewday # define reviewday::site( + $gerrit_url = '', + $gerrit_port = '', + $gerrit_user = '', + $reviewday_rsa_key_contents = '', + $reviewday_rsa_pubkey_contents = '', + $reviewday_gerrit_ssh_key = '', $git_url = '', $httproot = '', - $serveradmin = '', + $serveradmin = '' ) { - include apache - vcsrepo { "/var/lib/${name}/reviewday": + file { '/var/lib/reviewday/.ssh/': + ensure => directory, + owner => 'reviewday', + group => 'reviewday', + mode => '0700', + require => User['reviewday'], + } + + if $reviewday_rsa_key_contents != '' { + file { '/var/lib/reviewday/.ssh/id_rsa': + owner => 'reviewday', + group => 'reviewday', + mode => '0600', + content => $reviewday_rsa_key_contents, + replace => true, + require => File['/var/lib/reviewday/.ssh/'] + } + } + + if $reviewday_rsa_pubkey_contents != '' { + file { '/var/lib/reviewday/.ssh/id_rsa.pub': + owner => 'reviewday', + group => 'reviewday', + mode => '0600', + content => $reviewday_rsa_pubkey_contents, + replace => true, + require => File['/var/lib/reviewday/.ssh/'] + } + } + + if $reviewday_gerrit_ssh_key != '' { + file { '/var/lib/reviewday/.ssh/known_hosts': + owner => 'reviewday', + group => 'reviewday', + mode => '0600', + content => $reviewday_gerrit_ssh_key, + replace => true, + require => File['/var/lib/reviewday/.ssh/'] + } + } + + vcsrepo { '/var/lib/reviewday/reviewday': ensure => present, provider => git, source => $git_url, } - apache::vhost { $name: - docroot => $httproot, - port => 80, - priority => '50', - require => File[$httproot], - template => 'reviewday.vhost.erb', - } - file { $httproot: ensure => directory, owner => 'reviewday', @@ -42,19 +80,20 @@ define reviewday::site( mode => '0644', } - file { "/var/lib/${name}/.ssh/config": + file { '/var/lib/reviewday/.ssh/config': ensure => present, content => template('ssh_config.erb'), - owner => reviewday, - group => reviewday, + owner => 'reviewday', + group => 'reviewday', mode => '0644', } - cron { "update ${name} reviewday": - command => "cd /var/lib/${name}/reviewday && PYTHONPATH=\$PWD python bin/reviewday -o /${httproot}", + cron { 'update reviewday': + command => "cd /var/lib/reviewday/reviewday && PYTHONPATH=\$PWD python bin/reviewday -o ${httproot}", minute => '*/15', user => 'reviewday', } + } # vim:sw=2:ts=2:expandtab:textwidth=79 diff --git a/modules/reviewday/templates/reviewday.vhost.erb b/modules/reviewday/templates/reviewday.vhost.erb deleted file mode 100644 index 638f6b9c87..0000000000 --- a/modules/reviewday/templates/reviewday.vhost.erb +++ /dev/null @@ -1,10 +0,0 @@ -:80> - ServerAdmin <%= serveradmin %> - DocumentRoot <%= httproot %> - - ErrorLog ${APACHE_LOG_DIR}/<%= name %>-error.log - - LogLevel warn - - CustomLog ${APACHE_LOG_DIR}/<%= name %>-access.log combined - diff --git a/modules/reviewday/templates/ssh_config.erb b/modules/reviewday/templates/ssh_config.erb index 4a0a2249e9..14e5da9bd6 100644 --- a/modules/reviewday/templates/ssh_config.erb +++ b/modules/reviewday/templates/ssh_config.erb @@ -2,5 +2,5 @@ Host review Hostname <%= gerrit_url %> Port <%= gerrit_port %> User <%= gerrit_user %> - IdentityFile /var/lib/<%= name %>/.ssh/id_rsa - UserKnownHostsFile /var/lib/<%= name %>/.ssh/known_hosts + IdentityFile /var/lib/reviewday/.ssh/id_rsa + UserKnownHostsFile /var/lib/reviewday/.ssh/known_hosts