priestjim / chef-openresty Goto Github PK
View Code? Open in Web Editor NEWAn Opscode Chef cookbook for the OpenResty NGINX bundle
License: Other
An Opscode Chef cookbook for the OpenResty NGINX bundle
License: Other
Looks like SourceForge is currently in "disaster recovery" mode and won't let the cookbook download the binaries, thus failing the checksum match.
This can be confirmed by running wget https://sourceforge.net/projects/pcre/files/pcre/8.38/pcre-8.38.tar.bz2/download
which pulls a HTML file instead of the correct binaries.
Maybe we should use a different host to grab PCRE from?
In 00036f6, you tightened the ohai
constraint and I don't understand why. Flipping through the issue mentioned in the commit message, there's talk of the Ohai gem, but nothing about the cookbook. I am using the openresty
cookbook in Chef environments that have their ohai
cookbook version pinned at >= 5.0.0
which doesn't seem to cause any issues with openresty
at 0.5.5
. Would you consider loosening it again?
Seems as if the source is being recompiled on every run, which is less than ideal. I don't see any way to prevent this via an attribute, but I may very well be missing something.
It seems that the commons_build recipe doesn't have a guard in the bash[compile_openresty_source] block, but I figured I'd run it by you before thinking about how best to go about fixing it.
Openresty upgrade fails when I try attribute override in a wrapper recipe like this:
override['openresty']['source']['version'] = '1.7.10.2'
override['openresty']['source']['checksum'] = '5E8BEAFB7B32BA62FD34B323B2E9CF49884B4F0491FCCF189F0B88B3E25DD0E4'
You can see error here -> https://gist.github.com/TanmayaA/e1b0bd64515d5f208859
Looks like a merge issue in #36 broke compile (I suspect this broke all of them...) -
before:
cd ngx_openresty-#{node['openresty']['source']['version']} &&
mine before merge:
cd ngx_openresty-#{node['openresty']['source']['version']} &&
merged:
cd #{node['openresty']['source']['name']} &&
There's a knock-on issue related to the merge that broke this (making ['name'] dynamic - introduced a large number of delayed interpolation issues), too - I'll address that in another issue, though since it only impacts you if you change the version attribute from default - I suspect this breaks anyone who compiles.
Expected process to exit with [0], but received '1'
---- Begin output of "bash" "/tmp/chef-script20160520-16429-z5r8oj" ----
STDOUT:
STDERR: /tmp/chef-script20160520-16429-z5r8oj: line 2: cd: openresty-1.9.7.3: No such file or directory
---- End output of "bash" "/tmp/chef-script20160520-16429-z5r8oj" ----
Ran "bash" "/tmp/chef-script20160520-16429-z5r8oj" returned 1
Resource Declaration:
---------------------
# In /opt/chefprov/Provisioning/berkshelf-cookbooks/openresty/recipes/commons_build.rb
169: bash 'compile_openresty_source' do
170: cwd ::File.dirname(src_filepath)
171: code <<-EOH
172: tar zxf #{::File.basename(src_filepath)} -C #{::File.dirname(src_filepath)} &&
173: cd #{node['openresty']['source']['name']} &&
174: #{subreq_opts}
175: #{pcre_opts}
176: ./configure #{node.run_state['openresty_configure_flags'].join(' ')} &&
177: make -j#{node['cpu']['total']} && make install #{restart_on_update}
178: EOH
179:
180: # OpenResty configure args massaging due to the configure script adding its own arguments along our custom ones
181: if Chef::Config[:solo]
182: not_if do
183: openresty_force_recompile == false &&
184: node.automatic_attrs['nginx'] &&
185: node.automatic_attrs['nginx']['version'] == node['openresty']['source']['version'] &&
186: (::File.read(::File.join(::File.dirname(src_filepath), 'openresty.configure-opts')) || '' rescue '') ==
187: configure_flags.sort.uniq.join("\n")
188: end
189: else
190: not_if do
191: openresty_force_recompile == false &&
192: node.automatic_attrs['nginx'] &&
193: node.automatic_attrs['nginx']['version'] == node['openresty']['source']['version'] &&
194: node['openresty']['persisted_configure_flags'] &&
195: node['openresty']['persisted_configure_flags'] == configure_flags.sort.uniq
196: end
197: end
198:
In one of the last commits (841daa8) you've changed the file name of the site in sites-available
to be 000-default
if the name of the site is default
, but you're calling nxensite #{new_resource.name}
which is not 000-default
, but rather default
:
I can't install openresty due to this exception.
Chef::Exceptions::ChecksumMismatch
----------------------------------
Checksum on resource (b9e02d) does not match checksum on content (818a4b)
Cookbook Trace:
---------------
/var/chef/runs/855ccda3-34bf-4b73-98ce-cdc269a3f086/local-mode-cache/cache/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/runner.rb:41:in `run_action'
Resource Declaration:
---------------------
# In /var/chef/runs/855ccda3-34bf-4b73-98ce-cdc269a3f086/local-mode-cache/cache/cookbooks/openresty/recipes/commons_build.rb
77: remote_file "#{pcre_path}.tar.bz2" do
78: owner 'root'
79: group 'root'
80: mode 00644
81: source node['openresty']['pcre']['url']
82: checksum node['openresty']['pcre']['checksum']
83: action :create
84: end
85: execute 'openresty-extract-pcre' do
Compiled Resource:
------------------
# Declared in /var/chef/runs/855ccda3-34bf-4b73-98ce-cdc269a3f086/local-mode-cache/cache/cookbooks/openresty/recipes/commons_build.rb:77:in `from_file'
remote_file("/var/chef/runs/855ccda3-34bf-4b73-98ce-cdc269a3f086/local-mode-cache/cache/pcre-8.38.tar.bz2") do
provider Chef::Provider::RemoteFile
action [:create]
retries 0
retry_delay 2
default_guard_interpreter :default
source ["https://sourceforge.net/projects/pcre/files/pcre/8.38/pcre-8.38.tar.bz2/download"]
use_etag true
use_last_modified true
declared_type :remote_file
cookbook_name "openresty"
recipe_name "commons_build"
checksum "b9e02d36e23024d6c02a2e5b25204b3a4fa6ade43e0a5f869f254f49535079df"
path "/var/chef/runs/855ccda3-34bf-4b73-98ce-cdc269a3f086/local-mode-cache/cache/pcre-8.38.tar.bz2"
owner "root"
group "root"
mode 420
end
Platform:
---------
x86_64-linux
We found out (because luarocks was down) that the openresty_luarock provider was trying to install a luarock even though it was already installed in the right version.
This line of code is responsible for this behavior:
chef-openresty/providers/luarock.rb
Line 34 in d4362c7
Is this expected behavior? Are we supposed to pass versions without the revision number?
Thanks
Please make new tag and release.
Reciepe is failing
Re-raising exception: NoMethodError - undefined method `[]' for nil:NilClass
/tmp/vagrant-chef-1/chef-solo-1/cookbooks/openresty/recipes/ohai_plugin.rb:28:in from_file' /tmp/vagrant-chef-1/chef-solo-1/cookbooks/openresty/recipes/default.rb:23:in
from_file'
Fetching 'openresty' from [email protected]:priestjim/chef-openresty.git (at master)
Fetching cookbook index from https://supermarket.chef.io...
ERROR: Berkshelf::NoSolutionError: Unable to satisfy the following requirements:
- `yum (= 3.6.3)` required by `user-specified dependency`
- `yum (~> 3.2)` required by `yum-epel-0.6.2`
- `yum (~> 3.10.0)` required by `yum-epel-0.6.2`
- `yum (~> 3.2)` required by `yum-repoforge-0.5.3`
- `yum (~> 3.0)` required by `erlang-1.5.8`
- `yum (~> 3.0)` required by `yum-erlang_solutions-0.2.0`
- `yum (>= 0.0.0)` required by `grafana-2.1.3`
- `yum (>= 0.0.0)` required by `graphite-0.1.6`
- `yum (~> 3.0)` required by `jenkins-2.3.1`
- `yum (~> 3.0)` required by `percona-0.16.1`
- `yum (>= 0.0.0)` required by `sphinx-1.1.0`
- `yum (>= 0.0.0)` required by `td-agent-2.1.0`
- `yum (>= 3.0.0)` required by `yum-mysql-community-0.1.17`
- `yum (>= 0.0.0)` required by `openresty-0.4.1`
It would be great if conf.d/*.conf was included outside of the default nginx.conf's http block. Here is the relevant section. That way other config files could be included without having to completely overwrite/customize nginx.conf, because some directives aren't allowed inside of http blocks.
Since you are installing Nginx with luajit by default is it possible to add lua_package_path
and lua_package_cpath
to the default nginx.conf
?
Example from docs:
...
html {
# set search paths for pure Lua external libraries (';;' is the default path):
lua_package_path '/foo/bar/?.lua;/blah/?.lua;;';
# set search paths for Lua external libraries written in C (can also use ';;'):
lua_package_cpath '/bar/baz/?.so;/blah/blah/?.so;;';
server {
...
}
}
I'm sometimes getting the following error:
ERROR: resource template[/etc/nginx/sites-available/default1] is configured to notify resource service[nginx] with action reload, but service[nginx] cannot be found in the resource collection. template[/etc/nginx/sites-available/default1] is defined in /var/chef/runs/ac11fec0-b0fe-4697-9d43-950fea5b5e00/local-mode-cache/cache/cookbooks/openresty/providers/site.rb:25:in `block in class_from_file'
site.rb line 25 is inside the enable action of the site lwrp.
ERROR: Berkshelf::InternalError: The following error occurred while reading the cookbook `openresty':
Ridley::Errors::FromFileParserError: Could not parse `/tmp/d20160408-31207-10d0e3x/metadata.rb': undefined method `chef_version' for #<Ridley::Chef::Cookbook::Metadata:0x007fecabc13aa0>
using chef 12.5 with latest berkshelf and ridley gem , still failing
default['openresty']['pcre']['url']
uses FTP and doesn't work behind a proxy. I'm using in AWS VPC.
Logs:
* remote_file[/var/chef/cache/pcre-8.38.tar.bz2] action create
================================================================================
Error executing action `create` on resource 'remote_file[/var/chef/cache/pcre-8.38.tar.bz2]'
================================================================================
Net::FTPConnectionError
-----------------------
not connected
Resource Declaration:
---------------------
# In /var/chef/cache/cookbooks/openresty/recipes/commons_build.rb
74: remote_file "#{pcre_path}.tar.bz2" do
75: owner 'root'
76: group 'root'
77: mode 00644
78: source node['openresty']['pcre']['url']
79: checksum node['openresty']['pcre']['checksum']
80: action :create
81: end
82: execute 'openresty-extract-pcre' do
Compiled Resource:
------------------
# Declared in /var/chef/cache/cookbooks/openresty/recipes/commons_build.rb:74:in `from_file'
remote_file("/var/chef/cache/pcre-8.38.tar.bz2") do
provider Chef::Provider::RemoteFile
action [:create]
retries 0
retry_delay 2
default_guard_interpreter :default
source ["ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.38.tar.bz2"]
use_etag true
use_last_modified true
declared_type :remote_file
cookbook_name "openresty"
recipe_name "commons_build"
checksum "b9e02d36e23024d6c02a2e5b25204b3a4fa6ade43e0a5f869f254f49535079df"
path "/var/chef/cache/pcre-8.38.tar.bz2"
owner "root"
group "root"
mode 420
atomic_update true
end
Is there anyway to download it using HTTP or HTTPS?
One of these changes broken our builds and we had the cookbook pinned to 0.3.5
Commits on Feb 22, 2016
@priestjim
Version bump for OpenResty
priestjim committed 17 hours ago
7773955
@priestjim
Merge pull request #39 from kuberkaul/master …
priestjim committed 17 hours ago
bc81aad
@kuberkaul
update the nginx-upstream-fair github link from SSH to HTTPS …
kuberkaul committed a day ago
Hi, I've been pulling my hair out trying to figure out why luarocks wouldn't install any of my rocks. By changing the LWRP to
Chef::Application.fatal!("Installation of OpenResty LUA rock [#{rock}] #{('version [' + version + ']') if version} failed" +
"\nSTDOUT: #{cmd.stdout}" +
"\nSTDERR: #{cmd.stderr}")
I was able to see luarocks was failing with a "Failed unpacking my.rock" message.
To solve this I had to install the package zip using apt-get install zip
. Forgive my chef-fu but I cannot provide a PR to do so.
ohai cookbook version 4.0.0 was released yesterday, which has breaking changes that are not compatible with this cookbook.
The main issue is that the ohai cookbook now uses a custom resource, and no longer defines attributes like node['ohai']['plugin_path'], which is used in this cookbook in recipes/ohai_plugin.rb.
The issue can be solve by pinning ohai to ~> 3.0.1 or < 4.0.0 or something similar.
It would be nice to be able to declare (either by attribute or LWRP) custom error pages. Then all we would have to do is include the file in our cookbooks and specify the source. Openresty cookbook would then copy them where it wants and put the entries for it into the config.
Hi, i've got stuck on some interesting issue. It turned out that bzip2 (which should be one of the basic tools) is not included into the CentOS 7 minimal install. Since this package is needed for the source build, i think it might be a good idea to add it to the comins_build.rb:46
package list just to check if it's installed
the new default['openresty']['source']['name'] attribute introduced in 0.4.0, as well as the default['openresty']['source']['url'] attribute suffer from delayed interpolation problems (see https://coderanger.net/derived-attributes/ for reference) -
specifically, if I specify just the ['version'] attribute, the ['url'] and ['name'] atrtributes don't change:
This results in cases like:
STDERR: /tmp/chef-script20160520-16429-z5r8oj: line 2: cd: openresty-1.9.7.3: No such file or directory ---- End output of "bash" "/tmp/chef-script20160520-16429-z5r8oj" ----
if you only set
node.override['openresty']['source']['version']="1.9.3.2"
#must set both due to lack of delayed interpolation
node.override['openresty']['source']['url']="https://openresty.org/download/ngx_openresty-#{node['openresty']['source']['version']}.tar.gz"
for example - we fetch 1.9.3.2, but ['name'] is still 1.9.7.3.
Anyway - poor explaination but I'm going to try to effect a fix (using %{} - which effects all consumers of the attr..)
Got an error when using this cookbook.
It fails to install the package "libatomic_ops-devel" declared in openresty/recipes/commons_build.rb
Installed on ec2 with the AMI "Red Hat Enterprise Linux 7.2 (HVM), SSD Volume Type - ami-e0c19f83"
No candidate version available for libatomic_ops-devel
yum_package("libatomic_ops-devel") do
action [:install]
retries 0
retry_delay 2
default_guard_interpreter :default
package_name "libatomic_ops-devel"
flush_cache {:before=>false, :after=>false}
declared_type :package
cookbook_name :openresty
recipe_name "commons_build"
end
While installing luasql-mysql, I faced this error:
Error: Could not find expected file mysql.h, or mysql.h for MYSQL -- you may have to install MYSQL in your system and/or pass MYSQL_DIR or MYSQL_INCDIR to the luarocks command. Example: luarocks install luasql-mysql MYSQL_DIR=/usr/local
In my case path is /usr/include/mysql/mysql.h
, so this could be MYSQL_DIR=/usr/include
So installation command should be next:
luarocks install luasql-mysql MYSQL_DIR=/usr/include
Looks like the fair module is failing when behind proxies. Please convert the URL to HTTPS so that they can work.
Example:
Recipe: openresty::fair_module
* git[/var/chef/cache/nginx-upstream-fair] action checkout
================================================================================
Error executing action `checkout` on resource 'git[/var/chef/cache/nginx-upstream-fair]'
================================================================================
Mixlib::ShellOut::ShellCommandFailed
------------------------------------
Expected process to exit with [0], but received '128'
---- Begin output of git ls-remote "git://github.com/gnosek/nginx-upstream-fair.git" "master*" ----
STDOUT:
STDERR: fatal: unable to connect to github.com:
github.com[0: 192.30.252.131]: errno=Connection timed out
---- End output of git ls-remote "git://github.com/gnosek/nginx-upstream-fair.git" "master*" ----
Ran git ls-remote "git://github.com/gnosek/nginx-upstream-fair.git" "master*" returned 128
Resource Declaration:
---------------------
# In /var/chef/cache/cookbooks/openresty/recipes/fair_module.rb
26: git module_path do
27: repository node['openresty']['fair']['url']
28: reference 'master'
29: action :checkout
30: not_if { ::File.exists?(module_path) }
31: end
32:
Compiled Resource:
------------------
# Declared in /var/chef/cache/cookbooks/openresty/recipes/fair_module.rb:26:in `from_file'
git("/var/chef/cache/nginx-upstream-fair") do
action [:checkout]
retries 0
retry_delay 2
default_guard_interpreter :default
destination "/var/chef/cache/nginx-upstream-fair"
enable_checkout true
revision "master"
remote "origin"
checkout_branch "deploy"
declared_type :git
cookbook_name "openresty"
recipe_name "fair_module"
repository "git://github.com/gnosek/nginx-upstream-fair.git"
not_if { #code block }
end
The above would work if it had a url of:
https://github.com/gnosek/nginx-upstream-fair.git
The adding of chef_version to metadata in tag 0.4.0 doesn't sit well with the Berkshelf used bij AWS OpsWorks when using Chef 11.04
The Chef run now fails.
[2016-02-24T11:05:42+00:00] ERROR: Could not read /opt/aws/opsworks/current/merged-cookbooks/openresty into a Chef object: undefined method `chef_version' for #<Chef::Cookbook::Metadata:0x007f8287ddd7e8>
See also: berkshelf/berkshelf#1499
Working in tag 0.3.1, but on master, trying to install the md5
rock, fails with message:
luajit error Errno::ENOENT: No such file or directory - /usr/share/luajit/bin/luarocks show md5
I suspect its because of missing symbolic link luajit
:
$ ls -la /usr/share/luajit/bin/
total 2588
drwxr-xr-x 2 root root 4096 Jan 11 09:26 .
drwxr-xr-x 7 root root 4096 Jan 11 09:26 ..
-rwxr-xr-x 1 root root 2633600 Jan 11 09:26 luajit-2.1.0-alpha
lrwxrwxrwx 1 root root 34 Jan 11 09:26 luarocks -> /usr/share/luajit/bin/luarocks-5.1
-rwxr-xr-x 1 root root 1031 Jan 11 09:26 luarocks-5.1
lrwxrwxrwx 1 root root 40 Jan 11 09:26 luarocks-admin -> /usr/share/luajit/bin/luarocks-admin-5.1
-rwxr-xr-x 1 root root 570 Jan 11 09:26 luarocks-admin-5.1
$ /usr/share/luajit/bin/luarocks
-bash: /usr/share/luajit/bin/luarocks: /usr/share/luajit/bin/luajit: bad interpreter: No such file or directory
$ ln -s /usr/share/luajit/bin/luajit-2.1.0-alpha /usr/share/luajit/bin/luajit
$ /usr/share/luajit/bin/luarocks
LuaRocks 2.1.1, a module deployment system for Lua
....
Hello i got a problem on aws opsworks :
[Thu, 28 Mar 2013 08:49:53 +0000] ERROR: ruby_block[Load the custom cookbooks](/opt/aws/opsworks/releases/20130319123239_106/cookbooks/opsworks_custom_cookbooks/recipes/load.rb:3:in `from_file') had an error:
undefined method `default_action' for #Class:0xb5f8770c
Any ideas ?
Hi!
I'm using the default.rb when running the cookbook but I see openresty 1.5.11.1 installed and running on a new box from opsworks and also seen in vagrant.
This the version of the cookbook I'm using.
cookbook 'openresty', '~> 0.3.2'
When I tried to override the default value using a wrapper cookbook it would still download the 1.5.11.1 version and give me an error
==> default: Mixlib::ShellOut::ShellCommandFailed
==> default: ------------------------------------
==> default: Expected process to exit with [0], but received '1'
==> default: ---- Begin output of "bash" "/tmp/chef-script20150112-1718-1sorznf" ----
==> default: STDOUT:
==> default: STDERR: /tmp/chef-script20150112-1718-1sorznf: line 2: cd: ngx_openresty-1.7.7.1: No such file or directory
==> default: ---- End output of "bash" "/tmp/chef-script20150112-1718-1sorznf" ----
==> default: Ran "bash" "/tmp/chef-script20150112-1718-1sorznf" returned 1
==> default:
==> default:
==> default: Resource Declaration:
Am I missing something really obvious here?
I am wondering what are the key differences between the upstart script supplied by by this cookbook https://github.com/priestjim/chef-openresty/blob/master/templates/ubuntu/nginx.init.erb, and the upstart script in the nginx chef recipe: https://github.com/miketheman/nginx/blob/3.0.0-rewrite/templates/default/sysvinit/nginx.erb
They look somewhat similar to me. Would it be beneficial to make chef-openresty
dependent on nginx
chef recipe?
I see that the nginx.conf
is more comprehensive to support openresty lua in this repo: https://github.com/priestjim/chef-openresty/blob/master/templates/default/nginx.conf.erb vs https://github.com/miketheman/nginx/blob/3.0.0-rewrite/templates/default/nginx.conf.erb which is quite basic, perhaps thats the reason to not depend on the ngnix
chef recipe?
Line 195 of common_build.rb needs to include check for chef_server_url containing chefzero
https://github.com/priestjim/chef-openresty/blob/master/recipes/commons_build.rb#L195
Change to:
Line 195: if (Chef::Config[:solo] || Chef::Config[:chef_server_url].include?('chefzero'))
@priestjim any chance that you'll be bumping the version to 0.5.3 to reflect the last PR and pushing it to the supermarket? Would be very appreciated so that way we don't have to fork the cookbook.
The nginx
cookbook allowed to provide a template for the site configuration file using the template
method in the nginx_site
LWRP.
Since I could provide a template, I could also provide variables.
How can I do that in this cookbook ?
The latest version of this cookbook on the chef supermarket is 0.3.2.
Can you push 0.3.4?
Thanks
0.5.6...0.5.7#diff-6961d2ac46d2e913454e1cf7ac1d9cf0R28
Looks like this change brakes a installation to amazon linux.
when 'rhel' if node['platform_version'].to_i >= 7 'openresty::service_systemd' else 'openresty::service_init' end else
I have created a cookbook that has this one as a dependency. Everything works fine but I can't seem to be able to override attributes following the approach described here: https://www.chef.io/blog/2013/12/03/doing-wrapper-cookbooks-right/
In particular my problem is with the node['openresty']['source']['prefix']
attribute. In the attributes/default.rb of my cookbook I have:
default['openresty']['source']['prefix'] = '/etc'
But it is still deploying Nginx using the default value for that attribute, /usr/share
. I even tried specified the attribute as:
override['openresty']['source']['prefix'] = '/etc'
but that didn't work either.
I was wondering if you had any idea of why that might be happening.
If I set the same attribute by passing it in my node.json description it works fine then.
Thanks!
Nginx supports USR1 for reopening logs, here's what my (IO friendly) logrotate snippet looks like (postrotate is taken from Debian package):
logrotate_app 'openresty' do
path "#{node['openresty']['log_dir']}/*.log"
enable true
frequency 'daily'
rotate 7
cookbook 'logrotate'
create "0644 #{node['openresty']['user']} adm"
options [ 'missingok', 'delaycompress', 'notifempty', 'compress', 'sharedscripts' ]
postrotate "[ ! -f #{node['openresty']['pid']} ] || kill -USR1 `cat #{node['openresty']['pid']}`"
end
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.