diff --git a/.fixtures.yml b/.fixtures.yml index 0025d9a..f712123 100644 --- a/.fixtures.yml +++ b/.fixtures.yml @@ -1,12 +1,13 @@ fixtures: repositories: apt: "git://github.com/puppetlabs/puppetlabs-apt" + translate: "git://github.com/puppetlabs/puppetlabs-translate" firewall: "git://github.com/puppetlabs/puppetlabs-firewall" inifile: "git://github.com/puppetlabs/puppetlabs-inifile" stdlib: "git://github.com/puppetlabs/puppetlabs-stdlib" yumrepo_core: repo: https://github.com/puppetlabs/puppetlabs-yumrepo_core.git puppet_version: ">= 6.0.0" mount_core: repo: https://github.com/puppetlabs/puppetlabs-mount_core.git puppet_version: ">= 6.0.0" diff --git a/manifests/java.pp b/manifests/java.pp index 92ec02c..99c9a66 100644 --- a/manifests/java.pp +++ b/manifests/java.pp @@ -1,66 +1,67 @@ # A class to install Java and JNA packages. # @param aptkey [hash] If supplied, this should be a hash of `apt::key` # resources that will be passed to the create_resources function. # This is ignored on non-Debian systems. # @param aptsource [hash] If supplied, this should be a hash of # `apt::source` resources that will be passed to the create_resources # function. This is ignored on non-Red Hat` # @param jna_ensure [string] Is passed to the package reference for the JNA # package. Valid values are `present` or a version number. # @param jna_package_name [string] The name of the JNA package. # @param package_ensure [string] Is passed to the package reference for the JRE/JDK # package. Valid values are `present` or a version number. # @param package_name [string] The name of the Java package to be installed. # @param yumrepo [hash] If supplied, this should be a hash of *yumrepo* # resources that will be passed to the create_resources function. # This is ignored on non-Red Hat systems. class cassandra::java ( $aptkey = undef, $aptsource = undef, $jna_ensure = present, $jna_package_name = $::cassandra::params::jna_package_name, $package_ensure = present, $package_name = $::cassandra::params::java_package, $yumrepo = undef, ) inherits cassandra::params { if $::osfamily == 'RedHat' and $yumrepo != undef { $yumrepo_defaults = { 'before' => Package[$package_name], } create_resources(yumrepo, $yumrepo, $yumrepo_defaults) } if $::osfamily == 'Debian' { if $aptkey != undef { $aptkey_defaults = { 'before' => Package[$package_name], } + include apt create_resources(apt::key, $aptkey, $aptkey_defaults) } if $aptsource != undef { exec { 'cassandra::java::apt_update': refreshonly => true, command => '/bin/true', require => Exec['apt_update'], before => Package[$package_name], } $aptsource_defaults = { 'notify' => Exec['cassandra::java::apt_update'], } create_resources(apt::source, $aptsource, $aptsource_defaults) } } package { $package_name: ensure => $package_ensure, } package { $jna_package_name: ensure => $jna_ensure, } } diff --git a/spec/classes/apache_repo_spec.rb b/spec/classes/apache_repo_spec.rb index cdf85da..c2e3f62 100644 --- a/spec/classes/apache_repo_spec.rb +++ b/spec/classes/apache_repo_spec.rb @@ -1,73 +1,72 @@ require 'spec_helper' describe 'cassandra::apache_repo' do context 'On a RedHat OS with defaults for all parameters' do let :facts do { osfamily: 'RedHat' } end let :params do { release: '311x' } end it do is_expected.to have_resource_count(1) is_expected.to contain_class('cassandra::apache_repo').only_with( 'descr' => 'Repo for Apache Cassandra', 'key_id' => 'A26E528B271F19B9E5D8E19EA278B781FE4B2BDA', 'key_url' => 'https://www.apache.org/dist/cassandra/KEYS', 'release' => '311x' ) is_expected.to contain_yumrepo('cassandra_apache').with( ensure: 'present', descr: 'Repo for Apache Cassandra', baseurl: 'http://www.apache.org/dist/cassandra/redhat/311x', enabled: 1, gpgcheck: 1, gpgkey: 'https://www.apache.org/dist/cassandra/KEYS' ) end end context 'On a Debian OS with defaults for all parameters' do let :facts do { osfamily: 'Debian', lsbdistid: 'Debian', lsbdistrelease: '9', os: { name: 'Debian', release: { major: '9' } } } end it do - is_expected.to have_resource_count(16) is_expected.to contain_class('apt') is_expected.to contain_class('apt::update') is_expected.to contain_apt__key('apache.cassandra').with( id: 'A26E528B271F19B9E5D8E19EA278B781FE4B2BDA', source: 'https://www.apache.org/dist/cassandra/KEYS' ) is_expected.to contain_apt__source('cassandra.sources').with( location: 'http://www.apache.org/dist/cassandra/debian', comment: 'Repo for Apache Cassandra', release: 'main', include: { 'src' => false } ).that_notifies('Exec[update-apache-cassandra-repo]') is_expected.to contain_exec('update-apache-cassandra-repo').with( refreshonly: true, command: '/bin/true' ) end end end diff --git a/spec/classes/datastax_repo_spec.rb b/spec/classes/datastax_repo_spec.rb index 1ddbc20..95764e7 100644 --- a/spec/classes/datastax_repo_spec.rb +++ b/spec/classes/datastax_repo_spec.rb @@ -1,66 +1,65 @@ require 'spec_helper' describe 'cassandra::datastax_repo' do context 'On a RedHat OS with defaults for all parameters' do let :facts do { osfamily: 'RedHat' } end it do is_expected.to have_resource_count(1) is_expected.to contain_class('cassandra::datastax_repo').only_with( 'descr' => 'DataStax Repo for Apache Cassandra', 'key_id' => '7E41C00F85BFC1706C4FFFB3350200F2B999A372', 'key_url' => 'http://debian.datastax.com/debian/repo_key', 'release' => 'stable' ) is_expected.to contain_yumrepo('datastax').with( ensure: 'present', descr: 'DataStax Repo for Apache Cassandra', baseurl: 'http://rpm.datastax.com/community', enabled: 1, gpgcheck: 0 ) end end context 'On a Debian OS with defaults for all parameters' do let :facts do { osfamily: 'Debian', lsbdistid: 'Debian', lsbdistrelease: '9', os: { name: 'Debian', release: { major: '9' } } } end it do - is_expected.to have_resource_count(16) is_expected.to contain_class('apt') is_expected.to contain_class('apt::update') is_expected.to contain_apt__key('datastaxkey').with( id: '7E41C00F85BFC1706C4FFFB3350200F2B999A372', source: 'http://debian.datastax.com/debian/repo_key' ) is_expected.to contain_apt__source('datastax').with( location: 'http://debian.datastax.com/community', comment: 'DataStax Repo for Apache Cassandra', release: 'stable', include: { 'src' => false } ).that_notifies('Exec[update-cassandra-repos]') is_expected.to contain_exec('update-cassandra-repos').with( refreshonly: true, command: '/bin/true' ) end end end