Browse Source

Puppet: nginx usando modulo jfryman-nginx original

(nao o fork do interlegis)
producao
Marcio Mazza 10 years ago
parent
commit
be859820e9
  1. 9
      Vagrantfile
  2. 5
      puppet/bootstrap.sh
  3. 60
      puppet/manifests/site.pp

9
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"

5
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

60
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/',
}

Loading…
Cancel
Save