(maint) facts update oracle.pp

puppet-archive, a puppetlabs-java dependency, is now using structured
facts on master. this commit changes the minimum number of facts from
legacy to structured so that spec tests continue to pass
This commit is contained in:
Eric Putnam
2017-05-26 20:59:42 -07:00
parent 3e284312b0
commit 7f843d4b5b
3 changed files with 56 additions and 42 deletions

View File

@@ -1,7 +1,6 @@
fixtures: fixtures:
repositories: repositories:
stdlib: "git://github.com/puppetlabs/puppetlabs-stdlib.git" stdlib: "git://github.com/puppetlabs/puppetlabs-stdlib.git"
archive: archive: "git://github.com/voxpupuli/puppet-archive.git"
repo: "git://github.com/voxpupuli/puppet-archive.git"
symlinks: symlinks:
java: "#{source_dir}" java: "#{source_dir}"

View File

@@ -142,9 +142,9 @@ define java::oracle (
} }
# determine package type (exe/tar/rpm), destination directory based on OS # determine package type (exe/tar/rpm), destination directory based on OS
case $::kernel { case $facts['kernel'] {
'Linux' : { 'Linux' : {
case $::osfamily { case $facts['os']['family'] {
'RedHat', 'Amazon' : { 'RedHat', 'Amazon' : {
# Oracle Java 6 comes in a special rpmbin format # Oracle Java 6 comes in a special rpmbin format
if $version == '6' { if $version == '6' {
@@ -154,7 +154,7 @@ define java::oracle (
} }
} }
default : { default : {
fail ("unsupported platform ${::operatingsystem}") } fail ("unsupported platform ${$facts['os']['name']}") }
} }
$os = 'linux' $os = 'linux'
@@ -162,15 +162,15 @@ define java::oracle (
$creates_path = "/usr/java/${install_path}" $creates_path = "/usr/java/${install_path}"
} }
default : { default : {
fail ( "unsupported platform ${::kernel}" ) } fail ( "unsupported platform ${$facts['kernel']}" ) }
} }
# set java architecture nomenclature # set java architecture nomenclature
case $::architecture { case $facts['os']['architecture'] {
'i386' : { $arch = 'i586' } 'i386' : { $arch = 'i586' }
'x86_64' : { $arch = 'x64' } 'x86_64' : { $arch = 'x64' }
default : { default : {
fail ("unsupported platform ${::architecture}") fail ("unsupported platform ${$facts['os']['architecture']}")
} }
} }
@@ -227,7 +227,7 @@ define java::oracle (
proxy_server => $proxy_server, proxy_server => $proxy_server,
proxy_type => $proxy_type, proxy_type => $proxy_type,
} }
case $::kernel { case $facts['kernel'] {
'Linux' : { 'Linux' : {
exec { "Install Oracle java_se ${java_se} ${version}" : exec { "Install Oracle java_se ${java_se} ${version}" :
path => '/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin', path => '/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin',
@@ -237,7 +237,7 @@ define java::oracle (
} }
} }
default : { default : {
fail ("unsupported platform ${::kernel}") fail ("unsupported platform ${$facts['kernel']}")
} }
} }
} }

View File

