Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: priestjim/chef-openresty
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: 67P/chef-openresty
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Able to merge. These branches can be automatically merged.
  • 15 commits
  • 9 files changed
  • 2 contributors

Commits on Jul 5, 2023

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    c0f14b3 View commit details

Commits on Jul 6, 2023

  1. Update luarocks

    gregkare committed Jul 6, 2023
    Copy the full SHA
    8f087b5 View commit details
  2. Don't include the default recipe in luarocks recipe

    We don't want to compile openresty from source
    gregkare committed Jul 6, 2023
    Copy the full SHA
    db7df0f View commit details
  3. Add initial apt_package recipe

    It adds the official repository, installs openresty from the package and
    configures it
    gregkare committed Jul 6, 2023
    Copy the full SHA
    0406e84 View commit details

Commits on Jul 12, 2023

  1. Get rid of the converge_by

    It is supposed to be a block, so it wasn't doing anything
    gregkare committed Jul 12, 2023
    Copy the full SHA
    f48675c View commit details

Commits on Jul 17, 2023

  1. Disable aio by default

    It fails on Ubuntu on servers we've tried it on
    gregkare committed Jul 17, 2023
    Copy the full SHA
    1750612 View commit details
  2. Copy the full SHA
    9478577 View commit details
  3. Clean up the openresty_site resource

    * Remove unused variables
    * Rename site name variable
    gregkare committed Jul 17, 2023
    Copy the full SHA
    c6ee974 View commit details
  4. Add a redirect_http attribute

    It's set to true by default, and redirects HTTP to HTTPS for that
    host. It can listen on a specific IP using the `listen_ip` node
    attribute.
    gregkare committed Jul 17, 2023
    Copy the full SHA
    867046c View commit details

Commits on Jul 26, 2023

  1. Change default logs directory

    raucao committed Jul 26, 2023
    Copy the full SHA
    b31d6b0 View commit details
  2. Copy the full SHA
    7b13a95 View commit details
  3. Copy the full SHA
    d031d59 View commit details

Commits on Jul 30, 2023

  1. Copy the full SHA
    6e76dcb View commit details
  2. Add support for nginx streams

    raucao committed Jul 30, 2023
    Copy the full SHA
    fd3e5b0 View commit details

Commits on Jul 31, 2023

  1. Copy the full SHA
    bc916b9 View commit details
Showing with 225 additions and 72 deletions.
  1. +3 −1 attributes/default.rb
  2. +3 −3 attributes/luarocks.rb
  3. +0 −61 providers/site.rb
  4. +60 −0 recipes/apt_package.rb
  5. +1 −2 recipes/luarocks.rb
  6. +70 −5 resources/site.rb
  7. +74 −0 resources/stream.rb
  8. +7 −0 templates/default/nginx.conf.erb
  9. +7 −0 templates/default/redirect_http.conf.erb
4 changes: 3 additions & 1 deletion attributes/default.rb
Original file line number Diff line number Diff line change
@@ -140,7 +140,7 @@
default['openresty']['worker_rlimit_nofile'] = nil
default['openresty']['multi_accept'] = false

default['openresty']['try_aio'] = true
default['openresty']['try_aio'] = false

# epoll is available only on Linux kernels >= 2.6
if node['os'].eql?('linux') && node['kernel']['release'].to_f >= 2.6
@@ -156,6 +156,8 @@
default['openresty']['large_client_header_buffers'] = '32 32k'
default['openresty']['types_hash_max_size'] = 2048
default['openresty']['types_hash_bucket_size'] = 64
default['openresty']['variables_hash_max_size'] = 1024
default['openresty']['variables_hash_bucket_size'] = 64

