Initial commit for puppet-stackalytics

Change-Id: If62b3f633000cc6380d892cad0a2160136ce8ca4
Co-Authored-By: Monty Taylor <mordred@inaugust.com>
Signed-off-by: Paul Belanger <pabelanger@redhat.com>
This commit is contained in:
Paul Belanger 2015-06-11 12:04:44 -04:00
parent 2394b14290
commit 8d60e5981e
4 changed files with 379 additions and 2 deletions

View File

@ -1,3 +1,6 @@
# Copyright 2014 Hewlett-Packard Development Company, L.P.
# Copyright 2015 Red Hat, Inc.
#
# 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
@ -9,8 +12,193 @@
# 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: stackalytics
#
class stackalytics {
class stackalytics (
$stackalytics_ssh_private_key,
$gerrit_ssh_user = 'stackalytics',
$git_revision = 'master',
$git_source = 'https://git.openstack.org/openstack/stackalytics',
$memcached_port = '11211',
$vhost_name = $::fqdn,
) {
include ::httpd
include ::httpd::mod::wsgi
include ::pip
$packages = [
'libapache2-mod-proxy-uwsgi',
'libapache2-mod-uwsgi',
'uwsgi',
'uwsgi-plugin-python',
]
package { $packages:
ensure => present,
}
class { '::memcached':
# NOTE(pabelanger): current requirement is about 2.5Gb and it increases on
# approx 0.5Gb per year
max_memory => 4096,
listen_ip => '127.0.0.1',
tcp_port => $memcached_port,
udp_port => $memcached_port,
}
group { 'stackalytics':
ensure => present,
}
user { 'stackalytics':
ensure => present,
home => '/home/stackalytics',
shell => '/bin/bash',
gid => 'stackalytics',
managehome => true,
require => Group['stackalytics'],
}
file { '/home/stackalytics/.ssh':
ensure => directory,
mode => '0500',
owner => 'stackalytics',
group => 'stackalytics',
require => User['stackalytics'],
}
file { '/home/stackalytics/.ssh/id_rsa':
ensure => present,
content => $stackalytics_ssh_private_key,
mode => '0400',
owner => 'stackalytics',
group => 'stackalytics',
require => File['/home/stackalytics/.ssh'],
}
file { '/var/lib/git':
ensure => directory,
owner => 'stackalytics',
group => 'stackalytics',
mode => '0644',
require => User['stackalytics'],
}
vcsrepo { '/opt/stackalytics':
ensure => latest,
provider => git,
revision => $git_revision,
source => $git_source,
}
exec { 'install-stackalytics':
command => 'pip install /opt/stackalytics',
path => '/usr/local/bin:/usr/bin:/bin/',
refreshonly => true,
subscribe => Vcsrepo['/opt/stackalytics'],
notify => Exec['stackalytics-reload'],
require => Class['pip'],
}
cron { 'process_stackalytics':
user => 'stackalytics',
hour => '*/4',
command => 'stackalytics-processor',
environment => 'PATH=/usr/bin:/bin:/usr/sbin:/sbin',
require => Exec['install-stackalytics'],
}
file { '/etc/stackalytics':
ensure => directory,
}
file { '/etc/stackalytics/stackalytics.conf':
ensure => link,
owner => 'stackalytics',
mode => '0444',
target => '/opt/stackalytics/etc/stackalytics.conf',
notify => Exec['stackalytics-reload'],
require => [
File['/etc/stackalytics'],
User['stackalytics'],
Vcsrepo['/opt/stackalytics'],
],
}
file { '/etc/uwsgi/apps-enabled/stackalytics.ini':
ensure => present,
owner => 'root',
mode => '0444',
content => template('stackalytics/uwsgi.ini.erb'),
notify => [
Exec['stackalytics-reload'],
Service['uwsgi'],
],
require => Package['uwsgi'],
}
service { 'uwsgi':
ensure => running,
hasrestart => true,
hasstatus => true,
require => Package['uwsgi'],
}
exec { 'stackalytics-reload':
command => 'touch /usr/local/lib/python2.7/dist-packages/stackalytics/dashboard/web.wsgi',
path => '/usr/local/bin:/usr/bin:/bin/',
refreshonly => true,
}
::httpd::vhost { $vhost_name:
port => 80,
docroot => 'MEANINGLESS ARGUMENT',
priority => '50',
template => 'stackalytics/stackalytics.vhost.erb',
ssl => true,
}
httpd_mod { 'proxy':
ensure => present,
}
httpd_mod { 'proxy_http':
ensure => present,
}
httpd_mod { 'proxy_uwsgi':
ensure => present,
require => Package[$packages],
}
ini_setting { 'sources_root':
ensure => present,
notify => Exec['stackalytics-reload'],
path => '/etc/stackalytics/stackalytics.conf',
require => File['/etc/stackalytics/stackalytics.conf'],
section => 'DEFAULT',
setting => 'sources_root',
value => '/var/lib/git',
}
ini_setting { 'ssh_key_filename':
ensure => present,
notify => Exec['stackalytics-reload'],
path => '/etc/stackalytics/stackalytics.conf',
require => File['/etc/stackalytics/stackalytics.conf'],
section => 'DEFAULT',
setting => 'ssh_key_filename',
value => '/home/stackalytics/.ssh/id_rsa',
}
ini_setting { 'ssh_username':
ensure => present,
notify => Exec['stackalytics-reload'],
path => '/etc/stackalytics/stackalytics.conf',
require => File['/etc/stackalytics/stackalytics.conf'],
section => 'DEFAULT',
setting => 'ssh_username',
value => $gerrit_ssh_user,
}
}

View File

@ -0,0 +1,163 @@
[DEFAULT]
#
# From oslo_log
#
# Print debugging output (set logging level to DEBUG instead of default WARNING
# level). (boolean value)
#debug = false
# Print more verbose output (set logging level to INFO instead of default
# WARNING level). (boolean value)
#verbose = false
# The name of a logging configuration file. This file is appended to any
# existing logging configuration files. For details about logging configuration
# files, see the Python logging module documentation. (string value)
# Deprecated group/name - [DEFAULT]/log_config
#log_config_append = <None>
# DEPRECATED. A logging.Formatter log message format string which may use any
# of the available logging.LogRecord attributes. This option is deprecated.
# Please use logging_context_format_string and logging_default_format_string
# instead. (string value)
#log_format = <None>
# Format string for %%(asctime)s in log records. Default: %(default)s . (string
# value)
#log_date_format = %Y-%m-%d %H:%M:%S
# (Optional) Name of log file to output to. If no default is set, logging will
# go to stdout. (string value)
# Deprecated group/name - [DEFAULT]/logfile
#log_file = <None>
# (Optional) The base directory used for relative --log-file paths. (string
# value)
# Deprecated group/name - [DEFAULT]/logdir
#log_dir = <None>
# Use syslog for logging. Existing syslog format is DEPRECATED during I, and
# changed in J to honor RFC5424. (boolean value)
#use_syslog = false
# (Optional) Enables or disables syslog rfc5424 format for logging. If enabled,
# prefixes the MSG part of the syslog message with APP-NAME (RFC5424). The
# format without the APP-NAME is deprecated in K, and will be removed in M,
# along with this option. (boolean value)
# This option is deprecated for removal.
# Its value may be silently ignored in the future.
#use_syslog_rfc_format = true
# Syslog facility to receive log lines. (string value)
#syslog_log_facility = LOG_USER
# Log output to standard error. (boolean value)
#use_stderr = true
# Format string to use for log messages with context. (string value)
#logging_context_format_string = %(asctime)s.%(msecs)03d %(process)d %(levelname)s %(name)s [%(request_id)s %(user_identity)s] %(instance)s%(message)s
# Format string to use for log messages without context. (string value)
#logging_default_format_string = %(asctime)s.%(msecs)03d %(process)d %(levelname)s %(name)s [-] %(instance)s%(message)s
# Data to append to log format when level is DEBUG. (string value)
#logging_debug_format_suffix = %(funcName)s %(pathname)s:%(lineno)d
# Prefix each line of exception output with this format. (string value)
#logging_exception_prefix = %(asctime)s.%(msecs)03d %(process)d ERROR %(name)s %(instance)s
# List of logger=LEVEL pairs. (list value)
#default_log_levels = amqp=WARN,amqplib=WARN,boto=WARN,qpid=WARN,sqlalchemy=WARN,suds=INFO,oslo.messaging=INFO,iso8601=WARN,requests.packages.urllib3.connectionpool=WARN,urllib3.connectionpool=WARN,websocket=WARN,requests.packages.urllib3.util.retry=WARN,urllib3.util.retry=WARN,keystonemiddleware=WARN,routes.middleware=WARN,stevedore=WARN
# Enables or disables publication of error events. (boolean value)
#publish_errors = false
# Enables or disables fatal status of deprecations. (boolean value)
#fatal_deprecations = false
# The format for an instance that is passed with the log message. (string
# value)
#instance_format = "[instance: %(uuid)s] "
# The format for an instance UUID that is passed with the log message. (string
# value)
#instance_uuid_format = "[instance: %(uuid)s] "
# Enables or disables fatal status of deprecations. (boolean value)
#fatal_deprecations = false
#
# From stackalytics.processor.config
#
# Storage URI (string value)
#runtime_storage_uri = memcached://127.0.0.1:11211
runtime_storage_uri = memcached://127.0.0.1:<%= @memcached_port %>
# URI for default data (string value)
#default_data_uri = https://git.openstack.org/cgit/stackforge/stackalytics/plain/etc/default_data.json
default_data_uri = <%= @default_data_uri %>
# The folder that holds all project sources to analyze (string value)
#sources_root = /var/local/stackalytics
sources_root = /var/lib/git
# Number of days to update members (integer value)
#days_to_update_members = 30
# The address of file with corrections data (string value)
#corrections_uri = https://git.openstack.org/cgit/stackforge/stackalytics/plain/etc/corrections.json
corrections_uri = <%= @corrections_uri %>
# URI of review system (string value)
#review_uri = gerrit://review.openstack.org
review_uri = gerrit://<%= @gerrit_host %>
# git base location (string value)
#git_base_uri = git://git.openstack.org
git_base_uri = <%= @git_base %>
# SSH key for gerrit review system access (string value)
#ssh_key_filename = /home/user/.ssh/id_rsa
ssh_key_filename = /home/stackalytics/.ssh/id_rsa
# SSH username for gerrit review system access (string value)
#ssh_username = user
ssh_username = <%= @gerrit_ssh_user %>
# The address of file with the official projects list (string value)
#project_list_uri = https://git.openstack.org/cgit/openstack/governance/plain/reference/projects.yaml
# URI for default data (string value)
#driverlog_data_uri = https://git.openstack.org/cgit/stackforge/driverlog/plain/etc/default_data.json
# How many member profiles to look ahead after the last (integer value)
#members_look_ahead = 250
# The address dashboard listens on (string value)
#listen_host = 127.0.0.1
# The port dashboard listens on (integer value)
#listen_port = 8080
# Default metric (string value)
#default_metric = marks
# Default release, the most recent if not set (string value)
#default_release = <None>
# Default project type (string value)
#default_project_type = openstack
# The interval specifies how frequently dashboard should check for updates in
# seconds (integer value)
#dashboard_update_interval = 3600
# Name of file to store python profiler data. This option works for dashboard
# only (string value)
#collect_profiler_stats = <None>
# Warn if the age of data is more than this value, sec (integer value)
#age_warn = 172800

View File

@ -0,0 +1,17 @@
<VirtualHost <%= @vhost_name %>:80>
ErrorLog ${APACHE_LOG_DIR}/stackalytics-error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/stackalytics-access.log combined
<Directory /usr/local/lib/python2.7/dist-packages/stackalytics/dashboard>
Require all granted
</Directory>
Alias /static /usr/local/lib/python2.7/dist-packages/stackalytics/dashboard/static/
ProxyPass / uwsgi://127.0.0.1:3031/ retry=0
ProxyPassReverse / uwsgi://127.0.0.1:3031/
</VirtualHost>

9
templates/uwsgi.ini.erb Normal file
View File

@ -0,0 +1,9 @@
[uwsgi]
uid = stackalytics
gid = stackalytics
socket = 127.0.0.1:3031
pythonpath = /usr/local/lib/python2.7/dist-packages
module = stackalytics.dashboard.web:app
processes = 4
threads = 1
stats = 127.0.0.1:9191