diff --git a/.kitchen.yml b/.kitchen.yml index 51e3d83..bbcc889 100644 --- a/.kitchen.yml +++ b/.kitchen.yml @@ -23,8 +23,6 @@ suites: attributes: caddy: features: - - cors - - git email: caddy@example.com # you cannot define two hosts but only one is a hash, there must at least be one key hosts: @@ -32,3 +30,19 @@ suites: tls: 'off' localhost: log: /var/tmp/caddy.log + - name: github + run_list: + - recipe[caddy::default] + attributes: + caddy: + ark: + url: https://github.com/mholt/caddy/releases/download/v0.8.3/caddy_linux_amd64.tar.gz + binary_name: caddy_linux_amd64 + features: + email: caddy@example.com + # you cannot define two hosts but only one is a hash, there must at least be one key + hosts: + localhost:8080: + tls: 'off' + localhost: + log: /var/tmp/caddy.log diff --git a/attributes/default.rb b/attributes/default.rb index 38875a6..a8ae184 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -1,4 +1,9 @@ default['caddy']['features'] = [] default['caddy']['email'] = nil default['caddy']['hosts'] = {} -default['caddy']['ulimit'] = 4096 +default['caddy']['ulimit'] = 8192 +default['caddy']['ark']['url'] = "https://caddyserver.com/download/build?os=linux&arch=amd64&features=#{node['caddy']['features'].join(',')}" +default['caddy']['ark']['extension'] = 'tar.gz' +default['caddy']['ark']['binary_name'] = 'caddy' +default['caddy']['ark']['binaries'] = ["./#{node['caddy']['ark']['binary_name']}"] +default['caddy']['ark']['strip_components'] = 0 diff --git a/recipes/default.rb b/recipes/default.rb index ee0af5b..46fb3d9 100644 --- a/recipes/default.rb +++ b/recipes/default.rb @@ -26,17 +26,17 @@ require 'chef/version_constraint' ark 'caddy' do - url "https://caddyserver.com/download/build?os=linux&arch=amd64&features=#{node['caddy']['features'].join(',')}" - extension 'tar.gz' - has_binaries ['./caddy'] - strip_components 0 + url node['caddy']['ark']['url'] + extension node['caddy']['ark']['extension'] + has_binaries node['caddy']['ark']['binaries'] + strip_components node['caddy']['ark']['strip_components'] notifies :restart, 'service[caddy]' end # caddy path as autogenerated by ark caddy_path = '/usr/local/caddy-1' -execute 'setcap cap_net_bind_service=+ep caddy' do +execute "setcap cap_net_bind_service=+ep #{node['caddy']['ark']['binary_name']}" do cwd caddy_path action :nothing subscribes :run, 'ark[caddy]', :immediately @@ -49,7 +49,7 @@ variables = ({ :workdir => caddy_path, - :command => '/usr/local/bin/caddy', + :command => "/usr/local/bin/#{node['caddy']['ark']['binary_name']}", :options => "#{caddy_letsencrypt_arguments} -pidfile /var/run/caddy.pid -log #{caddy_path}/caddy.log -conf /etc/Caddyfile", :ulimit => node['caddy']['ulimit'] })