From 0ebcfb69a142eb3f9cb0193651e6a32b82835560 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20Negr=C3=B3n?= <45871721+manegron@users.noreply.github.com> Date: Fri, 31 May 2024 01:39:52 +0100 Subject: [PATCH 1/9] Update rpm.yml --- .github/workflows/rpm.yml | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/.github/workflows/rpm.yml b/.github/workflows/rpm.yml index 03352e5..5d83b78 100644 --- a/.github/workflows/rpm.yml +++ b/.github/workflows/rpm.yml @@ -18,7 +18,7 @@ jobs: uses: actions/checkout@v2 with: fetch-depth: 0 - + - name: Create tag based on metadata.rb id: create_tag run: | @@ -26,38 +26,55 @@ jobs: echo "TAG=$TAG" >> $GITHUB_ENV shell: bash + - name: Check if Tag Exists + id: check_tag + run: | + if git rev-parse "refs/tags/${{ env.TAG }}" >/dev/null 2>&1; then + echo "Tag ${{ env.TAG }} already exists, exiting." + exit 1 + fi + shell: bash + - name: Set Version + if: success() run: echo "VERSION=${{ env.TAG }}" >> $GITHUB_ENV - name: Run Docker Container + if: success() run: docker run --privileged -d --name builder --network host rockylinux:9 /bin/sleep infinity - name: Install build tools RPM + if: success() run: | docker cp ./ builder:/build docker exec builder bash -c "yum install -y epel-release && yum install -y make git mock" docker exec builder bash -c "rm -rf /etc/mock/default.cfg" - name: Setup SDK + if: success() run: | docker exec builder bash -c "curl https://raw.githubusercontent.com/redBorder/repoinit/master/sdk9.cfg > /build/sdk9.cfg" docker exec builder bash -c "echo \"config_opts['use_host_resolv'] = True\" >> /build/sdk9.cfg" docker exec builder bash -c "ln -s /build/sdk9.cfg /etc/mock/default.cfg" - name: Build RPM using mock + if: success() run: | docker exec builder bash -c "git config --global --add safe.directory /build" docker exec builder bash -c "cd /build/ && VERSION=${{ env.TAG }} make rpm" - name: Copy RPMS + if: success() run: | docker cp builder:/build/packaging/rpm/pkgs/. ./rpms - name: Delete non-.rpm files + if: success() run: | find ./rpms -type f -not -name '*.rpm' -exec rm {} \; - name: Release + if: success() uses: softprops/action-gh-release@v1 with: files: ./rpms/* From c35c19ef1f80564da8008da3ba6847f42feba0f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20Negr=C3=B3n?= <45871721+manegron@users.noreply.github.com> Date: Fri, 31 May 2024 01:40:33 +0100 Subject: [PATCH 2/9] Update README.md --- README.md | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 5e4cb64..b3d5469 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,17 @@ -# Nginx Cookbook +# cookbook-nginx +[![Build Status][build-shield]][build-url] +[![Linters][linters-shield]][linters-url] +[![License][license-shield]][license-url] -cookbook to install and configure redborder nginx cookbook + +[build-shield]: https://github.com/redBorder/cookbook-nginx/actions/workflows/rpm.yml/badge.svg?branch=master +[build-url]: https://github.com/redBorder/cookbook-nginx/actions/workflows/rpm.yml?query=branch%3Amaster +[linters-shield]: https://github.com/redBorder/cookbook-nginx/actions/workflows/lint.yml/badge.svg?event=push +[linters-url]: https://github.com/redBorder/cookbook-nginx/actions/workflows/lint.yml +[license-shield]: https://img.shields.io/badge/license-AGPLv3-blue.svg +[license-url]: https://github.com/cookbook-nginx/blob/HEAD/LICENSE + +Chef cookbook to install and configure redborder nginx ### Platforms @@ -8,7 +19,7 @@ cookbook to install and configure redborder nginx cookbook ### Chef -- Chef 12.0 or later +- Chef 15.7.0 or later ## Contributing @@ -20,7 +31,5 @@ cookbook to install and configure redborder nginx cookbook 6. Submit a Pull Request using Github ## License -GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007 -## Authors -Authors: Juan J. Prieto +GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007 From 95d5155f42b0a5d19567fd2574ca34f6931b131e Mon Sep 17 00:00:00 2001 From: Miguel Alvarez Date: Mon, 3 Jun 2024 17:01:56 +0100 Subject: [PATCH 3/9] Configure Minio Load Balancer --- resources/providers/config.rb | 25 ------------------------- resources/templates/default/s3.conf.erb | 4 +++- 2 files changed, 3 insertions(+), 26 deletions(-) diff --git a/resources/providers/config.rb b/resources/providers/config.rb index aa02cd6..67da22d 100644 --- a/resources/providers/config.rb +++ b/resources/providers/config.rb @@ -114,31 +114,6 @@ end end -action :add_s3 do # TODO: Create this resource in minio cookbook - begin - s3_port = new_resource.s3_port - - template '/etc/nginx/conf.d/s3.conf' do - source 's3.conf.erb' - owner user - group user - mode '0644' - cookbook 'nginx' - variables(s3_port: s3_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 :add_aioutliers do begin aioutliers_port = new_resource.aioutliers_port diff --git a/resources/templates/default/s3.conf.erb b/resources/templates/default/s3.conf.erb index e3a100b..eaaef3a 100644 --- a/resources/templates/default/s3.conf.erb +++ b/resources/templates/default/s3.conf.erb @@ -3,7 +3,9 @@ ####################################################### upstream s3 { - server localhost:<%= @s3_port %> weight=2 max_fails=3 fail_timeout=5s; + <% @s3_hosts.each do |server| %> + server <%= server %> weight=2 max_fails=3 fail_timeout=5s; + <% end %> } map $http_host $port_in_host { From ded1a473f90abce096f9569a9dc9be579ff808d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20=C3=81lvarez?= <128592227+malvads@users.noreply.github.com> Date: Tue, 4 Jun 2024 12:59:41 +0100 Subject: [PATCH 4/9] Update s3.conf.erb --- resources/templates/default/s3.conf.erb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/resources/templates/default/s3.conf.erb b/resources/templates/default/s3.conf.erb index eaaef3a..1358780 100644 --- a/resources/templates/default/s3.conf.erb +++ b/resources/templates/default/s3.conf.erb @@ -3,8 +3,9 @@ ####################################################### upstream s3 { - <% @s3_hosts.each do |server| %> - server <%= server %> weight=2 max_fails=3 fail_timeout=5s; + server <%= @s3_hosts.first %> max_fails=3 fail_timeout=5s; + <% @s3_hosts.drop(1).each do |server| %> + server <%= server %> backup max_fails=1 fail_timeout=10; <% end %> } From 6880cbdc3b5c0bf0a0620a99bded431dc5a0bc8a Mon Sep 17 00:00:00 2001 From: Miguel Alvarez Date: Mon, 10 Jun 2024 14:35:44 +0100 Subject: [PATCH 5/9] Remove add s3 from configure solo --- resources/recipes/configure_solo.rb | 2 +- resources/resources/config.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/recipes/configure_solo.rb b/resources/recipes/configure_solo.rb index 7ad6cc2..fb82627 100644 --- a/resources/recipes/configure_solo.rb +++ b/resources/recipes/configure_solo.rb @@ -5,5 +5,5 @@ nginx_config 'config' do service_name 's3' - action [:add, :configure_certs, :add_s3] + action [:add, :configure_certs] end diff --git a/resources/resources/config.rb b/resources/resources/config.rb index 1ffe3a6..28a9685 100644 --- a/resources/resources/config.rb +++ b/resources/resources/config.rb @@ -1,7 +1,7 @@ # Cookbook:: nginx # Resource:: config -actions :add, :add_s3, :add_erchef, :add_aioutliers, :configure_certs, :remove, :register, :deregister +actions :add, :add_erchef, :add_aioutliers, :configure_certs, :remove, :register, :deregister default_action :add attribute :user, kind_of: String, default: 'nginx' From dd1b69268a19072d410b7f389b13bbcdce4aaf79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20=C3=81lvarez?= <128592227+malvads@users.noreply.github.com> Date: Mon, 10 Jun 2024 14:44:37 +0100 Subject: [PATCH 6/9] Update config.rb --- resources/providers/config.rb | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/resources/providers/config.rb b/resources/providers/config.rb index 67da22d..c7904c2 100644 --- a/resources/providers/config.rb +++ b/resources/providers/config.rb @@ -89,6 +89,31 @@ end end +action :add_s3 do # Only for configure solo + begin + s3_port = new_resource.s3_port + + template '/etc/nginx/conf.d/s3.conf' do + source 's3.conf.erb' + owner user + group user + mode '0644' + cookbook 'nginx' + variables(s3_port: s3_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 :add_erchef do begin erchef_port = new_resource.erchef_port From 08dbca56c39400645f6778dd7b1970d353f52d9a Mon Sep 17 00:00:00 2001 From: Miguel Alvarez Date: Mon, 10 Jun 2024 15:13:56 +0100 Subject: [PATCH 7/9] Add back s3 --- resources/providers/config.rb | 4 ++-- resources/recipes/configure_solo.rb | 2 +- resources/resources/config.rb | 3 ++- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/resources/providers/config.rb b/resources/providers/config.rb index c7904c2..d165682 100644 --- a/resources/providers/config.rb +++ b/resources/providers/config.rb @@ -92,14 +92,14 @@ action :add_s3 do # Only for configure solo begin s3_port = new_resource.s3_port - + s3_hosts = new_resource.s3_hosts template '/etc/nginx/conf.d/s3.conf' do source 's3.conf.erb' owner user group user mode '0644' cookbook 'nginx' - variables(s3_port: s3_port) + variables(s3_hosts: s3_hosts, s3_port: s3_port) notifies :restart, 'service[nginx]' end diff --git a/resources/recipes/configure_solo.rb b/resources/recipes/configure_solo.rb index fb82627..7ad6cc2 100644 --- a/resources/recipes/configure_solo.rb +++ b/resources/recipes/configure_solo.rb @@ -5,5 +5,5 @@ nginx_config 'config' do service_name 's3' - action [:add, :configure_certs] + action [:add, :configure_certs, :add_s3] end diff --git a/resources/resources/config.rb b/resources/resources/config.rb index 28a9685..0667bb5 100644 --- a/resources/resources/config.rb +++ b/resources/resources/config.rb @@ -1,11 +1,12 @@ # Cookbook:: nginx # Resource:: config -actions :add, :add_erchef, :add_aioutliers, :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 :s3_hosts, kind_of: Array, default: ["localhost: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' From e5b2a9bc5ee6d8e2936aa4b770887ab6c21193c2 Mon Sep 17 00:00:00 2001 From: malvads Date: Wed, 12 Jun 2024 20:33:40 +0100 Subject: [PATCH 8/9] Fix lint --- resources/resources/config.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/resources/config.rb b/resources/resources/config.rb index 0667bb5..591b0f4 100644 --- a/resources/resources/config.rb +++ b/resources/resources/config.rb @@ -6,7 +6,7 @@ attribute :user, kind_of: String, default: 'nginx' attribute :s3_port, kind_of: Integer, default: 9000 -attribute :s3_hosts, kind_of: Array, default: ["localhost:9000"] +attribute :s3_hosts, kind_of: Array, default: ['localhost: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' From af3b0f09cbec96a55226ef6e7e3b7f0579171be0 Mon Sep 17 00:00:00 2001 From: David Vanhoucke Date: Thu, 13 Jun 2024 14:01:02 +0100 Subject: [PATCH 9/9] bump to 1.0.0 --- CHANGELOG.md | 12 ++++++++++++ resources/metadata.rb | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a73dc42..6d8ca84 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,18 @@ cookbook-nginx CHANGELOG =============== +## 1.0.0 + + - malvads + - [e5b2a9b] Fix lint + - [dd1b692] Update config.rb + - [ded1a47] Update s3.conf.erb + - [08dbca5] Add back s3 + - [6880cbd] Remove add s3 from configure solo + - [95d5155] Configure Minio Load Balancer + - [dd1b692] Update config.rb + - [ded1a47] Update s3.conf.erb + ## 0.0.8 - Miguel Negron - [717936a] lint avoid use constants for OpenSSL diff --git a/resources/metadata.rb b/resources/metadata.rb index f811d33..ce73159 100644 --- a/resources/metadata.rb +++ b/resources/metadata.rb @@ -3,4 +3,4 @@ maintainer_email 'git@redborder.com' license 'AGPL-3.0' description 'Installs/Configures cookbook-nginx' -version '0.0.8' +version '1.0.0'