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/* 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/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 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' diff --git a/resources/providers/config.rb b/resources/providers/config.rb index aa02cd6..d165682 100644 --- a/resources/providers/config.rb +++ b/resources/providers/config.rb @@ -89,17 +89,17 @@ end end -action :add_erchef do +action :add_s3 do # Only for configure solo begin - erchef_port = new_resource.erchef_port - - template '/etc/nginx/conf.d/erchef.conf' do - source 'erchef.conf.erb' + 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(erchef_port: erchef_port) + variables(s3_hosts: s3_hosts, s3_port: s3_port) notifies :restart, 'service[nginx]' end @@ -114,17 +114,17 @@ end end -action :add_s3 do # TODO: Create this resource in minio cookbook +action :add_erchef do begin - s3_port = new_resource.s3_port + erchef_port = new_resource.erchef_port - template '/etc/nginx/conf.d/s3.conf' do - source 's3.conf.erb' + template '/etc/nginx/conf.d/erchef.conf' do + source 'erchef.conf.erb' owner user group user mode '0644' cookbook 'nginx' - variables(s3_port: s3_port) + variables(erchef_port: erchef_port) notifies :restart, 'service[nginx]' end diff --git a/resources/resources/config.rb b/resources/resources/config.rb index 1ffe3a6..591b0f4 100644 --- a/resources/resources/config.rb +++ b/resources/resources/config.rb @@ -6,6 +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 :erchef_port, kind_of: Integer, default: 4443 attribute :aioutliers_port, kind_of: Integer, default: 39091 attribute :cdomain, kind_of: String, default: 'redborder.cluster' diff --git a/resources/templates/default/s3.conf.erb b/resources/templates/default/s3.conf.erb index e3a100b..1358780 100644 --- a/resources/templates/default/s3.conf.erb +++ b/resources/templates/default/s3.conf.erb @@ -3,7 +3,10 @@ ####################################################### upstream s3 { - server localhost:<%= @s3_port %> 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 %> } map $http_host $port_in_host {