Cleanup lodgeit manifest lint errors.

Change-Id: Iec09a46b4c3a540154d962989dcf02b1a4605b52
Reviewed-on: https://review.openstack.org/14825
Reviewed-by: Paul Belanger <paul.belanger@polybeacon.com>
Reviewed-by: Monty Taylor <mordred@inaugust.com>
Approved: James E. Blair <corvus@inaugust.com>
Reviewed-by: James E. Blair <corvus@inaugust.com>
Tested-by: Jenkins
This commit is contained in:
Matthew Wagoner 2012-10-23 22:45:02 -04:00 committed by Jenkins
parent d488e3bdaa
commit 234804ed84
2 changed files with 69 additions and 53 deletions

View File

@ -1,52 +1,56 @@
# == Class: lodgeit
#
class lodgeit { class lodgeit {
$packages = [ "python-imaging", $packages = [ 'python-imaging',
"python-jinja2", 'python-jinja2',
"python-pybabel", 'python-pybabel',
"python-werkzeug", 'python-werkzeug',
"python-simplejson", 'python-simplejson',
"python-pygments", 'python-pygments',
"drizzle", 'drizzle',
"python-mysqldb" ] 'python-mysqldb' ]
include apache include apache
include pip include pip
a2mod { 'proxy': a2mod { 'proxy':
ensure => present ensure => present,
} }
a2mod { 'proxy_http': a2mod { 'proxy_http':
ensure => present ensure => present,
} }
package { $packages: ensure => present } package { $packages:
ensure => present,
}
package { 'SQLAlchemy': package { 'SQLAlchemy':
ensure => present,
provider => pip, provider => pip,
ensure => present, require => Class[pip],
require => Class[pip]
} }
file { '/srv/lodgeit': file { '/srv/lodgeit':
ensure => directory ensure => directory,
} }
service { 'drizzle': service { 'drizzle':
ensure => running, ensure => running,
hasrestart => true hasrestart => true,
} }
vcsrepo { "/tmp/lodgeit-main": vcsrepo { '/tmp/lodgeit-main':
ensure => latest, ensure => latest,
provider => git, provider => git,
source => "https://github.com/openstack-ci/lodgeit.git", source => 'https://github.com/openstack-ci/lodgeit.git',
} }
# create initial git DB backup location # create initial git DB backup location
exec { "create_db_backup": exec { 'create_db_backup':
command => "git init /var/backups/lodgeit_db", command => 'git init /var/backups/lodgeit_db',
path => "/bin:/usr/bin", path => '/bin:/usr/bin',
onlyif => "test ! -d /var/backups/lodgeit_db" onlyif => 'test ! -d /var/backups/lodgeit_db',
} }
} }

View File

@ -1,75 +1,87 @@
define lodgeit::site($vhost_name="paste.$name.org", $port, $image="") { # == Define: site
#
define lodgeit::site(
$port,
$vhost_name="paste.${name}.org",
$image='') {
include remove_nginx include remove_nginx
apache::vhost::proxy { $vhost_name: apache::vhost::proxy { $vhost_name:
port => 80, port => 80,
dest => "http://localhost:$port", dest => "http://localhost:${port}",
require => File["/srv/lodgeit/${name}"], require => File["/srv/lodgeit/${name}"],
} }
file { "/etc/init/${name}-paste.conf": file { "/etc/init/${name}-paste.conf":
ensure => 'present', ensure => present,
content => template("lodgeit/upstart.erb"), content => template('lodgeit/upstart.erb'),
replace => 'true', replace => true,
require => Package[nginx], require => Package['nginx'],
notify => Service["${name}-paste"] notify => Service["${name}-paste"],
} }
file { "/srv/lodgeit/${name}": file { "/srv/lodgeit/${name}":
ensure => directory, ensure => directory,
recurse => true, recurse => true,
source => "/tmp/lodgeit-main" source => '/tmp/lodgeit-main',
} }
if $image != '' { if $image != '' {
file { "/srv/lodgeit/${name}/lodgeit/static/${image}": file { "/srv/lodgeit/${name}/lodgeit/static/${image}":
ensure => present, ensure => present,
source => "puppet:///lodgeit/${image}" source => "puppet:///lodgeit/${image}",
} }
} }
file { "/srv/lodgeit/${name}/manage.py": file { "/srv/lodgeit/${name}/manage.py":
mode => 755, ensure => present,
mode => '0755',
replace => true, replace => true,
content => template("lodgeit/manage.py.erb"), content => template('lodgeit/manage.py.erb'),
notify => Service["${name}-paste"] notify => Service["${name}-paste"],
} }
file { "/srv/lodgeit/${name}/lodgeit/views/layout.html": file { "/srv/lodgeit/${name}/lodgeit/views/layout.html":
ensure => present,
replace => true, replace => true,
content => template("lodgeit/layout.html.erb") content => template('lodgeit/layout.html.erb'),
} }
exec { "create_database_${name}": exec { "create_database_${name}":
command => "drizzle --user=root -e \"create database if not exists ${name};\"", command => "drizzle --user=root \
path => "/bin:/usr/bin", -e \"create database if not exists ${name};\"",
unless => "drizzle --disable-column-names -r --batch -e \"show databases like 'openstack'\" | grep openstack >/dev/null", path => '/bin:/usr/bin',
require => Service["drizzle"] unless => 'drizzle --disable-column-names -r --batch \
-e "show databases like \'openstack\'" | grep -q openstack',
require => Service['drizzle'],
} }
# create a backup .sql file in git # create a backup .sql file in git
exec { "create_db_backup_${name}": exec { "create_db_backup_${name}":
command => "touch ${name}.sql && git add ${name}.sql && git commit -am \"Initial commit for ${name}\"", command => "touch ${name}.sql && git add ${name}.sql && git commit \
cwd => "/var/backups/lodgeit_db/", -am \"Initial commit for ${name}\"",
path => "/bin:/usr/bin", cwd => '/var/backups/lodgeit_db/',
onlyif => "test ! -f /var/backups/lodgeit_db/${name}.sql" path => '/bin:/usr/bin',
onlyif => "test ! -f /var/backups/lodgeit_db/${name}.sql",
} }
# cron to take a backup and commit it in git # cron to take a backup and commit it in git
cron { "update_backup_${name}": cron { "update_backup_${name}":
user => root, user => root,
hour => 6, hour => 6,
minute => 23, minute => 23,
command => "sleep $((RANDOM\\%60+60)) && cd /var/backups/lodgeit_db && drizzledump -uroot ${name} > ${name}.sql && git commit -qam \"Updating DB backup for ${name}\"" command => "sleep $((RANDOM\\%60+60)) && cd /var/backups/lodgeit_db \
&& drizzledump -uroot ${name} > ${name}.sql \
&& git commit -qam \"Updating DB backup for ${name}\""
} }
service { "${name}-paste": service { "${name}-paste":
ensure => running,
provider => upstart, provider => upstart,
ensure => running, require => [Service['drizzle', 'nginx'], Exec["create_database_${name}"]],
require => [Service["drizzle", "nginx"], Exec["create_database_${name}"]]
} }
} }