Optional install Nailgun OSTF from PRM packages

Change-Id: Ib73410ff8d3f06e7195e0b9d41862390588a212a
This commit is contained in:
Ivan Kolodyazhny 2014-03-17 22:22:02 +02:00
parent 34ee2a8681
commit c0a04fd46c
8 changed files with 178 additions and 107 deletions

View File

@ -1,4 +1,20 @@
$fuel_settings = parseyaml($astute_settings_yaml)
$fuel_version = parseyaml($fuel_version_yaml)
if is_hash($::fuel_version) and $::fuel_version['VERSION'] and $::fuel_version['VERSION']['production'] {
$production = $::fuel_version['VERSION']['production']
}
else {
$production = 'prod'
}
if $production == 'prod'{
$env_path = "/usr"
$staticdir = "/usr/share/nailgun/static"
} else {
$env_path = "/opt/nailgun"
$staticdir = "/opt/nailgun/share/nailgun/static"
}
# this replaces removed postgresql version fact
$postgres_default_version = '8.4'
@ -51,10 +67,11 @@ node default {
class { "nailgun":
package => "Nailgun",
version => "0.1.0",
production => $production,
astute_version => "0.0.2",
nailgun_group => "nailgun",
nailgun_user => "nailgun",
venv => "/opt/nailgun",
venv => $env_path,
pip_index => "--no-index",
pip_find_links => "-f file://${pip_repo}",
@ -69,8 +86,8 @@ node default {
database_user => "nailgun",
database_passwd => "nailgun",
staticdir => "/opt/nailgun/share/nailgun/static",
templatedir => "/opt/nailgun/share/nailgun/static",
staticdir => $staticdir,
templatedir => $staticdir,
cobbler_url => "http://localhost/cobbler_api",
cobbler_user => $cobbler_user,

View File

@ -0,0 +1,11 @@
require 'facter'
fuel_version_path = '/etc/nailgun/version.yaml'
Facter.add('fuel_version_yaml') do
if File.exist?(fuel_version_path)
setcode { File.read(fuel_version_path) }
else
setcode { "none" }
end
end

View File

@ -1,9 +1,10 @@
class nailgun(
$package,
$version,
$production,
$venv,
$nailgun_group = "nailgun",
$nailgun_user = "nailgun",
$venv = "/opt/nailgun",
$repo_root = "/var/www/nailgun",
$pip_index = "",
@ -17,8 +18,8 @@ class nailgun(
$database_user = "nailgun",
$database_passwd = "nailgun",
$staticdir = "/opt/nailgun/share/nailgun/static",
$templatedir = "/opt/nailgun/share/nailgun/static",
$staticdir,
$templatedir,
$logdumpdir = "/var/www/nailgun/dump",
$cobbler_url = "http://localhost/cobbler_api",
@ -110,6 +111,7 @@ class nailgun(
package => $package,
version => $version,
pip_opts => "${pip_index} ${pip_find_links}",
production => $production,
nailgun_user => $nailgun_user,
nailgun_group => $nailgun_group,
@ -142,8 +144,17 @@ class nailgun(
gem_source => $gem_source,
}
if $production == 'prod' {
$nailgun_env = $venv
$ostf_env = $venv
} else {
$nailgun_env = '/opt/nailgun'
$ostf_env = '/opt/fuel_plugins/ostf'
}
class { "nailgun::supervisor":
venv => $venv,
nailgun_env => $nailgun_env,
ostf_env => $ostf_env,
}
class { "nailgun::nginx-repo":
@ -202,6 +213,7 @@ class nailgun(
class { "nailgun::logrotate": }
class { "nailgun::ostf":
production => $production,
pip_opts => "${pip_index} ${pip_find_links}",
}

View File

@ -1,5 +1,6 @@
class nailgun::ostf(
$pip_opts,
$production,
$venv = '/opt/fuel_plugins/ostf',
$dbuser = 'ostf',
$dbpass = 'ostf',
@ -19,53 +20,69 @@ class nailgun::ostf(
grant => 'all',
require => Class['::postgresql::server'],
}
nailgun::venv::venv{'ostf-venv':
venv => $venv,
ensure => 'present',
opts => "--system-site-packages",
pip_opts => $pip_opts,
}
Nailgun::Venv::Pip {
venv => $venv,
opts => "$pip_opts",
require => [
Nailgun::Venv::Venv['ostf-venv'],
Package['libevent-devel'],
Package['openssl-devel'],
Package['postgresql-devel'],
],
}
file { "$venv/pip-requires.txt":
source => 'puppet:///modules/nailgun/venv-ostf.txt',
owner => 'root',
group => 'root',
mode => 0755,
}->
nailgun::venv::pip { "${venv}_setuptools-git":
package => 'setuptools-git==1.0',
}->
nailgun::venv::pip { "${venv}_d2to1":
package => 'd2to1==0.2.10',
}->
nailgun::venv::pip { "${venv}_pbr":
package => 'pbr==0.5.21',
}->
nailgun::venv::pip { "${venv}_ostf-req":
package => "-r $venv/pip-requires.txt",
}->
nailgun::venv::pip { "${venv}_ostf":
package => 'fuel-ostf',
}
exec {'ostf-init':
command => "$venv/bin/ostf-server \
--host=${host} --port=${port} --log_file=${logfile} \
--dbpath '${dbengine}://${dbuser}:${dbpass}@${dbhost}:${dbport}/${dbname}' \
--after-initialization-environment-hook || /bin/true",
require => [
Postgresql::Db[$dbname],
Nailgun::Venv::Pip["${venv}_ostf-req"],
Nailgun::Venv::Pip["${venv}_ostf"],
],
before => Class['nailgun::supervisor'],
if $production == 'prod' {
package{'fuel-ostf':}
exec {'ostf-init':
command => "/usr/bin/ostf-server \
--host=${host} --port=${port} --log_file=${logfile} \
--dbpath '${dbengine}://${dbuser}:${dbpass}@${dbhost}:${dbport}/${dbname}' \
--after-initialization-environment-hook || /bin/true",
require => [
Package["fuel-ostf"],
Postgresql::Db[$dbname],
],
before => Class['nailgun::supervisor'],
}
} else {
nailgun::venv::venv{'ostf-venv':
venv => $venv,
ensure => 'present',
opts => "--system-site-packages",
pip_opts => $pip_opts,
}
Nailgun::Venv::Pip {
venv => $venv,
opts => "$pip_opts",
require => [
Nailgun::Venv::Venv['ostf-venv'],
Package['libevent-devel'],
Package['openssl-devel'],
Package['postgresql-devel'],
],
}
file { "$venv/pip-requires.txt":
source => 'puppet:///modules/nailgun/venv-ostf.txt',
owner => 'root',
group => 'root',
mode => 0755,
}->
nailgun::venv::pip { "${venv}_setuptools-git":
package => 'setuptools-git==1.0',
}->
nailgun::venv::pip { "${venv}_d2to1":
package => 'd2to1==0.2.10',
}->
nailgun::venv::pip { "${venv}_pbr":
package => 'pbr==0.5.21',
}->
nailgun::venv::pip { "${venv}_ostf-req":
package => "-r $venv/pip-requires.txt",
}->
nailgun::venv::pip { "${venv}_ostf":
package => 'fuel-ostf',
}
exec {'ostf-init':
command => "$venv/bin/ostf-server \
--host=${host} --port=${port} --log_file=${logfile} \
--dbpath '${dbengine}://${dbuser}:${dbpass}@${dbhost}:${dbport}/${dbname}' \
--after-initialization-environment-hook || /bin/true",
require => [
Postgresql::Db[$dbname],
Nailgun::Venv::Pip["${venv}_ostf-req"],
Nailgun::Venv::Pip["${venv}_ostf"],
],
before => Class['nailgun::supervisor'],
}
}
}

View File

@ -1,5 +1,6 @@
class nailgun::supervisor(
$venv,
$nailgun_env,
$ostf_env,
) {
file { "/etc/sysconfig/supervisord":

View File

@ -5,6 +5,7 @@ class nailgun::venv(
$version,
$pip_opts = "",
$production,
$nailgun_user,
$nailgun_group,
@ -34,47 +35,50 @@ class nailgun::venv(
) {
nailgun::venv::venv { $venv:
ensure => "present",
venv => $venv,
opts => $venv_opts,
require => Package["python-virtualenv"],
pip_opts => $pip_opts,
}
if $production == 'prod' {
package{'nailgun':}
} else {
nailgun::venv::venv { $venv:
ensure => "present",
venv => $venv,
opts => $venv_opts,
require => Package["python-virtualenv"],
pip_opts => $pip_opts,
}
Nailgun::Venv::Pip {
require => [
Nailgun::Venv::Venv[$venv],
Package["python-devel"],
Package["gcc"],
Package["make"],
],
opts => $pip_opts,
venv => $venv,
}
Nailgun::Venv::Pip {
require => [
Nailgun::Venv::Venv[$venv],
Package["python-devel"],
Package["gcc"],
Package["make"],
],
opts => $pip_opts,
venv => $venv,
}
nailgun::venv::pip { "${venv}_${package}":
package => "$package==$version",
}
nailgun::venv::pip { "${venv}_${package}":
package => "$package==$version",
}
nailgun::venv::pip { "${venv}_pbr":
package => "pbr==0.5.21",
require => [
Nailgun::Venv::Venv[$venv],
],
}
nailgun::venv::pip { "${venv}_pbr":
package => "pbr==0.5.21",
require => [
Nailgun::Venv::Venv[$venv],
],
}
nailgun::venv::pip { "${venv}_psycopg2":
package => "psycopg2==2.4.6",
require => [
Package["postgresql-devel"],
Nailgun::Venv::Venv[$venv],
Package["python-devel"],
Package["gcc"],
Package["make"],
],
nailgun::venv::pip { "${venv}_psycopg2":
package => "psycopg2==2.4.6",
require => [
Package["postgresql-devel"],
Nailgun::Venv::Venv[$venv],
Package["python-devel"],
Package["gcc"],
Package["make"],
],
}
}
file { "/etc/nailgun":
ensure => directory,
owner => 'root',
@ -96,17 +100,26 @@ class nailgun::venv(
file { "/usr/local/bin/fuel":
ensure => link,
target => "/opt/nailgun/bin/fuel",
require => Nailgun::Venv::Pip["${venv}_${package}"],
}
exec {"nailgun_syncdb":
command => "${venv}/bin/nailgun_syncdb",
require => [
File["/etc/nailgun/settings.yaml"],
Nailgun::Venv::Pip["${venv}_${package}"],
Nailgun::Venv::Pip["${venv}_psycopg2"],
Class["nailgun::database"],
],
if $production == 'prod' {
exec {"nailgun_syncdb":
command => "${venv}/bin/nailgun_syncdb",
require => [
File["/etc/nailgun/settings.yaml"],
Class["nailgun::database"],
],
}
} else {
exec {"nailgun_syncdb":
command => "${venv}/bin/nailgun_syncdb",
require => [
File["/etc/nailgun/settings.yaml"],
Nailgun::Venv::Pip["${venv}_${package}"],
Nailgun::Venv::Pip["${venv}_psycopg2"],
Class["nailgun::database"],
],
}
}
exec {"nailgun_upload_fixtures":

View File

@ -15,7 +15,7 @@ childlogdir=/var/log/supervisor
serverurl=unix:///var/run/supervisor.sock
[program:nailgun]
command=<%= @venv %>/bin/nailgund
command=<%= @nailgun_env %>/bin/nailgund
process_name=%(program_name)s
numprocs=1
numprocs_start=0
@ -33,7 +33,7 @@ stdout_events_enabled=false
serverurl=AUTO
[program:assassind]
command=<%= @venv %>/bin/assassind
command=<%= @nailgun_env %>/bin/assassind
process_name=%(program_name)s
numprocs=1
numprocs_start=0
@ -51,7 +51,7 @@ stdout_events_enabled=false
serverurl=AUTO
[program:receiverd]
command=<%= @venv %>/bin/receiverd
command=<%= @nailgun_env %>/bin/receiverd
process_name=%(program_name)s
numprocs=1
numprocs_start=0
@ -94,7 +94,7 @@ stderr_events_enabled=false
serverurl=AUTO
[program:ostf]
command=/opt/fuel_plugins/ostf/bin/ostf-server --host=127.0.0.1 --port=8777 --log_file=/var/log/ostf.log --dbpath postgresql+psycopg2://ostf:ostf@127.0.0.1:5432/ostf
command=<%= @ostf_env %>/bin/ostf-server --host=127.0.0.1 --port=8777 --log_file=/var/log/ostf.log --dbpath postgresql+psycopg2://ostf:ostf@127.0.0.1:5432/ostf
process_name=%(program_name)s
numprocs=1
numprocs_start=0