# Open file cache - for metadata operations only
default['openresty']['open_file_cache'] = {
6 changes: 3 additions & 3 deletions attributes/luarocks.rb
Original file line number Diff line number Diff line change
@@ -19,7 +19,7 @@
# limitations under the License.
#

default['openresty']['luarocks']['version'] = '2.4.2'
default['openresty']['luarocks']['url'] = "http://luarocks.org/releases/luarocks-#{node['openresty']['luarocks']['version']}.tar.gz"
default['openresty']['luarocks']['checksum'] = '0e1ec34583e1b265e0fbafb64c8bd348705ad403fe85967fd05d3a659f74d2e5'
default['openresty']['luarocks']['version'] = '3.9.2'
default['openresty']['luarocks']['url'] = "https://luarocks.org/releases/luarocks-#{node['openresty']['luarocks']['version']}.tar.gz"
default['openresty']['luarocks']['checksum'] = 'bca6e4ecc02c203e070acdb5f586045d45c078896f6236eb46aa33ccd9b94edb'
default['openresty']['luarocks']['default_rocks'] = Hash.new
61 changes: 0 additions & 61 deletions providers/site.rb

This file was deleted.

60 changes: 60 additions & 0 deletions recipes/apt_package.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Cookbook Name:: openresty
# Recipe:: apt_package
#

openresty_dir = '/usr/local/openresty'

node.force_default['openresty']['service']['resource'] = 'service[openresty]'
node.force_default['openresty']['dir'] = '/etc/openresty'
node.force_default['openresty']['log_dir'] = "/var/log/nginx"
node.force_default['openresty']['cache_dir'] = '/var/cache/nginx'
node.force_default['openresty']['binary'] = "#{openresty_dir}/nginx/sbin/nginx"
node.force_default['openresty']['pid'] = "#{openresty_dir}/nginx/logs/nginx.pid"
# Needed to compile LuaRocks
node.force_default['openresty']['source']['prefix'] = openresty_dir

apt_repository 'openresty' do
uri "https://openresty.org/package/#{node['platform']}"
distribution node['lsb']['codename']
components ['main']
key 'https://openresty.org/package/pubkey.gpg'
end

# Do not start the service automatically after installing the package.
# The default config listens on port 80 on every interface
execute "systemctl mask openresty" do
action :nothing
end

execute "systemctl unmask openresty" do
action :nothing
end

package 'openresty' do
notifies :run, "execute[systemctl mask openresty]", :before
notifies :run, "execute[systemctl unmask openresty]", :immediately
end

include_recipe 'openresty::ohai_plugin'
include_recipe 'openresty::commons_cleanup'
include_recipe 'openresty::commons_user'
include_recipe 'openresty::commons_dir'
include_recipe 'openresty::commons_script'
include_recipe 'openresty::commons_conf'
include_recipe 'openresty::luarocks'

file "#{openresty_dir}/nginx/html/index.html" do
action :delete
backup false
end
file "#{openresty_dir}/nginx/html/50x.html" do
action :delete
backup false
end

service 'openresty' do
supports :status => true, :restart => true, :reload => true
if node['openresty']['service']['start_on_boot']
action [ :enable, :start ]
end
end
3 changes: 1 addition & 2 deletions recipes/luarocks.rb
Original file line number Diff line number Diff line change
@@ -21,10 +21,9 @@

# Make sure we build with LUAJIT
node.override['openresty']['or_modules']['luajit'] = true
include_recipe 'openresty'

# Install needed packages
%w{ zip unzip }.each do |pkg|
%w{ build-essential zip unzip }.each do |pkg|
package pkg
end

75 changes: 70 additions & 5 deletions resources/site.rb
Original file line number Diff line number Diff line change
@@ -23,8 +23,73 @@

default_action :enable

attribute :name, :kind_of => String, :name_attribute => true
attribute :template, :kind_of => String, :default => nil
attribute :variables, :kind_of => Hash, :default => {}
attribute :cookbook, :kind_of => String, :default => nil
attribute :timing, [:delayed, :immediately], :default => :delayed
property :name, kind_of: String, name_property: true
property :template, kind_of: String, default: nil
property :variables, kind_of: Hash, default: {}
property :cookbook, kind_of: String, default: nil
property :timing, [:delayed, :immediately], default: :delayed
property :redirect_http, kind_of: [TrueClass, FalseClass], default: true

action :enable do
site_name = (new_resource.name == 'default') ? '000-default' : new_resource.name
openresty_dir = node['openresty']['dir']

if new_resource.template
if new_resource.redirect_http
template "#{openresty_dir}/sites-available/#{site_name}_http" do
source "redirect_http.conf.erb"
owner 'root'
group 'root'
mode 00644
variables new_resource.variables
cookbook 'openresty'
if node['openresty']['service']['start_on_boot']
notifies :reload, node['openresty']['service']['resource'], new_resource.timing
end
end

link "#{openresty_dir}/sites-enabled/#{site_name}_http" do
to "#{openresty_dir}/sites-available/#{site_name}_http"
action :create
notifies :reload, node['openresty']['service']['resource'], new_resource.timing
end
end

template "#{openresty_dir}/sites-available/#{site_name}" do
source new_resource.template
owner 'root'
group 'root'
mode 00644
variables new_resource.variables
cookbook new_resource.cookbook
if node['openresty']['service']['start_on_boot']
notifies :reload, node['openresty']['service']['resource'], new_resource.timing
end
end
end

link "#{openresty_dir}/sites-enabled/#{site_name}" do
to "#{openresty_dir}/sites-available/#{site_name}"
action :create
notifies :reload, node['openresty']['service']['resource'], new_resource.timing
end
end

action :disable do
site_name = (new_resource.name == 'default') ? '000-default' : new_resource.name
openresty_dir = node['openresty']['dir']

if new_resource.redirect_http
link "#{openresty_dir}/sites-enabled/#{site_name}_http" do
to "#{openresty_dir}/sites-available/#{site_name}_http"
action :delete
notifies :reload, node['openresty']['service']['resource'], new_resource.timing
end
end

link "#{openresty_dir}/sites-enabled/#{site_name}" do
to "#{openresty_dir}/sites-available/#{site_name}"
action :delete
notifies :reload, node['openresty']['service']['resource'], new_resource.timing
end
end
74 changes: 74 additions & 0 deletions resources/stream.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#
# Cookbook Name:: openresty
# Resource:: stream
#
# Author:: Kosmos Developers (<mail@kosmos.org>)
#
# Copyright 2023, Kosmos Developers
#
# Licensed under the Apache License, Version 2.0 (the 'License');
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an 'AS IS' BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

actions :enable, :disable

default_action :enable

property :name, kind_of: String, name_property: true
property :template, kind_of: String, default: nil
property :variables, kind_of: Hash, default: {}
property :cookbook, kind_of: String, default: nil
property :timing, [:delayed, :immediately], default: :delayed

action :enable do
openresty_dir = node['openresty']['dir']

[ "#{openresty_dir}/streams-enabled",
"#{openresty_dir}/streams-available" ].each do |dir|
directory dir do
owner 'root'
group 'root'
mode 00644
end
end

stream_name = (new_resource.name == 'default') ? '000-default' : new_resource.name
if new_resource.template
template "#{openresty_dir}/streams-available/#{stream_name}" do
source new_resource.template
owner 'root'
group 'root'
mode 00644
variables new_resource.variables
cookbook new_resource.cookbook
if node['openresty']['service']['start_on_boot']
notifies :reload, node['openresty']['service']['resource'], new_resource.timing
end
end
end

link "#{openresty_dir}/streams-enabled/#{stream_name}" do
to "#{openresty_dir}/streams-available/#{stream_name}"
action :create
notifies :reload, node['openresty']['service']['resource'], new_resource.timing
end
end

action :disable do
openresty_dir = node['openresty']['dir']

link "#{openresty_dir}/streams-enabled/#{stream_name}" do
to "#{openresty_dir}/streams-available/#{stream_name}"
action :delete
notifies :reload, node['openresty']['service']['resource'], new_resource.timing
end
end
7 changes: 7 additions & 0 deletions templates/default/nginx.conf.erb
Original file line number Diff line number Diff line change
@@ -89,6 +89,9 @@ http {
types_hash_max_size <%= node['openresty']['types_hash_max_size'] %>;
types_hash_bucket_size <%= node['openresty']['types_hash_bucket_size'] %>;

variables_hash_max_size <%= node['openresty']['variables_hash_max_size'] %>;
variables_hash_bucket_size <%= node['openresty']['variables_hash_bucket_size'] %>;

<% if node['openresty']['lua_package_path'] %>
lua_package_path <%= node['openresty']['lua_package_path'] %>;
<% end %>
@@ -103,3 +106,7 @@ http {
include <%= node['openresty']['dir'] %>/conf.d/*.conf;
include <%= node['openresty']['dir'] %>/sites-enabled/*;
}

stream {
include <%= node['openresty']['dir'] %>/streams-enabled/*;
}
7 changes: 7 additions & 0 deletions templates/default/redirect_http.conf.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
server {
listen <%= "#{node['openresty']['listen_ip']}:" if node['openresty']['listen_ip'] %>80;
server_name <%= @domain || @server_name %>;
location / {
return 301 https://$host$request_uri;
}
}