Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/Issue136_dsc22_installs_cassandr…
Browse files Browse the repository at this point in the history
…a3' into v1.9.2
  • Loading branch information
dallinb committed Nov 21, 2015
2 parents 941e5ed + d2e77ee commit bf6f790
Show file tree
Hide file tree
Showing 6 changed files with 118 additions and 53 deletions.
46 changes: 39 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ A Puppet module to install and manage Cassandra, DataStax Agent & OpsCenter

#### What the Cassandra class affects

* Installs the Cassandra package (default **dsc22**).
* Installs the Cassandra package (default **cassandra22** on Red Hat and
**cassandra** on Debian).
* Configures settings in *${config_path}/cassandra.yaml*.
* Optionally ensures that the Cassandra service is enabled and running.
* On Ubuntu systems, optionally replace ```/etc/init.d/cassandra``` with a
Expand Down Expand Up @@ -115,6 +116,27 @@ A basic example is as follows:

### Upgrading

#### Changes in 1.9.2

Now that Cassandra 3 is available from the DataStax repositories, there is
a problem (especially on Debian) with the operating system package manager
attempting to install Cassandra 3. This can be mitigated against using
something similar to the code in this modules acceptance test. Please note
that the default Cassandra package name has now been changed from 'dsc'. See
the documentation for cassandra::package_name below for details.

```puppet
if $::osfamily == 'RedHat' {
$version = '2.2.3-1'
} else {
$version = '2.2.3'
}
class { 'cassandra':
package_ensure => $version,
}
```

#### Changes in 1.8.0

A somewhat embarrassing correction to the spelling of the
Expand Down Expand Up @@ -905,8 +927,11 @@ The status of the package specified in **package_name**. Can be
Default value 'present'

##### `package_name`
The name of the Cassandra package. Must be available from a repository.
Default value 'dsc22'
The name of the Cassandra package which must be available from a repository.
If this is *undef*, it will be changed to **cassandra22** on the Red Hat family
of operating systems or **cassandra** on Debian. Otherwise the user can
specify the package name.
Default value *undef*

##### `partitioner`
This is passed to the
Expand Down Expand Up @@ -1405,15 +1430,15 @@ Default value 'present'

##### `jna_package_name`
If the default value of *undef* is left as it is, then a package called
jna or libjna-java will be installed on a Red Hat family or Ubuntu system
jna or libjna-java will be installed on a Red Hat family or Debian system
respectively. Alternatively, one can specify a package that is available in
a package repository to the node.
Default value *undef*

##### `package_name`
If the default value of *undef* is left as it is, then a package called
java-1.8.0-openjdk-headless or openjdk-7-jre-headless will be installed
on a Red Hat family or Ubuntu system respectively. Alternatively, one
on a Red Hat family or Debian system respectively. Alternatively, one
can specify a package that is available in a package repository to the
node.
Default value *undef*
Expand Down Expand Up @@ -2376,7 +2401,7 @@ Default value 'present'
##### `package_name`
If the default value of *undef* is left as it is, then a package called
cassandra22-tools or cassandra-tools will be installed
on a Red Hat family or Ubuntu system respectively. Alternatively, one
on a Red Hat family or Debian system respectively. Alternatively, one
can specify a package that is available in a package repository to the
node.
Default value *undef*
Expand Down Expand Up @@ -2559,7 +2584,8 @@ The setting value to be changed to (e.g. **8888**).
## Limitations

Tested on the Red Hat family versions 6 and 7, Ubuntu 12.04 and 14.04,
Debian 7 Puppet (CE) 3.7.5 and DSC 2.
Debian 7 Puppet (CE) 3.7.5 and DSC 2. Currently this module does not support
Cassandra 3 but this is planned for the near future.

