From 909e53130a6b7debec4d312d399985413a1e3a76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20=C3=81lvarez?= <128592227+malvads@users.noreply.github.com> Date: Fri, 16 Feb 2024 15:04:44 +0000 Subject: [PATCH] Add nginx config & certs creation for rb-aioutliers (#7) * Add rb-aioutliers to nginx * rename aioutliers.erb to aioutliers.conf.erb * Update changelog * aioutliers over http * Disable SSL --- CHANGELOG.md | 6 +++++ resources/metadata.rb | 2 +- resources/providers/config.rb | 26 +++++++++++++++++++ resources/resources/config.rb | 3 ++- .../templates/default/aioutliers.conf.erb | 26 +++++++++++++++++++ 5 files changed, 61 insertions(+), 2 deletions(-) create mode 100644 resources/templates/default/aioutliers.conf.erb diff --git a/CHANGELOG.md b/CHANGELOG.md index 8fa12e7..e2da386 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,12 @@ cookbook-nginx CHANGELOG This file is used to list changes made in each version of the nginx cookbook. +0.0.7 +----- +- [malvarez] + - Configure rb-aioutliers service + + 0.0.1 ----- - [cjmateos] diff --git a/resources/metadata.rb b/resources/metadata.rb index 259ec3e..41bc12e 100644 --- a/resources/metadata.rb +++ b/resources/metadata.rb @@ -4,4 +4,4 @@ license 'All rights reserved' description 'Installs/Configures cookbook-nginx' long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) -version '0.0.6' +version '0.0.7' diff --git a/resources/providers/config.rb b/resources/providers/config.rb index 2ace1c1..a90f5e1 100644 --- a/resources/providers/config.rb +++ b/resources/providers/config.rb @@ -145,6 +145,32 @@ end end +action :add_aioutliers do + begin + aioutliers_port = new_resource.aioutliers_port + + template "/etc/nginx/conf.d/aioutliers.conf" do + source "aioutliers.conf.erb" + owner user + group user + mode 0644 + cookbook "nginx" + variables(:aioutliers_port => aioutliers_port) + notifies :restart, "service[nginx]" + end + + service "nginx" do + service_name "nginx" + ignore_failure true + supports :status => true, :reload => true, :restart => true, :enable => true + action [:nothing] + end + + rescue => e + Chef::Log.error(e.message) + end +end + action :remove do begin diff --git a/resources/resources/config.rb b/resources/resources/config.rb index 879cc03..e0fcf08 100644 --- a/resources/resources/config.rb +++ b/resources/resources/config.rb @@ -3,11 +3,12 @@ # Resource:: config # -actions :add, :add_s3, :add_erchef, :configure_certs, :remove, :register, :deregister +actions :add, :add_s3, :add_erchef, :add_aioutliers, :configure_certs, :remove, :register, :deregister default_action :add attribute :user, :kind_of => String, :default => "nginx" attribute :s3_port, :kind_of => Integer, :default => 9000 attribute :erchef_port, :kind_of => Integer, :default => 4443 +attribute :aioutliers_port, :kind_of => Integer, :default => 39091 attribute :cdomain, :kind_of => String, :default => "redborder.cluster" attribute :service_name, :kind_of => String diff --git a/resources/templates/default/aioutliers.conf.erb b/resources/templates/default/aioutliers.conf.erb new file mode 100644 index 0000000..a31a32e --- /dev/null +++ b/resources/templates/default/aioutliers.conf.erb @@ -0,0 +1,26 @@ +####################################################### +## Generated by Chef +####################################################### + +upstream rb-aioutliers { + server localhost:<%= @aioutliers_port %> max_fails=3 fail_timeout=5s; + } + +server { + listen 80; + listen [::]:80; + + server_name rb-aioutliers.service; + + access_log /var/log/nginx/access-aioutliers.log main; + + client_max_body_size 512m; + + location /api/v1/outliers { + proxy_pass http://rb-aioutliers; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } +}