diff --git a/manifests/oracle.pp b/manifests/oracle.pp index e3aa912..460e1ab 100644 --- a/manifests/oracle.pp +++ b/manifests/oracle.pp @@ -166,6 +166,11 @@ define java::oracle ( } else { $package_type = 'rpm' } + $creates_path = "/usr/java/${install_path}" + } + 'Debian' : { + $package_type = 'tar.gz' + $creates_path = "/usr/lib/jvm/${install_path}" } default : { fail ("unsupported platform ${$facts['os']['name']}") } @@ -173,7 +178,6 @@ define java::oracle ( $os = 'linux' $destination_dir = '/tmp/' - $creates_path = "/usr/java/${install_path}" } default : { fail ( "unsupported platform ${$facts['kernel']}" ) } @@ -183,6 +187,7 @@ define java::oracle ( case $facts['os']['architecture'] { 'i386' : { $arch = 'i586' } 'x86_64' : { $arch = 'x64' } + 'amd64' : { $arch = 'x64' } default : { fail ("unsupported platform ${$facts['os']['architecture']}") } @@ -205,6 +210,9 @@ define java::oracle ( 'rpm' : { $package_name = "${java_se}-${release_major}-${os}-${arch}.rpm" } + 'tar.gz' : { + $package_name = "${java_se}-${release_major}-${os}-${arch}.tar.gz" + } default : { $package_name = "${java_se}-${release_major}-${os}-${arch}.rpm" } @@ -235,6 +243,9 @@ define java::oracle ( 'rpm' : { $install_command = "rpm --force -iv ${destination}" } + 'tar.gz' : { + $install_command = "tar -zxf ${destination} -C /usr/lib/jvm" + } default : { $install_command = "rpm -iv ${destination}" } @@ -260,6 +271,15 @@ define java::oracle ( creates => $creates_path, require => Archive[$destination] } + case $facts['os']['family'] { + 'Debian' : { + file{'/usr/lib/jvm': + ensure => directory, + before => Exec["Install Oracle java_se ${java_se} ${version}"] + } + } + default : { } + } } default : { fail ("unsupported platform ${$facts['kernel']}") diff --git a/spec/defines/oracle_spec.rb b/spec/defines/oracle_spec.rb index 9e05ee7..d7cd817 100644 --- a/spec/defines/oracle_spec.rb +++ b/spec/defines/oracle_spec.rb @@ -130,6 +130,63 @@ describe 'java::oracle', :type => :define do end end + context 'On Ubuntu 64-bit' do + let(:facts) { {:kernel => 'Linux', :os => { :family => 'Debian', :architecture => 'amd64', :name => 'Ubuntu', :release => { :full => '16.04' } } } } + + context 'Oracle Java SE 6 JDK' do + let(:params) { {:ensure => 'present', :version => '6', :java_se => 'jdk'} } + let :title do 'jdk6' end + it { is_expected.to contain_archive('/tmp/jdk-6u45-linux-x64.tar.gz')} + it { is_expected.to contain_exec('Install Oracle java_se jdk 6').with_command('tar -zxf /tmp/jdk-6u45-linux-x64.tar.gz -C /usr/lib/jvm') } + it { is_expected.to contain_exec('Install Oracle java_se jdk 6').that_requires('Archive[/tmp/jdk-6u45-linux-x64.tar.gz]') } + end + + context 'Oracle Java SE 7 JDK' do + let(:params) { {:ensure => 'present', :version => '7', :java_se => 'jdk'} } + let :title do 'jdk7' end + it { is_expected.to contain_archive('/tmp/jdk-7u80-linux-x64.tar.gz')} + it { is_expected.to contain_exec('Install Oracle java_se jdk 7').with_command('tar -zxf /tmp/jdk-7u80-linux-x64.tar.gz -C /usr/lib/jvm') } + it { is_expected.to contain_exec('Install Oracle java_se jdk 7').that_requires('Archive[/tmp/jdk-7u80-linux-x64.tar.gz]') } + end + + context 'Oracle Java SE 8 JDK' do + let(:params) { {:ensure => 'present', :version => '8', :java_se => 'jdk'} } + let :title do 'jdk8' end + it { is_expected.to contain_archive('/tmp/jdk-8u131-linux-x64.tar.gz')} + it { is_expected.to contain_exec('Install Oracle java_se jdk 8').with_command('tar -zxf /tmp/jdk-8u131-linux-x64.tar.gz -C /usr/lib/jvm') } + it { is_expected.to contain_exec('Install Oracle java_se jdk 8').that_requires('Archive[/tmp/jdk-8u131-linux-x64.tar.gz]') } + end + + context 'Oracle Java SE 6 JRE' do + let(:params) { {:ensure => 'present', :version => '6', :java_se => 'jre'} } + let :title do 'jre6' end + it { is_expected.to contain_archive('/tmp/jre-6u45-linux-x64.tar.gz')} + it { is_expected.to contain_exec('Install Oracle java_se jre 6').with_command('tar -zxf /tmp/jre-6u45-linux-x64.tar.gz -C /usr/lib/jvm') } + it { is_expected.to contain_exec('Install Oracle java_se jre 6').that_requires('Archive[/tmp/jre-6u45-linux-x64.tar.gz]') } + end + + context 'Oracle Java SE 7 JRE' do + let(:params) { {:ensure => 'present', :version => '7', :java_se => 'jre'} } + let :title do 'jre7' end + it { is_expected.to contain_archive('/tmp/jre-7u80-linux-x64.tar.gz')} + it { is_expected.to contain_exec('Install Oracle java_se jre 7').with_command('tar -zxf /tmp/jre-7u80-linux-x64.tar.gz -C /usr/lib/jvm') } + it { is_expected.to contain_exec('Install Oracle java_se jre 7').that_requires('Archive[/tmp/jre-7u80-linux-x64.tar.gz]') } + end + + context 'select Oracle Java SE 8 JRE' do + let(:params) { {:ensure => 'present', :version => '8', :java_se => 'jre'} } + let :title do 'jre8' end + it { is_expected.to contain_archive('/tmp/jre-8u131-linux-x64.tar.gz')} + it { is_expected.to contain_exec('Install Oracle java_se jre 8').with_command('tar -zxf /tmp/jre-8u131-linux-x64.tar.gz -C /usr/lib/jvm') } + it { is_expected.to contain_exec('Install Oracle java_se jre 8').that_requires('Archive[/tmp/jre-8u131-linux-x64.tar.gz]') } + end + + context 'Pass URL to url parameter' do + let(:params) { {:ensure => 'present', :version_major => '8u131', :version_minor => 'b11', :java_se => 'jdk', :url => 'http://download.oracle.com/otn-pub/java/jdk/8u131-b11/d54c1d3a095b4ff2b6607d096fa80163/jdk-8u131-linux-x64.tar.gz'} } + let :title do 'jdk8' end + it { is_expected.to contain_archive('/tmp/jdk-8u131-linux-x64.tar.gz')} + end + end describe 'incompatible OSes' do [ {