@@ -2,7 +2,7 @@ require 'spec_helper'
describe 'java::oracle', :type => :define do describe 'java::oracle', :type => :define do
context 'On CentOS 64-bit' do context 'On CentOS 64-bit' do
let(:facts) { {:kernel => 'Linux', :architecture => 'x86_64', :osfamily => 'RedHat', :operatingsystem => 'CentOS', :operatingsystemrelease => '6.6', :puppetversion => '3.4.3 (Puppet Enterprise 3.2.3)'} } let(:facts) { { :kernel => 'Linux', :os => {:family => 'RedHat', :architecture => 'x86_64', :name => 'CentOS', :release => {:full => '6.0'}}}}
context 'Oracle Java SE 6 JDK' do context 'Oracle Java SE 6 JDK' do
let(:params) { {:ensure => 'present', :version => '6', :java_se => 'jdk'} } let(:params) { {:ensure => 'present', :version => '6', :java_se => 'jdk'} }
@@ -55,7 +55,7 @@ describe 'java::oracle', :type => :define do
end end
context 'On CentOS 32-bit' do context 'On CentOS 32-bit' do
let(:facts) { {:kernel => 'Linux', :architecture => 'i386', :osfamily => 'RedHat', :operatingsystem => 'CentOS', :operatingsystemrelease => '6.6', :puppetversion => '3.4.3 (Puppet Enterprise 3.2.3)'} } let(:facts) { {:kernel => 'Linux', :os => { :family => 'RedHat', :architecture => 'i386', :name => 'CentOS', :release => { :full => '6.6' } } } }
context 'select Oracle Java SE 6 JDK on RedHat family, 32-bit' do context 'select Oracle Java SE 6 JDK on RedHat family, 32-bit' do
let(:params) { {:ensure => 'present', :version => '6', :java_se => 'jdk'} } let(:params) { {:ensure => 'present', :version => '6', :java_se => 'jdk'} }
@@ -106,52 +106,67 @@ describe 'java::oracle', :type => :define do
end end
end end
describe 'incompatible OSs' do describe 'incompatible OSes' do
[ [
{ {
# C14706 # C14706
:kernel => 'windows', :kernel => 'Windows',
:osfamily => 'windows', :os => {
:operatingsystem => 'windows', :family => 'Windows',
:operatingsystemrelease => '8.1', :name => 'Windows',
:puppetversion => '3.4.3 (Puppet Enterprise 3.2.3)', :release => {
:full => '8.1'
}
},
}, },
{ {
# C14707 # C14707
:kernel => 'Darwin', :kernel => 'Darwin',
:osfamily => 'Darwin', :os => {
:operatingsystem => 'Darwin', :family => 'Darwin',
:operatingsystemrelease => '13.3.0', :name => 'Darwin',
:puppetversion => '3.4.3 (Puppet Enterprise 3.2.3)', :release => {
:full => '13.3.0'
}
},
}, },
{ {
# C14708 # C14708
:kernel => 'AIX', :kernel => 'AIX',
:osfamily => 'AIX', :os => {
:operatingsystem => 'AIX', :family => 'AIX',
:operatingsystemrelease => '7100-02-00-000', :name => 'AIX',
:puppetversion => '3.4.3 (Puppet Enterprise 3.2.3)', :release => {
:full => '7100-02-00-000'
}
},
}, },
{ {
# C14708 # C14709
:kernel => 'AIX', :kernel => 'AIX',
:osfamily => 'AIX', :os => {
:operatingsystem => 'AIX', :family => 'AIX',
:operatingsystemrelease => '6100-07-04-1216', :name => 'AIX',
:puppetversion => '3.4.3 (Puppet Enterprise 3.2.3)', :release => {
:full => '6100-07-04-1216'
}
},
}, },
{ {
# C14708 # C14710
:kernel => 'AIX', :kernel => 'AIX',
:osfamily => 'AIX', :os => {
:operatingsystem => 'AIX', :family => 'AIX',
:operatingsystemrelease => '5300-12-01-1016', :name => 'AIX',
:puppetversion => '3.4.3 (Puppet Enterprise 3.2.3)', :release => {
}, :full => '5300-12-01-1016'
}
},
}
].each do |facts| ].each do |facts|
let(:facts) { facts } let(:facts) { facts }
let :title do 'jdk' end let :title do 'jdk' end
it "is_expected.to fail on #{facts[:operatingsystem]} #{facts[:operatingsystemrelease]}" do it "is_expected.to fail on #{facts[:os][:name]} #{facts[:os][:release][:full]}" do
expect { catalogue }.to raise_error Puppet::Error, /unsupported platform/ expect { catalogue }.to raise_error Puppet::Error, /unsupported platform/
end end
end end