mirror of https://github.com/interlegis/sigi.git
Sesostris Vieira
3 years ago
4 changed files with 0 additions and 274 deletions
@ -1,26 +0,0 @@ |
|||||
# -*- mode: ruby -*- |
|
||||
# vi: set ft=ruby : |
|
||||
|
|
||||
VAGRANTFILE_API_VERSION = "2" |
|
||||
|
|
||||
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| |
|
||||
|
|
||||
config.vm.box = "ubuntu/trusty64" |
|
||||
|
|
||||
config.vm.network :forwarded_port, guest: 80, host: 8080 |
|
||||
|
|
||||
config.vm.provision :shell, :path => "puppet/bootstrap.sh" |
|
||||
|
|
||||
# XXX Usando provisoriamente o modulo oficial ate que sincronizemos nosso repo |
|
||||
# XXX descomentar este trecho entao |
|
||||
|
|
||||
# config.vm.provision :shell, |
|
||||
# :path => "puppet/puppet_module_install_from_github.sh", |
|
||||
# :args => "jfryman-nginx interlegis/puppet-nginx" |
|
||||
|
|
||||
config.vm.provision :puppet do |puppet| |
|
||||
puppet.manifests_path = "puppet/manifests" |
|
||||
puppet.manifest_file = "site.pp" |
|
||||
end |
|
||||
|
|
||||
end |
|
@ -1,13 +0,0 @@ |
|||||
#!/bin/bash |
|
||||
|
|
||||
puppet_install () { |
|
||||
puppet module list | grep $1 || puppet module install $1 |
|
||||
} |
|
||||
|
|
||||
puppet_install puppetlabs-vcsrepo |
|
||||
puppet_install stankevich-python |
|
||||
|
|
||||
# XXX Usando provisoriamente o modulo oficial ate que sincronizemos nosso repo |
|
||||
# XXX retirar esta linha entao |
|
||||
puppet_install jfryman-nginx |
|
||||
|
|
@ -1,212 +0,0 @@ |
|||||
Exec { |
|
||||
path => '/usr/bin:/usr/sbin:/bin:/usr/local/bin', |
|
||||
} |
|
||||
|
|
||||
group { 'sigi': |
|
||||
ensure => 'present', |
|
||||
} |
|
||||
|
|
||||
user { 'sigi': |
|
||||
ensure => 'present', |
|
||||
system => true, |
|
||||
gid => 'sigi', |
|
||||
require => Group['sigi'] |
|
||||
} |
|
||||
|
|
||||
$package_deps = [ |
|
||||
# gerais |
|
||||
'git', 'supervisor', 'memcached', |
|
||||
|
|
||||
# para psycopg ('python-dev' ja eh instalado pelo modulo python) |
|
||||
'libpq-dev', |
|
||||
|
|
||||
# para ldap |
|
||||
'libldap2-dev', 'libsasl2-dev', 'libssl-dev'] |
|
||||
|
|
||||
package { $package_deps: } |
|
||||
|
|
||||
$sigi_dir = '/srv/sigi' |
|
||||
$sigidata_dir = '/srv/sigidata' |
|
||||
|
|
||||
vcsrepo { $sigi_dir: |
|
||||
ensure => latest, |
|
||||
provider => git, |
|
||||
source => 'https://github.com/interlegis/sigi.git', |
|
||||
revision => 'producao', |
|
||||
require => Package['git'], |
|
||||
} |
|
||||
|
|
||||
file { [ |
|
||||
'/var/log/sigi', |
|
||||
'/var/run/sigi', |
|
||||
]: |
|
||||
ensure => 'directory', |
|
||||
owner => 'sigi', |
|
||||
group => 'sigi', |
|
||||
require => Vcsrepo[$sigi_dir], |
|
||||
} |
|
||||
|
|
||||
file { "${sigi_dir}/media": |
|
||||
ensure => link, |
|
||||
target => "${sigidata_dir}/media", |
|
||||
} |
|
||||
|
|
||||
# TODO A pasta "${sigi_dir}/media" deve ser compartilhada entre instancias de cluster |
|
||||
|
|
||||
file { '/var/log/sigi/sigi-supervisor.log': |
|
||||
ensure => file, |
|
||||
} |
|
||||
|
|
||||
########################################################################### |
|
||||
# PYTHON |
|
||||
|
|
||||
if !defined(Class['python']) { |
|
||||
class { 'python': |
|
||||
version => 'system', |
|
||||
dev => true, |
|
||||
virtualenv => true, |
|
||||
pip => true, |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
$sigi_venv_dir = '/srv/.virtualenvs/sigi' |
|
||||
|
|
||||
file { ['/srv/.virtualenvs',]: |
|
||||
ensure => 'directory', |
|
||||
} |
|
||||
|
|
||||
python::virtualenv { $sigi_venv_dir : |
|
||||
require => File['/srv/.virtualenvs'], |
|
||||
} |
|
||||
|
|
||||
python::requirements { "${sigi_dir}/requirements/requirements.txt": |
|
||||
virtualenv => $sigi_venv_dir, |
|
||||
forceupdate => true, |
|
||||
require => [ |
|
||||
Python::Virtualenv[$sigi_venv_dir], |
|
||||
Vcsrepo[$sigi_dir], |
|
||||
Package[$package_deps] ] |
|
||||
} |
|
||||
|
|
||||
########################################################################### |
|
||||
# GERALDO (reporting) |
|
||||
file { "${sigi_venv_dir}/lib/python2.7/site-packages/reporting": |
|
||||
ensure => link, |
|
||||
target => "${sigi_venv_dir}/src/geraldo/reporting", |
|
||||
} |
|
||||
|
|
||||
########################################################################### |
|
||||
# DJANGO |
|
||||
|
|
||||
exec { 'collectstatic': |
|
||||
command => "${sigi_venv_dir}/bin/python manage.py collectstatic --noinput", |
|
||||
cwd => $sigi_dir, |
|
||||
require => [ |
|
||||
Python::Virtualenv[$sigi_venv_dir], |
|
||||
Vcsrepo[$sigi_dir], |
|
||||
Python::Requirements["${sigi_dir}/requirements/requirements.txt"], |
|
||||
] |
|
||||
} |
|
||||
|
|
||||
# TODO local_settings.py ... |
|
||||
|
|
||||
|
|
||||
########################################################################### |
|
||||
# SUPERVISOR |
|
||||
|
|
||||
# XXX trocar isso por algum plugin do puppet? |
|
||||
|
|
||||
$supervisor_conf = '/etc/supervisor/conf.d/sigi.conf' |
|
||||
|
|
||||
file { $supervisor_conf: |
|
||||
ensure => link, |
|
||||
target => "${sigi_dir}/etc/supervisor/conf.d/sigi.conf", |
|
||||
require => [ |
|
||||
Vcsrepo[$sigi_dir], |
|
||||
Package['supervisor'] ] |
|
||||
} |
|
||||
|
|
||||
exec { 'supervisor_update': |
|
||||
command => 'supervisorctl reread && supervisorctl update', |
|
||||
refreshonly => true, |
|
||||
subscribe => [ File[$supervisor_conf], Vcsrepo[$sigi_dir]], |
|
||||
} |
|
||||
|
|
||||
########################################################################### |
|
||||
# NGINX |
|
||||
|
|
||||
class { 'nginx': } |
|
||||
|
|
||||
nginx::resource::upstream { 'sigi_app_server': |
|
||||
members => [ 'unix:/var/run/sigi/sigi.sock' ], |
|
||||
upstream_fail_timeout => 0 |
|
||||
} |
|
||||
|
|
||||
# XXX trocar nome para server_name, p.ex. sigi01h.interlegis.leg.br |
|
||||
$sigi_vhost = 'localhost' |
|
||||
|
|
||||
nginx::resource::vhost { $sigi_vhost: |
|
||||
client_max_body_size => '4G', |
|
||||
access_log => '/var/log/sigi/sigi-access.log', |
|
||||
error_log => '/var/log/sigi/sigi-error.log', |
|
||||
use_default_location => false, |
|
||||
require => Vcsrepo[$sigi_dir], |
|
||||
|
|
||||
# TODO tentar usar try_files ao inves desse "if" |
|
||||
# vide http://stackoverflow.com/questions/19845566/in-nginxs-configuration-could-if-f-request-filename-cause-a-performan |
|
||||
# XXX este raw_append foi uma apelacao devido a limitacoes do modulo nginx |
|
||||
raw_append => ' |
|
||||
location / { |
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; |
|
||||
proxy_set_header Host $http_host; |
|
||||
proxy_redirect off; |
|
||||
if (!-f $request_filename) { |
|
||||
proxy_pass http://sigi_app_server; |
|
||||
break; |
|
||||
} |
|
||||
} |
|
||||
' |
|
||||
} |
|
||||
|
|
||||
nginx::resource::location { '/static/': |
|
||||
vhost => $sigi_vhost, |
|
||||
location_alias => '/srv/sigi/static/', |
|
||||
} |
|
||||
|
|
||||
nginx::resource::location { '/media/': |
|
||||
vhost => $sigi_vhost, |
|
||||
location_alias => '/srv/sigi/media/', |
|
||||
} |
|
||||
|
|
||||
########################################################################### |
|
||||
# CRON |
|
||||
|
|
||||
cron { 'atualiza_uso_servico': |
|
||||
command => "${sigi_venv_dir}/bin/python ${sigi_dir}/manage.py atualiza_uso_servico -v 0", |
|
||||
user => 'sigi', |
|
||||
hour => [0,] |
|
||||
} |
|
||||
|
|
||||
cron { 'clearsessions': |
|
||||
command => "${sigi_venv_dir}/bin/python ${sigi_dir}/manage.py clearsessions -v 0", |
|
||||
user => 'sigi', |
|
||||
hour => [0,] |
|
||||
} |
|
||||
|
|
||||
cron { 'sync_ldap': |
|
||||
command => "${sigi_venv_dir}/bin/python ${sigi_dir}/manage.py sync_ldap", |
|
||||
user => 'sigi', |
|
||||
hour => [0,] |
|
||||
} |
|
||||
|
|
||||
cron { 'gera_map_data': |
|
||||
command => "${sigi_venv_dir}/bin/python ${sigi_dir}/manage.py gera_map_data", |
|
||||
user => 'sigi', |
|
||||
hour => "*/1", |
|
||||
} |
|
||||
|
|
||||
cron { 'get_moodle_stats': |
|
||||
command => "${sigi_venv_dir}/bin/python ${sigi_dir}/manage.py get_moodle_stats -v 0", |
|
||||
user => 'sigi', |
|
||||
hour => "*/1", |
|
||||
} |
|
@ -1,23 +0,0 @@ |
|||||
#!/bin/bash |
|
||||
# argumentos: <nome do modulo> <github_user/nome_repo> |
|
||||
|
|
||||
nome_modulo=$1 |
|
||||
github_path=$2 |
|
||||
nome_repo=$(echo $github_path | cut -d / -f 2) |
|
||||
|
|
||||
modulo_instalado=$( puppet module list | grep -ic $nome_modulo ) |
|
||||
|
|
||||
if [ $modulo_instalado -eq 0 ] |
|
||||
then |
|
||||
TAR_FILE="/tmp/$nome_modulo.tar.gz" |
|
||||
|
|
||||
wget "https://github.com/$github_path/archive/master.tar.gz" -O $TAR_FILE |
|
||||
rm -fr "/tmp/$nome_repo-master" |
|
||||
tar -C /tmp -xf $TAR_FILE |
|
||||
|
|
||||
echo "Building module $nome_modulo..." |
|
||||
TAR_MODULE=$(puppet module build "/tmp/$nome_repo-master" | grep 'Module built' | cut -d\ -f 3) |
|
||||
echo "Installing module $nome_modulo from " $TAR_MODULE ' ...' |
|
||||
puppet module install $TAR_MODULE |
|
||||
fi |
|
||||
|
|
Loading…
Reference in new issue