From d545245508d28349a989dff2e591635fa2bd4b74 Mon Sep 17 00:00:00 2001 From: Tomas Barton Date: Thu, 27 Jun 2019 10:03:23 +0200 Subject: [PATCH] Support proxy_server for archive install method (#133) --- README.md | 10 +++++++ manifests/init.pp | 1 + manifests/install/archive.pp | 5 +++- manifests/params.pp | 1 + spec/classes/install_spec.rb | 55 ++++++++++++++++++++++++++++++++++++ 5 files changed, 71 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ddad0b7..797a2da 100644 --- a/README.md +++ b/README.md @@ -269,6 +269,16 @@ class { 'zookeeper': } ``` +Optionally you can specify a `proxy_server`: + +```puppet +class { 'zookeeper': + install_method => 'archive', + archive_version => '3.4.8', + proxy_server => 'http://10.0.0.1:8080' +} +``` + ## Java installation Default: `false` diff --git a/manifests/init.pp b/manifests/init.pp index edbc124..398ed42 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -21,6 +21,7 @@ Boolean $archive_symlink = $::zookeeper::params::archive_symlink, String $archive_symlink_name = $::zookeeper::params::archive_symlink_name, String $archive_version = $::zookeeper::params::archive_version, + Optional[String] $proxy_server = $::zookeeper::params::proxy_server, Optional[String] $cdhver = $::zookeeper::params::cdhver, Boolean $install_java = $::zookeeper::params::install_java, String $install_method = $::zookeeper::params::install_method, diff --git a/manifests/install/archive.pp b/manifests/install/archive.pp index 896ef3c..eb4cc1d 100644 --- a/manifests/install/archive.pp +++ b/manifests/install/archive.pp @@ -26,11 +26,14 @@ default => $::zookeeper::archive_dl_url, } - archive { "${::zookeeper::archive_install_dir}/${filename}.tar.gz": + $archive_file = "${::zookeeper::archive_install_dir}/${filename}.tar.gz" + + archive { $archive_file: ensure => present, user => 'root', group => 'root', source => $download_url, + proxy_server => $::zookeeper::proxy_server, checksum => $::zookeeper::archive_checksum['hash'], checksum_type => $::zookeeper::archive_checksum['type'], extract_path => $::zookeeper::archive_install_dir, diff --git a/manifests/params.pp b/manifests/params.pp index 149e62f..d8f1bc3 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -83,6 +83,7 @@ $java_opts = '' $java_package = undef $repo = undef + $proxy_server = undef # service options $manage_service = true diff --git a/spec/classes/install_spec.rb b/spec/classes/install_spec.rb index 4425d3e..c82a4f4 100644 --- a/spec/classes/install_spec.rb +++ b/spec/classes/install_spec.rb @@ -429,4 +429,59 @@ }) end end + + context 'installing 3.4.8 from tar archive over proxy server' do + let(:install_dir) { '/opt' } + let(:zoo_dir) { '/opt/zookeeper' } + let(:vers) { '3.4.8' } + let(:mirror_url) { 'http://archive.apache.org/dist' } + let(:basefilename) { "zookeeper-#{vers}.tar.gz" } + let(:package_url) { "#{mirror_url}/zookeeper/zookeeper-#{vers}/zookeeper-#{vers}.tar.gz" } + let(:extract_path) { "#{zoo_dir}-#{vers}" } + + let(:facts) {{ + :operatingsystem => 'Ubuntu', + :osfamily => 'Debian', + :lsbdistcodename => 'bionic', + :operatingsystemmajrelease => '18.04', + :puppetversion => Puppet.version, + }} + + let :pre_condition do + 'class {"zookeeper": + install_method => "archive", + proxy_server => "http://10.0.0.1:8080", + archive_version => "3.4.8", + archive_install_dir => "/opt", + zoo_dir => "/opt/zookeeper", + }' + end + + it do + is_expected.to contain_file(zoo_dir).with({ + :ensure => 'link', + :target => extract_path, + }) + end + it do + should contain_archive("#{install_dir}/#{basefilename}").with({ + extract_path: install_dir, + source: package_url, + creates: extract_path, + proxy_server: 'http://10.0.0.1:8080', + user: 'root', + group: 'root', + }) + end + + it do + is_expected.to contain_file('/etc/zookeeper').with({ + :ensure => 'directory', + :owner => 'zookeeper', + :group => 'zookeeper', + }) + end + end + + end