Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/libarchive #93

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ gem 'stove'
gem 'test-kitchen'
gem 'winrm'
gem 'winrm-fs'
gem 'ffi-libarchive'
6 changes: 3 additions & 3 deletions metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
license 'Apache-2.0'
description 'Installs/Configures consul-template'
long_description 'Installs/Configures consul-template'
version '0.13.0'
version '0.14.0'

recipe 'consul-template', 'Installs, configures, and starts the consul-template service.'
recipe 'consul-template::install_binary', 'Installs consul-template from binary.'
Expand All @@ -17,11 +17,11 @@
supports 'arch'
supports 'windows'

depends 'libarchive'
depends 'libarchive', '>= 2.0.0'
depends 'golang'
depends 'runit'
depends 'nssm'

issues_url 'https://github.com/adamkrone/chef-consul-template/issues' if respond_to?(:issues_url)
source_url 'https://github.com/adamkrone/chef-consul-template' if respond_to?(:source_url)
chef_version '>= 12.1' if respond_to?(:chef_version)
chef_version '>= 14.0' if respond_to?(:chef_version)
28 changes: 20 additions & 8 deletions recipes/install_binary.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#
#

include_recipe 'libarchive::default'
include_recipe 'libarchive::default' unless Chef::VERSION.to_i >= 14
require 'chef/version_constraint'

url = ::URI.join(node['consul_template']['base_url'],
Expand All @@ -23,15 +23,27 @@
action :create_if_missing
end

libarchive_file ConsulTemplateHelpers.install_file(node) do
path download_path
extract_to install_path
mode 0o755
not_if { File.exist? install_path }
action :extract
libarchive_version = run_context.cookbook_collection['libarchive'].version.to_f.round(2)
case libarchive_version
when 2.0
archive_file ConsulTemplateHelpers.install_file(node) do
path download_path
extract_to install_path
mode 0755
not_if { File.exist? install_path }
action :extract
end
when libarchive_version < 2.0
libarchive_file ConsulTemplateHelpers.install_file(node) do
path download_path
extract_to install_path
mode 0755
not_if { File.exist? install_path }
action :extract
end
end

link "#{node['consul_template']['install_dir']}/consul-template" do
to "#{install_path}/consul-template"
mode 0o755
mode 0755
end