From release 1.6.0 of this module, regular updates of the Cassandra 1.X
template will cease and testing against this template will cease. Testing
Expand Down Expand Up @@ -2602,3 +2628,9 @@ to set the batch_size_warn_threshold_in_kb parameter (see
* [@markasammut](https://github.com/markasammut) also contributed a pull
request to restart the service if the datastax-agent package is upgraded
(see [#110](https://github.com/locp/cassandra/pull/110)).

* Issues with the newly released Cassandra 3 were reported by
[@mantunovic](https://github.com/mantunovic) in
[#136](https://github.com/locp/cassandra/issues/136) with some excellent
help and advice from [@al4](https://github.com/al4). Thanks to both
Mladen and Alex for your feedback and constructive collaboration.
39 changes: 26 additions & 13 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
$native_transport_port = 9042,
$num_tokens = 256,
$package_ensure = 'present',
$package_name = 'dsc22',
$package_name = undef,
$partitioner
= 'org.apache.cassandra.dht.Murmur3Partitioner',
$permissions_update_interval_in_ms = undef,
Expand Down Expand Up @@ -178,6 +178,12 @@
} else {
$cfg_path = $config_path
}

if $package_name == undef {
$cassandra_pkg = 'cassandra22'
} else {
$cassandra_pkg = $package_name
}
}
'Debian': {
if $config_path == undef {
Expand All @@ -186,6 +192,12 @@
$cfg_path = $config_path
}

if $package_name == undef {
$cassandra_pkg = 'cassandra'
} else {
$cassandra_pkg = $package_name
}

# A workaround for CASSANDRA-9822
if $cassandra_9822 == true {
file { '/etc/init.d/cassandra':
Expand All @@ -197,13 +209,14 @@
if $supported_os_only {
fail("OS family ${::osfamily} not supported")
} else {
$cassandra_pkg = $package_name
$cfg_path = $config_path
warning("OS family ${::osfamily} not supported")
}
}
}

package { $package_name:
package { $cassandra_pkg:
ensure => $package_ensure,
}

Expand All @@ -215,31 +228,31 @@
group => 'cassandra',
content => template($cassandra_yaml_tmpl),
mode => $config_file_mode,
require => Package[$package_name],
require => Package[$cassandra_pkg],
}

file { $commitlog_directory:
ensure => directory,
owner => 'cassandra',
group => 'cassandra',
mode => $commitlog_directory_mode,
require => Package[$package_name]
require => Package[$cassandra_pkg]
}

file { $data_file_directories:
ensure => directory,
owner => 'cassandra',
group => 'cassandra',
mode => $data_file_directories_mode,
require => Package[$package_name]
require => Package[$cassandra_pkg]
}

file { $saved_caches_directory:
ensure => directory,
owner => 'cassandra',
group => 'cassandra',
mode => $saved_caches_directory_mode,
require => Package[$package_name]
require => Package[$cassandra_pkg]
}

if $package_ensure != 'absent'
Expand All @@ -256,7 +269,7 @@
File[$saved_caches_directory],
Ini_setting['rackdc.properties.dc'],
Ini_setting['rackdc.properties.rack'],
Package[$package_name],
Package[$cassandra_pkg],
]
}
} else {
Expand All @@ -275,15 +288,15 @@
section => '',
setting => 'dc',
value => $dc,
require => Package[$package_name],
require => Package[$cassandra_pkg],
}

ini_setting { 'rackdc.properties.rack':
path => $dc_rack_properties_file,
section => '',
setting => 'rack',
value => $rack,
require => Package[$package_name],
require => Package[$cassandra_pkg],
}

if $dc_suffix != undef {
Expand All @@ -293,7 +306,7 @@
section => '',
setting => 'dc_suffix',
value => $dc_suffix,
require => Package[$package_name],
require => Package[$cassandra_pkg],
notify => Service['cassandra']
}
} else {
Expand All @@ -302,7 +315,7 @@
section => '',
setting => 'dc_suffix',
value => $dc_suffix,
require => Package[$package_name],
require => Package[$cassandra_pkg],
}
}
}
Expand All @@ -314,7 +327,7 @@
section => '',
setting => 'prefer_local',
value => $prefer_local,
require => Package[$package_name],
require => Package[$cassandra_pkg],
notify => Service['cassandra']
}
} else {
Expand All @@ -323,7 +336,7 @@
section => '',
setting => 'prefer_local',
value => $prefer_local,
require => Package[$package_name],
require => Package[$cassandra_pkg],
}
}
}
Expand Down
72 changes: 45 additions & 27 deletions spec/acceptance/cassandra_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,14 @@
end

