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_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 # this replaces removed postgresql version fact
$postgres_default_version = '8.4' $postgres_default_version = '8.4'
@ -51,10 +67,11 @@ node default {
class { "nailgun": class { "nailgun":
package => "Nailgun", package => "Nailgun",
version => "0.1.0", version => "0.1.0",
production => $production,
astute_version => "0.0.2", astute_version => "0.0.2",
nailgun_group => "nailgun", nailgun_group => "nailgun",
nailgun_user => "nailgun", nailgun_user => "nailgun",
venv => "/opt/nailgun", venv => $env_path,
pip_index => "--no-index", pip_index => "--no-index",
pip_find_links => "-f file://${pip_repo}", pip_find_links => "-f file://${pip_repo}",
@ -69,8 +86,8 @@ node default {
database_user => "nailgun", database_user => "nailgun",
database_passwd => "nailgun", database_passwd => "nailgun",
staticdir => "/opt/nailgun/share/nailgun/static", staticdir => $staticdir,
templatedir => "/opt/nailgun/share/nailgun/static", templatedir => $staticdir,
cobbler_url => "http://localhost/cobbler_api", cobbler_url => "http://localhost/cobbler_api",
cobbler_user => $cobbler_user, 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( class nailgun(
$package, $package,
$version, $version,
$production,
$venv,
$nailgun_group = "nailgun", $nailgun_group = "nailgun",
$nailgun_user = "nailgun", $nailgun_user = "nailgun",
$venv = "/opt/nailgun",
$repo_root = "/var/www/nailgun", $repo_root = "/var/www/nailgun",
$pip_index = "", $pip_index = "",
@ -17,8 +18,8 @@ class nailgun(
$database_user = "nailgun", $database_user = "nailgun",
$database_passwd = "nailgun", $database_passwd = "nailgun",
$staticdir = "/opt/nailgun/share/nailgun/static", $staticdir,
$templatedir = "/opt/nailgun/share/nailgun/static", $templatedir,
$logdumpdir = "/var/www/nailgun/dump", $logdumpdir = "/var/www/nailgun/dump",
$cobbler_url = "http://localhost/cobbler_api", $cobbler_url = "http://localhost/cobbler_api",
@ -110,6 +111,7 @@ class nailgun(
package => $package, package => $package,
version => $version, version => $version,
pip_opts => "${pip_index} ${pip_find_links}", pip_opts => "${pip_index} ${pip_find_links}",
production => $production,
nailgun_user => $nailgun_user, nailgun_user => $nailgun_user,
nailgun_group => $nailgun_group, nailgun_group => $nailgun_group,
@ -142,8 +144,17 @@ class nailgun(
gem_source => $gem_source, 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": class { "nailgun::supervisor":
venv => $venv, nailgun_env => $nailgun_env,
ostf_env => $ostf_env,
} }
class { "nailgun::nginx-repo": class { "nailgun::nginx-repo":
@ -202,6 +213,7 @@ class nailgun(
class { "nailgun::logrotate": } class { "nailgun::logrotate": }
class { "nailgun::ostf": class { "nailgun::ostf":
production => $production,
pip_opts => "${pip_index} ${pip_find_links}", pip_opts => "${pip_index} ${pip_find_links}",
} }

View File

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

View File

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

View File

@ -15,7 +15,7 @@ childlogdir=/var/log/supervisor
serverurl=unix:///var/run/supervisor.sock serverurl=unix:///var/run/supervisor.sock
[program:nailgun] [program:nailgun]
command=<%= @venv %>/bin/nailgund command=<%= @nailgun_env %>/bin/nailgund
process_name=%(program_name)s process_name=%(program_name)s
numprocs=1 numprocs=1
numprocs_start=0 numprocs_start=0
@ -33,7 +33,7 @@ stdout_events_enabled=false
serverurl=AUTO serverurl=AUTO
[program:assassind] [program:assassind]
command=<%= @venv %>/bin/assassind command=<%= @nailgun_env %>/bin/assassind
process_name=%(program_name)s process_name=%(program_name)s
numprocs=1 numprocs=1
numprocs_start=0 numprocs_start=0
@ -51,7 +51,7 @@ stdout_events_enabled=false
serverurl=AUTO serverurl=AUTO
[program:receiverd] [program:receiverd]
command=<%= @venv %>/bin/receiverd command=<%= @nailgun_env %>/bin/receiverd
process_name=%(program_name)s process_name=%(program_name)s
numprocs=1 numprocs=1
numprocs_start=0 numprocs_start=0
@ -94,7 +94,7 @@ stderr_events_enabled=false
serverurl=AUTO serverurl=AUTO
[program:ostf] [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 process_name=%(program_name)s
numprocs=1 numprocs=1
numprocs_start=0 numprocs_start=0