Skip to content

Commit

Permalink
Merge pull request #348 from johnbellone/poise-archive
Browse files Browse the repository at this point in the history
WIP: Update cookbook to use poise-archive for unzipping.
  • Loading branch information
johnbellone authored Oct 4, 2016
2 parents e0ab571 + 20f8f40 commit 966dadf
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 28 deletions.
12 changes: 8 additions & 4 deletions .kitchen.dokken.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,12 @@ driver:
name: dokken
chef_version: latest
privileged: true

transport:
name: dokken

provisioner:
name: dokken

verifier:
root_path: /opt/verifier

platforms:
- name: centos-7
named_run_list: centos
Expand Down Expand Up @@ -103,3 +99,11 @@ suites:
server: true
datacenter: FortMeade
encrypt: CGXC2NsXW4AvuB4h5ODYzQ==
- name: archive
provisioner:
policyfile: test/fixtures/policies/default.rb
attributes:
consul:
provider: binary
options:
version: 0.7.0
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ env:
- INSTANCE=default-ubuntu-1204
- INSTANCE=default-debian-8
- INSTANCE=default-debian-7
- INSTANCE=archive-centos-7
- INSTANCE=archive-centos-6
- INSTANCE=archive-ubuntu-1604
- INSTANCE=archive-ubuntu-1404
before_script:
# https://github.com/zuazo/kitchen-in-travis-native/issues/1#issuecomment-142230889
- sudo iptables -L DOCKER || ( echo "DOCKER iptables chain missing" ; sudo iptables -N DOCKER )
Expand Down
34 changes: 11 additions & 23 deletions libraries/consul_installation_binary.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,33 +32,25 @@ def self.provides_auto?(_node, _resource)
# @return [Hash]
# @api private
def self.default_inversion_options(node, resource)
archive_basename = binary_basename(node, resource)
extract_to = node.windows? ? node.config_prefix_path : '/opt/consul'
super.merge(
version: resource.version,
archive_url: default_archive_url % { version: resource.version, basename: archive_basename },
archive_basename: archive_basename,
archive_checksum: binary_checksum(node, resource),
extract_to: extract_to
)
extract_path = node.windows? ? node.config_prefix_path : '/opt/consul'
super.merge(extract_to: extract_path,
version: resource.version,
archive_url: 'https://releases.hashicorp.com/consul/%{version}/%{basename}',
archive_basename: binary_basename(node, resource),
archive_checksum: binary_checksum(node, resource))
end

def action_create
archive_url = options[:archive_url] % {
version: options[:version],
basename: options[:archive_basename]
}

notifying_block do
directory join_path(options[:extract_to], new_resource.version) do
mode '0755'
recursive true
end

zipfile options[:archive_basename] do
path join_path(options[:extract_to], new_resource.version)
source archive_url
checksum options[:archive_checksum]
url = options[:archive_url] % {version: options[:version], basename: options[:archive_basename]}
poise_archive url do
destination join_path(options[:extract_to], new_resource.version)
source_properties checksum: options[:archive_checksum]
not_if { ::File.exist?(consul_program) }
end
end
Expand All @@ -67,8 +59,8 @@ def action_create
def action_remove
notifying_block do
directory join_path(options[:extract_to], new_resource.version) do
recursive true
action :delete
recursive true
end
end
end
Expand All @@ -78,10 +70,6 @@ def consul_program
windows? ? @program + '.exe' : @program
end

def self.default_archive_url
"https://releases.hashicorp.com/consul/%{version}/%{basename}" # rubocop:disable Style/StringLiterals
end

def self.binary_basename(node, resource)
case node['kernel']['machine']
when 'x86_64', 'amd64' then ['consul', resource.version, node['os'], 'amd64'].join('_')
Expand Down
2 changes: 1 addition & 1 deletion metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
depends 'golang'
depends 'firewall', '~> 2.0'
depends 'poise', '~> 2.2'
depends 'poise-archive', '~> 1.3'
depends 'poise-service', '~> 1.4'
depends 'rubyzip', '~> 1.3'
depends 'yum-epel'

source_url 'https://github.com/johnbellone/consul-cookbook' if respond_to?(:source_url)
Expand Down

0 comments on commit 966dadf

Please sign in to comment.