cassandra_install_pp = <<-EOS
if $::osfamily == 'RedHat' {
$version = '2.2.3-1'
} else {
$version = '2.2.3'
}
class { 'cassandra':
package_ensure => $version,
cassandra_9822 => true,
commitlog_directory_mode => '0770',
data_file_directories_mode => '0770',
Expand All @@ -36,13 +43,22 @@ class { 'cassandra':
end

optutils_install_pp = <<-EOS
if $::osfamily == 'RedHat' {
$version = '2.2.3-1'
} else {
$version = '2.2.3'
}
class { 'cassandra':
cassandra_9822 => true,
commitlog_directory_mode => '0770',
data_file_directories_mode => '0770',
saved_caches_directory_mode => '0770'
}
include '::cassandra::optutils'
class { 'cassandra::optutils':
ensure => $version,
}
EOS

describe 'Cassandra optional utilities installation.' do
Expand Down Expand Up @@ -138,30 +154,32 @@ class { 'cassandra':
it { is_expected.to be_enabled }
end

check_against_previous_version_pp = <<-EOS
include cassandra
EOS

describe 'Ensure config file does get updated unnecessarily.' do
it 'Initial install manifest again' do
apply_manifest(check_against_previous_version_pp,
:catch_failures => true)
end
it 'Copy the current module to the side without error.' do
shell("cp -R /etc/puppet/modules/cassandra /var/tmp",
:acceptable_exit_codes => 0)
end
it 'Remove the current module without error.' do
shell("puppet module uninstall locp-cassandra",
:acceptable_exit_codes => 0)
end
it 'Install the latest module from the forge.' do
shell("puppet module install locp-cassandra",
:acceptable_exit_codes => 0)
end
it 'Check install works with changes with previous module version.' do
expect(apply_manifest(check_against_previous_version_pp,
:catch_failures => true).exit_code).to_not be_zero
end
end
# Release 1.9.2 will be making changes so these checks are currently redundant.
#
# check_against_previous_version_pp = <<-EOS
# include cassandra
# EOS
#
# describe 'Ensure config file does get updated unnecessarily.' do
# it 'Initial install manifest again' do
# apply_manifest(check_against_previous_version_pp,
# :catch_failures => true)
# end
# it 'Copy the current module to the side without error.' do
# shell("cp -R /etc/puppet/modules/cassandra /var/tmp",
# :acceptable_exit_codes => 0)
# end
# it 'Remove the current module without error.' do
# shell("puppet module uninstall locp-cassandra",
# :acceptable_exit_codes => 0)
# end
# it 'Install the latest module from the forge.' do
# shell("puppet module install locp-cassandra",
# :acceptable_exit_codes => 0)
# end
# it 'Check install works without changes with previous module version.' do
# expect(apply_manifest(check_against_previous_version_pp,
# :catch_failures => true).exit_code).to be_zero
# end
# end
end
2 changes: 1 addition & 1 deletion spec/classes/cassandra_debian_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
})
}
it { should contain_file('/etc/cassandra/cassandra.yaml') }
it { should contain_package('dsc22') }
it { should contain_package('cassandra') }
it { is_expected.to contain_service('cassandra') }
it { is_expected.not_to contain_class('apt') }
it { is_expected.not_to contain_class('apt::update') }
Expand Down
2 changes: 1 addition & 1 deletion spec/classes/cassandra_redhat_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
'enable' => 'true'
})
}
it { should contain_package('dsc22') }
it { should contain_package('cassandra22') }
it { is_expected.not_to contain_yumrepo('datastax') }
it {
should contain_ini_setting('rackdc.properties.dc').with({
Expand Down
Loading

0 comments on commit bf6f790

Please sign in to comment.