diff --git a/Vagrantfile b/Vagrantfile index 228df1e..070c0e0 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -11,9 +11,12 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| config.vm.provision :shell, :path => "puppet/bootstrap.sh" - config.vm.provision :shell, - :path => "puppet/puppet_module_install_from_github.sh", - :args => "jfryman-nginx interlegis/puppet-nginx" + # 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" diff --git a/puppet/bootstrap.sh b/puppet/bootstrap.sh index 5d3aca4..dde9730 100644 --- a/puppet/bootstrap.sh +++ b/puppet/bootstrap.sh @@ -6,3 +6,8 @@ puppet_install () { 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 + diff --git a/puppet/manifests/site.pp b/puppet/manifests/site.pp index fbf8d1c..bdedecf 100644 --- a/puppet/manifests/site.pp +++ b/puppet/manifests/site.pp @@ -125,31 +125,45 @@ exec { 'supervisor_update': ########################################################################### # NGINX -package { 'nginx': } - -file { '/etc/nginx/sites-available/sigi.vhost': - ensure => link, - target => "${sigi_dir}/etc/nginx/sites-available/sigi.vhost", - require => [ - Vcsrepo[$sigi_dir], - Package['nginx'] ] -} - -file { '/etc/nginx/sites-enabled/sigi.vhost': - ensure => link, - target => '/etc/nginx/sites-available/sigi.vhost', - require => Package['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; + } + } +' } -exec { 'nginx_restart': - command => 'service nginx restart', - refreshonly => true, - subscribe => [ - File['/etc/nginx/sites-enabled/sigi.vhost'], - Vcsrepo[$sigi_dir]], +nginx::resource::location { '/static/': + vhost => $sigi_vhost, + location_alias => '/srv/sigi/static/', } -file { '/etc/nginx/sites-enabled/default': - ensure => absent, +nginx::resource::location { '/media/': + vhost => $sigi_vhost, + location_alias => '/srv/sigi/media/', } -