From b3af6199008f0629be3915260cb70804a6eac0b0 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Thu, 5 Dec 2013 17:02:59 -0500 Subject: [PATCH] move to elastic-recheck web console in share this provides the changes needed to handle the new elastic-recheck web console installed from the elastic-recheck package in the share tree. factor out bot code to elastic_recheck::bot this change moves elastic_recheck bot starting code out into a separate module, which lets us include all the elastic_recheck base module into the static site config. Change-Id: If53523754494a746c152c5d1384db5426b096fc1 --- manifests/site.pp | 14 ++-- modules/elastic_recheck/manifests/bot.pp | 83 +++++++++++++++++++ modules/elastic_recheck/manifests/init.pp | 81 ++---------------- .../openstack_project/manifests/logstash.pp | 2 +- modules/openstack_project/manifests/static.pp | 61 +------------- .../templates/status.vhost.erb | 16 ++++ 6 files changed, 118 insertions(+), 139 deletions(-) create mode 100644 modules/elastic_recheck/manifests/bot.pp diff --git a/manifests/site.pp b/manifests/site.pp index 231d2c5141..b275a4c53b 100644 --- a/manifests/site.pp +++ b/manifests/site.pp @@ -379,13 +379,13 @@ node 'summit.openstack.org' { # A machine to serve static content. node 'static.openstack.org' { class { 'openstack_project::static': - sysadmins => hiera('sysadmins'), - reviewday_rsa_key_contents => hiera('reviewday_rsa_key_contents'), - reviewday_rsa_pubkey_contents => hiera('reviewday_rsa_pubkey_contents'), - reviewday_gerrit_ssh_key => hiera('gerrit_ssh_rsa_pubkey_contents'), - releasestatus_prvkey_contents => hiera('releasestatus_rsa_key_contents'), - releasestatus_pubkey_contents => hiera('releasestatus_rsa_pubkey_contents'), - releasestatus_gerrit_ssh_key => hiera('gerrit_ssh_rsa_pubkey_contents'), + sysadmins => hiera('sysadmins'), + reviewday_rsa_key_contents => hiera('reviewday_rsa_key_contents'), + reviewday_rsa_pubkey_contents => hiera('reviewday_rsa_pubkey_contents'), + reviewday_gerrit_ssh_key => hiera('gerrit_ssh_rsa_pubkey_contents'), + releasestatus_prvkey_contents => hiera('releasestatus_rsa_key_contents'), + releasestatus_pubkey_contents => hiera('releasestatus_rsa_pubkey_contents'), + releasestatus_gerrit_ssh_key => hiera('gerrit_ssh_rsa_pubkey_contents'), } } diff --git a/modules/elastic_recheck/manifests/bot.pp b/modules/elastic_recheck/manifests/bot.pp new file mode 100644 index 0000000000..f26144ff20 --- /dev/null +++ b/modules/elastic_recheck/manifests/bot.pp @@ -0,0 +1,83 @@ +# Copyright 2013 Hewlett-Packard Development Company, L.P. +# Copyright 2013 Samsung Electronics +# +# 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. +# +# Class to install and configure an instance of the elastic-recheck +# service. +# +class elastic_recheck::bot ( + $gerrit_host, + $gerrit_ssh_private_key, + $gerrit_ssh_private_key_contents, + #not used today, will be used when elastic-recheck supports it. + $elasticsearch_url, + $recheck_bot_passwd, + $gerrit_user = 'elasticrecheck', + $recheck_bot_nick = 'openstackrecheck', +) { + include elastic_recheck + + file { '/etc/elastic-recheck/elastic-recheck.conf': + ensure => present, + mode => '0640', + owner => 'recheck', + group => 'recheck', + content => template('elastic_recheck/elastic-recheck.conf.erb'), + require => Class['elastic_recheck'], + } + + file { '/home/recheck': + ensure => directory, + mode => '0700', + owner => 'recheck', + group => 'recheck', + require => Class['elastic_recheck'], + } + + file { '/home/recheck/.ssh': + ensure => directory, + mode => '0700', + owner => 'recheck', + group => 'recheck', + require => Class['elastic_recheck'], + } + + file { $gerrit_ssh_private_key: + ensure => present, + mode => '0600', + owner => 'recheck', + group => 'recheck', + content => $gerrit_ssh_private_key_contents, + require => Class['elastic_recheck'], + } + + file { '/etc/init.d/elastic-recheck': + ensure => present, + mode => '0755', + owner => 'root', + group => 'root', + source => 'puppet:///modules/elastic_recheck/elastic-recheck.init', + } + + service { 'elastic-recheck': + ensure => running, + enable => true, + subscribe => File['/etc/elastic-recheck/elastic-recheck.conf'], + require => [ + Class['elastic_recheck'], + File['/etc/init.d/elastic-recheck'], + File['/etc/elastic-recheck/elastic-recheck.conf'], + ], + } +} diff --git a/modules/elastic_recheck/manifests/init.pp b/modules/elastic_recheck/manifests/init.pp index 2609216a56..b532c30652 100644 --- a/modules/elastic_recheck/manifests/init.pp +++ b/modules/elastic_recheck/manifests/init.pp @@ -16,14 +16,6 @@ # service. # class elastic_recheck ( - $gerrit_host, - $gerrit_ssh_private_key, - $gerrit_ssh_private_key_contents, - #not used today, will be used when elastic-recheck supports it. - $elasticsearch_url, - $recheck_bot_passwd, - $gerrit_user = 'elasticrecheck', - $recheck_bot_nick = 'openstackrecheck' ) { group { 'recheck': ensure => 'present', @@ -62,6 +54,14 @@ class elastic_recheck ( require => User['recheck'], } + file { '/var/lib/elastic-recheck': + ensure => directory, + mode => '0755', + owner => 'recheck', + group => 'recheck', + require => User['recheck'], + } + file { '/var/log/elastic-recheck': ensure => directory, mode => '0755', @@ -78,15 +78,6 @@ class elastic_recheck ( require => User['recheck'], } - file { '/etc/elastic-recheck/elastic-recheck.conf': - ensure => present, - mode => '0640', - owner => 'recheck', - group => 'recheck', - content => template('elastic_recheck/elastic-recheck.conf.erb'), - require => File['/etc/elastic-recheck'], - } - file { '/etc/elastic-recheck/logging.config': ensure => present, mode => '0640', @@ -105,17 +96,6 @@ class elastic_recheck ( require => File['/etc/elastic-recheck'], } - # TODO(clarkb) put queries.yaml somewhere else. - file { '/etc/elastic-recheck/queries.yaml': - ensure => link, - target => '/opt/elastic-recheck/queries.yaml', - require => [ - Vcsrepo['/opt/elastic-recheck'], - File['/etc/elastic-recheck'], - ], - } - - # Link in the queries directory for refactoring file { '/etc/elastic-recheck/queries': ensure => link, target => '/opt/elastic-recheck/queries', @@ -124,49 +104,4 @@ class elastic_recheck ( File['/etc/elastic-recheck'], ], } - - file { '/home/recheck': - ensure => directory, - mode => '0700', - owner => 'recheck', - group => 'recheck', - require => User['recheck'], - } - - file { '/home/recheck/.ssh': - ensure => directory, - mode => '0700', - owner => 'recheck', - group => 'recheck', - require => User['recheck'], - } - - file { $gerrit_ssh_private_key: - ensure => present, - mode => '0600', - owner => 'recheck', - group => 'recheck', - content => $gerrit_ssh_private_key_contents, - require => User['recheck'], - } - - file { '/etc/init.d/elastic-recheck': - ensure => present, - mode => '0755', - owner => 'root', - group => 'root', - source => 'puppet:///modules/elastic_recheck/elastic-recheck.init', - } - - service { 'elastic-recheck': - ensure => running, - enable => true, - subscribe => File['/etc/elastic-recheck/elastic-recheck.conf'], - require => [ - File['/etc/init.d/elastic-recheck'], - File['/etc/elastic-recheck/elastic-recheck.conf'], - File['/etc/elastic-recheck/queries.yaml'], - Exec['install_elastic-recheck'], - ], - } } diff --git a/modules/openstack_project/manifests/logstash.pp b/modules/openstack_project/manifests/logstash.pp index 509993c332..e9956fa17b 100644 --- a/modules/openstack_project/manifests/logstash.pp +++ b/modules/openstack_project/manifests/logstash.pp @@ -117,7 +117,7 @@ class openstack_project::logstash ( require => Service['jenkins-log-client'], } - class { 'elastic_recheck': + class { 'elastic_recheck::bot': gerrit_host => $gerrit_host, gerrit_ssh_private_key => $gerrit_ssh_private_key, gerrit_ssh_private_key_contents => $gerrit_ssh_private_key_contents, diff --git a/modules/openstack_project/manifests/static.pp b/modules/openstack_project/manifests/static.pp index 522cbed644..89f01639a8 100644 --- a/modules/openstack_project/manifests/static.pp +++ b/modules/openstack_project/manifests/static.pp @@ -8,7 +8,7 @@ class openstack_project::static ( $releasestatus_prvkey_contents = '', $releasestatus_pubkey_contents = '', $releasestatus_gerrit_ssh_key = '', - $er_state_dir = '/srv/static/status/elastic-recheck', + $er_state_dir = '/var/lib/elastic-recheck', ) { class { 'openstack_project::server': @@ -307,61 +307,7 @@ class openstack_project::static ( ########################################################### # Status - elastic-recheck - - group { 'recheck': - ensure => 'present', - } - - user { 'recheck': - ensure => present, - home => '/home/recheck', - shell => '/bin/bash', - gid => 'recheck', - require => Group['recheck'], - } - - file { '/home/recheck': - ensure => directory, - mode => '0700', - owner => 'recheck', - group => 'recheck', - require => User['recheck'], - } - - vcsrepo { '/opt/elastic-recheck': - ensure => latest, - provider => git, - revision => 'master', - source => 'https://git.openstack.org/openstack-infra/elastic-recheck', - } - - include pip - exec { 'install_elastic-recheck' : - command => 'pip install /opt/elastic-recheck', - path => '/usr/local/bin:/usr/bin:/bin/', - refreshonly => true, - subscribe => Vcsrepo['/opt/elastic-recheck'], - require => Class['pip'], - } - - file { '/srv/static/status/elastic-recheck': - ensure => directory, - owner => 'recheck', - group => 'recheck', - require => User['recheck'], - } - - file { '/srv/static/status/elastic-recheck/index.html': - ensure => present, - source => 'puppet:///modules/openstack_project/elastic-recheck/elastic-recheck.html', - require => File['/srv/static/status/elastic-recheck'], - } - - file { '/srv/static/status/elastic-recheck/elastic-recheck.js': - ensure => present, - source => 'puppet:///modules/openstack_project/elastic-recheck/elastic-recheck.js', - require => File['/srv/static/status/elastic-recheck'], - } + include elastic_recheck cron { 'elastic-recheck': user => 'recheck', @@ -369,8 +315,7 @@ class openstack_project::static ( hour => '*', command => "elastic-recheck-graph /opt/elastic-recheck/queries -o ${er_state_dir}/graph-new.json && mv ${er_state_dir}/graph-new.json ${er_state_dir}/graph.json", environment => 'PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin', - require => [Vcsrepo['/opt/elastic-recheck'], - User['recheck']], + require => Class['elastic_recheck'] } ########################################################### diff --git a/modules/openstack_project/templates/status.vhost.erb b/modules/openstack_project/templates/status.vhost.erb index 96d434e83c..edfae6e73b 100644 --- a/modules/openstack_project/templates/status.vhost.erb +++ b/modules/openstack_project/templates/status.vhost.erb @@ -38,6 +38,22 @@ NameVirtualHost <%= vhost_name %>:<%= port %> allow from all + # Sample elastic-recheck config file, adjust prefixes + # per your local configuration + Alias /elastic-recheck /usr/local/share/elastic-recheck + + Options FollowSymlinks + AllowOverride None + Require all granted + + + Alias /elastic-recheck/data /var/lib/elastic-recheck + + Options FollowSymlinks + AllowOverride None + Require all granted + + ErrorLog /var/log/apache2/<%= name %>_error.log LogLevel warn CustomLog /var/log/apache2/<%= name %>_access.log combined