From 8cc7d40dd9930b34abfdbebd8a27acefc449d69c Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Sun, 15 Feb 2015 10:52:57 -0800 Subject: [PATCH] Get rid of force --- manifests/force.pp | 60 ---------------------- spec/defines/force_spec.rb | 102 ------------------------------------- 2 files changed, 162 deletions(-) delete mode 100644 manifests/force.pp delete mode 100644 spec/defines/force_spec.rb diff --git a/manifests/force.pp b/manifests/force.pp deleted file mode 100644 index 8ceeb17..0000000 --- a/manifests/force.pp +++ /dev/null @@ -1,60 +0,0 @@ -# force.pp -# force a package from a specific release - -define apt::force( - $release = false, - $version = false, - $timeout = 300, - $cfg_files = 'none', - $cfg_missing = false, -) { - - validate_re($cfg_files, ['^new', '^old', '^unchanged', '^none']) - validate_bool($cfg_missing) - - $provider = $apt::params::provider - - $version_string = $version ? { - false => undef, - default => "=${version}", - } - - $release_string = $release ? { - false => undef, - default => "-t ${release}", - } - - case $cfg_files { - 'new': { $config_files = '-o Dpkg::Options::="--force-confnew"' } - 'old': { $config_files = '-o Dpkg::Options::="--force-confold"' } - 'unchanged': { $config_files = '-o Dpkg::Options::="--force-confdef"' } - 'none', default: { $config_files = '' } - } - - case $cfg_missing { - true: { $config_missing = '-o Dpkg::Options::="--force-confmiss"' } - false, default: { $config_missing = '' } - } - - if $version == false { - if $release == false { - $install_check = "/usr/bin/dpkg -s ${name} | grep -q 'Status: install'" - } else { - # If installed version and candidate version differ, this check returns 1 (false). - $install_check = "/usr/bin/test \$(/usr/bin/apt-cache policy -t ${release} ${name} | /bin/grep -E 'Installed|Candidate' | /usr/bin/uniq -s 14 | /usr/bin/wc -l) -eq 1" - } - } else { - if $release == false { - $install_check = "/usr/bin/dpkg -s ${name} | grep -q 'Version: ${version}'" - } else { - $install_check = "/usr/bin/apt-cache policy -t ${release} ${name} | /bin/grep -q 'Installed: ${version}'" - } - } - - exec { "${provider} -y ${config_files} ${config_missing} ${release_string} install ${name}${version_string}": - unless => $install_check, - environment => ['LC_ALL=C', 'LANG=C'], - logoutput => 'on_failure', - timeout => $timeout, - } -} diff --git a/spec/defines/force_spec.rb b/spec/defines/force_spec.rb deleted file mode 100644 index 5c48ec6..0000000 --- a/spec/defines/force_spec.rb +++ /dev/null @@ -1,102 +0,0 @@ -require 'spec_helper' -describe 'apt::force', :type => :define do - let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian' } } - let :pre_condition do - 'include apt::params' - end - - let :title do - 'my_package' - end - - let :default_params do - { - :release => false, - :version => false, - :cfg_files => 'none', - :cfg_missing => false, - } - end - - describe "when using default parameters" do - it { should contain_exec("/usr/bin/apt-get -y install #{title}").with( - :unless => "/usr/bin/dpkg -s #{title} | grep -q 'Status: install'", - :logoutput => 'on_failure', - :timeout => '300' - ) } - end - - describe "when specifying release parameter" do - let :params do - default_params.merge(:release => 'testing') - end - it { should contain_exec("/usr/bin/apt-get -y -t #{params[:release]} install #{title}").with( - :unless => "/usr/bin/test \$(/usr/bin/apt-cache policy -t #{params[:release]} #{title} | /bin/grep -E 'Installed|Candidate' | /usr/bin/uniq -s 14 | /usr/bin/wc -l) -eq 1" - ) } - end - - describe "when specifying version parameter" do - let :params do - default_params.merge(:version => '1') - end - it { should contain_exec("/usr/bin/apt-get -y install #{title}=#{params[:version]}").with( - :unless => "/usr/bin/dpkg -s #{title} | grep -q 'Version: #{params[:version]}'" - ) } - end - - describe "when specifying cfg_files parameter" do - let :params do - default_params.merge(:cfg_files => 'unchanged') - end - it { should contain_exec('/usr/bin/apt-get -y -o Dpkg::Options::="--force-confdef" install my_package').with( - :unless => "/usr/bin/dpkg -s #{title} | grep -q 'Status: install'" - ) } - end - - describe "when specifying cfg_missing parameter" do - let :params do - default_params.merge(:cfg_missing => true) - end - it { should contain_exec('/usr/bin/apt-get -y -o Dpkg::Options::="--force-confmiss" install my_package').with( - :unless => "/usr/bin/dpkg -s #{title} | grep -q 'Status: install'" - ) } - end - - describe "when specifying cfg_files and cfg_missing parameter" do - let :params do - default_params.merge( - :cfg_files => 'unchanged', - :cfg_missing => true - ) - end - it { should contain_exec('/usr/bin/apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confmiss" install my_package').with( - :unless => "/usr/bin/dpkg -s #{title} | grep -q 'Status: install'" - ) } - end - - describe "when specifying release and version parameters" do - let :params do - default_params.merge( - :release => 'testing', - :version => '1' - ) - end - it { should contain_exec("/usr/bin/apt-get -y -t #{params[:release]} install #{title}=1").with( - :unless => "/usr/bin/apt-cache policy -t #{params[:release]} #{title} | /bin/grep -q 'Installed: #{params[:version]}'" - ) } - end - - describe "when specifying release, version, cfg_files and cfg_missing parameters" do - let :params do - default_params.merge( - :release => 'testing', - :version => '1', - :cfg_files => 'unchanged', - :cfg_missing => true - ) - end - it { should contain_exec('/usr/bin/apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confmiss" -t testing install my_package=1').with( - :unless => "/usr/bin/apt-cache policy -t #{params[:release]} #{title} | /bin/grep -q 'Installed: #{params[:version]}'" - ) } - end -end -- 2.32.3