From abace3482491371d5e16d42e85b7710e348a53cf Mon Sep 17 00:00:00 2001 From: Paulo Tada Date: Thu, 17 Dec 2015 15:36:22 -0200 Subject: [PATCH] Adding nginx configuration for mezuro machine --- cookbooks/mezuro/recipes/default.rb | 39 --------------------------------------- cookbooks/mezuro/recipes/kalibro_configurations.rb | 25 +++++++++++++++++++------ cookbooks/mezuro/recipes/kalibro_processor.rb | 24 ++++++++++++++++++------ cookbooks/mezuro/templates/kalibro_configurations/nginx.conf.erb | 20 ++++++++++++++++++++ cookbooks/mezuro/templates/kalibro_processor/nginx.conf.erb | 20 ++++++++++++++++++++ 5 files changed, 77 insertions(+), 51 deletions(-) delete mode 100644 cookbooks/mezuro/recipes/default.rb create mode 100644 cookbooks/mezuro/templates/kalibro_configurations/nginx.conf.erb create mode 100644 cookbooks/mezuro/templates/kalibro_processor/nginx.conf.erb diff --git a/cookbooks/mezuro/recipes/default.rb b/cookbooks/mezuro/recipes/default.rb deleted file mode 100644 index eed0a31..0000000 --- a/cookbooks/mezuro/recipes/default.rb +++ /dev/null @@ -1,39 +0,0 @@ -# Install kalibro configuration -# TODO: change the repo -execute 'download:repo' do - command 'wget https://copr.fedoraproject.org/coprs/ribeiro/athos-spb/repo/epel-7/ribeiro-athos-spb-epel-7.repo' - cwd '/etc/yum.repos.d' - user 'root' -end - -execute 'download:mezuro' do - command 'wget https://bintray.com/mezurometrics/rpm/rpm -O bintray-mezurometrics-rpm.repo' - cwd '/etc/yum.repos.d' - user 'root' -end - -package 'kalibro-configurations-deps' -package 'kalibro-configurations' -package 'kalibro-processor' - -service 'kalibro_configurations' do - action [:enable, :start] -end - -template '/etc/kalibro-configurations/database.yml' do - source 'kalibro_configurations/database.yml.erb' - owner 'kalibro_configurations' - group 'kalibro_configurations' - mode '0600' - notifies :restart, 'service[kalibro_configurations]' -end - -template '/etc/kalibro-processor/database.yml' do - source 'kalibro_processor/database.yml.erb' - owner 'kalibro_processor' - group 'kalibro_processor' - mode '0600' - action :nothing - #notifies :restart, 'service[kalibro_processor]' -end - diff --git a/cookbooks/mezuro/recipes/kalibro_configurations.rb b/cookbooks/mezuro/recipes/kalibro_configurations.rb index a50326e..00ffd9c 100644 --- a/cookbooks/mezuro/recipes/kalibro_configurations.rb +++ b/cookbooks/mezuro/recipes/kalibro_configurations.rb @@ -5,6 +5,17 @@ execute 'download:mezuro' do user 'root' end +package 'kalibro-configurations' +package 'nginx' + +service 'kalibro-configurations.target' do + action [:enable, :start] +end + +service 'nginx' do + action [:enable, :start] +end + template '/etc/mezuro/kalibro-configurations/database.yml' do source 'kalibro_configurations/database.yml.erb' owner 'kalibro_configurations' @@ -13,12 +24,6 @@ template '/etc/mezuro/kalibro-configurations/database.yml' do notifies :restart, 'service[kalibro-configurations.target]' end -package 'kalibro-configurations' - -service 'kalibro-configurations.target' do - action [:enable, :start] -end - CONFIGURATIONS_DIR='/usr/share/mezuro/kalibro-configurations' execute 'kalibro-configurations:schema' do @@ -33,3 +38,11 @@ execute 'kalibro-configurations:migrate' do user 'kalibro_configurations' notifies :restart, 'service[kalibro-configurations.target]' end + +template '/etc/nginx/conf.d/kalibro-configurations.conf' do + source 'kalibro_configurations/nginx.conf.erb' + owner 'root' + group 'root' + mode '0644' + notifies :restart, 'service[nginx]' +end diff --git a/cookbooks/mezuro/recipes/kalibro_processor.rb b/cookbooks/mezuro/recipes/kalibro_processor.rb index 94ac369..b99c406 100644 --- a/cookbooks/mezuro/recipes/kalibro_processor.rb +++ b/cookbooks/mezuro/recipes/kalibro_processor.rb @@ -4,6 +4,16 @@ execute 'download:mezuro' do user 'root' end +package 'kalibro-processor' + +service 'kalibro-processor.target' do + action [:enable, :start] +end + +service 'nginx' do + action [:enable, :start] +end + template '/etc/mezuro/kalibro-processor/database.yml' do source 'kalibro_processor/database.yml.erb' owner 'kalibro_processor' @@ -12,12 +22,6 @@ template '/etc/mezuro/kalibro-processor/database.yml' do notifies :restart, 'service[kalibro-processor.target]' end -package 'kalibro-processor' - -service 'kalibro-processor.target' do - action [:enable, :start] -end - PROCESSOR_DIR='/usr/share/mezuro/kalibro-processor' execute 'kalibro-processor:schema' do @@ -32,3 +36,11 @@ execute 'kalibro-processor:migrate' do user 'kalibro_processor' notifies :restart, 'service[kalibro-processor.target]' end + +template '/etc/nginx/conf.d/kalibro-processor.conf' do + source 'kalibro_processor/nginx.conf.erb' + owner 'root' + group 'root' + mode '0644' + notifies :restart, 'service[nginx]' +end diff --git a/cookbooks/mezuro/templates/kalibro_configurations/nginx.conf.erb b/cookbooks/mezuro/templates/kalibro_configurations/nginx.conf.erb new file mode 100644 index 0000000..0bc833b --- /dev/null +++ b/cookbooks/mezuro/templates/kalibro_configurations/nginx.conf.erb @@ -0,0 +1,20 @@ +# MANAGED WITH CHEF; DO NOT CHANGE BY HAND + +server { + listen *:83; + server_name <%= node['peers']['mezuro'] %>; + underscores_in_headers on; + access_log /var/log/nginx/kalibro-configurations.access.log; + error_log /var/log/nginx/kalibro-configurations.error.log; + client_max_body_size 0; + + location / { + try_files $uri @kalibro-configurations; + } + + location @kalibro-configurations { + proxy_pass http://10.10.10.8:8083; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + } +} diff --git a/cookbooks/mezuro/templates/kalibro_processor/nginx.conf.erb b/cookbooks/mezuro/templates/kalibro_processor/nginx.conf.erb new file mode 100644 index 0000000..09ce717 --- /dev/null +++ b/cookbooks/mezuro/templates/kalibro_processor/nginx.conf.erb @@ -0,0 +1,20 @@ +# MANAGED WITH CHEF; DO NOT CHANGE BY HAND + +server { + listen *:82; + server_name <%= node['peers']['mezuro'] %>; + underscores_in_headers on; + access_log /var/log/nginx/kalibro-processor.access.log; + error_log /var/log/nginx/kalibro-processor.error.log; + client_max_body_size 0; + + location / { + try_files $uri @kalibro-processor; + } + + location @kalibro-processor { + proxy_pass http://localhost:8082; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + } +} -- libgit2 0.21.2