Documentation by YARD 0.9.10
+Alphabetic Index
+ +Puppet Class Listing A-Z
+ + +
+
+
+
|
+
Defined Type Listing A-Z
+ + +
+
+
+
|
+
File Listing
+-
+
+
+
- README + + +
diff --git a/docs/_index.html b/docs/_index.html new file mode 100644 index 0000000..dc32417 --- /dev/null +++ b/docs/_index.html @@ -0,0 +1,229 @@ + + +
+ + +
+
+
+
|
+
+
+
+
|
+
Node Name | +IP Address | +
---|---|
node0 (seed 1) | +110.82.155.0 | +
node1 | +110.82.155.1 | +
node2 | +110.82.155.2 | +
node3 (seed 2) | +110.82.156.3 | +
node4 | +110.82.156.4 | +
node5 | +110.82.156.5 | +
Each node is configured to use the GossipingPropertyFileSnitch and 256 virtual +nodes (vnodes). The name of the cluster is MyCassandraCluster. Also, +while building the initial cluster, we are setting the auto_bootstrap +to false.
+ +In this initial example, we are going to expand the example by:
+ +cassandra::datastax_repo
. This needs to be
+executed before the Cassandra package is installed.cassandra::java
. This need to be executed
+before the Cassandra service is started.node /^node\d+$/ {
+ class { 'cassandra::datastax_repo':
+ before => Class['cassandra']
+ }
+
+ class { 'cassandra::java':
+ before => Class['cassandra']
+ }
+
+ class { 'cassandra':
+ settings => {
+ 'authenticator' => 'AllowAllAuthenticator',
+ 'auto_bootstrap' => false,
+ 'cluster_name' => 'MyCassandraCluster',
+ 'commitlog_directory' => '/var/lib/cassandra/commitlog',
+ 'commitlog_sync' => 'periodic',
+ 'commitlog_sync_period_in_ms' => 10000,
+ 'data_file_directories' => ['/var/lib/cassandra/data'],
+ 'endpoint_snitch' => 'GossipingPropertyFileSnitch',
+ 'hints_directory' => '/var/lib/cassandra/hints',
+ 'listen_interface' => 'eth1',
+ 'num_tokens' => 256,
+ 'partitioner' => 'org.apache.cassandra.dht.Murmur3Partitioner',
+ 'saved_caches_directory' => '/var/lib/cassandra/saved_caches',
+ 'seed_provider' => [
+ {
+ 'class_name' => 'org.apache.cassandra.locator.SimpleSeedProvider',
+ 'parameters' => [
+ {
+ 'seeds' => '110.82.155.0,110.82.156.3',
+ },
+ ],
+ },
+ ],
+ 'start_native_transport' => true,
+ },
+ }
+}
+
+
+The default value for the num_tokens is already 256, but it is +included in the example for clarity. Do not forget to either +set auto_bootstrap to true or not set the attribute at all +after initializing the cluster.
+ +To continue with the examples provided by DataStax, we look at the example +for a cluster across multiple data centers +http://docs.datastax.com/en/cassandra/2.2/cassandra/initialize/initMultipleDS.html.
+ +Node Name | +IP Address | +Data Center | +Rack | +
---|---|---|---|
node0 (seed 1) | +10.168.66.41 | +DC1 | +RAC1 | +
node1 | +10.176.43.66 | +DC1 | +RAC1 | +
node2 | +10.168.247.41 | +DC1 | +RAC1 | +
node3 (seed 2) | +10.176.170.59 | +DC2 | +RAC1 | +
node4 | +10.169.61.170 | +DC2 | +RAC1 | +
node5 | +10.169.30.138 | +DC2 | +RAC1 | +
For the sake of simplicity, we will confine this example to the nodes:
+ +node /^node[012]$/ {
+ class { 'cassandra':
+ dc => 'DC1',
+ settings => {
+ 'authenticator' => 'AllowAllAuthenticator',
+ 'auto_bootstrap' => false,
+ 'cluster_name' => 'MyCassandraCluster',
+ 'commitlog_directory' => '/var/lib/cassandra/commitlog',
+ 'commitlog_sync' => 'periodic',
+ 'commitlog_sync_period_in_ms' => 10000,
+ 'data_file_directories' => ['/var/lib/cassandra/data'],
+ 'endpoint_snitch' => 'GossipingPropertyFileSnitch',
+ 'hints_directory' => '/var/lib/cassandra/hints',
+ 'listen_interface' => 'eth1',
+ 'num_tokens' => 256,
+ 'partitioner' => 'org.apache.cassandra.dht.Murmur3Partitioner',
+ 'saved_caches_directory' => '/var/lib/cassandra/saved_caches',
+ 'seed_provider' => [
+ {
+ 'class_name' => 'org.apache.cassandra.locator.SimpleSeedProvider',
+ 'parameters' => [
+ {
+ 'seeds' => '110.82.155.0,110.82.156.3',
+ },
+ ],
+ },
+ ],
+ 'start_native_transport' => true,
+ },
+ }
+}
+
+node /^node[345]$/ {
+ class { 'cassandra':
+ dc => 'DC2',
+ settings => {
+ 'authenticator' => 'AllowAllAuthenticator',
+ 'auto_bootstrap' => false,
+ 'cluster_name' => 'MyCassandraCluster',
+ 'commitlog_directory' => '/var/lib/cassandra/commitlog',
+ 'commitlog_sync' => 'periodic',
+ 'commitlog_sync_period_in_ms' => 10000,
+ 'data_file_directories' => ['/var/lib/cassandra/data'],
+ 'endpoint_snitch' => 'GossipingPropertyFileSnitch',
+ 'hints_directory' => '/var/lib/cassandra/hints',
+ 'listen_interface' => 'eth1',
+ 'num_tokens' => 256,
+ 'partitioner' => 'org.apache.cassandra.dht.Murmur3Partitioner',
+ 'saved_caches_directory' => '/var/lib/cassandra/saved_caches',
+ 'seed_provider' => [
+ {
+ 'class_name' => 'org.apache.cassandra.locator.SimpleSeedProvider',
+ 'parameters' => [
+ {
+ 'seeds' => '110.82.155.0,110.82.156.3',
+ },
+ ],
+ },
+ ],
+ 'start_native_transport' => true,
+ },
+ }
+}
+
+
+We don't need to specify the rack name (with the rack attribute) as RAC1 is +the default value. Again, do not forget to either set auto_bootstrap to +true or not set the attribute at all after initializing the cluster.
+ +After configuring the relevant repository, the following snippet works on +CentOS 7 to install DSE Cassandra 4.7.0, set the HADOOP_LOG_DIR, set the +DSE_HOME and configure DataStax Enterprise to use LDAP for authentication:
+ +class { 'cassandra::datastax_repo':
+ descr => 'DataStax Repo for DataStax Enterprise',
+ pkg_url => 'https://username:password@rpm.datastax.com/enterprise',
+ before => Class['cassandra'],
+}
+
+class { 'cassandra':
+ cluster_name => 'MyCassandraCluster',
+ config_path => '/etc/dse/cassandra',
+ package_ensure => '4.7.0-1',
+ package_name => 'dse-full',
+ service_name => 'dse',
+ ...
+}
+
+class { 'cassandra::dse':
+ file_lines => {
+ 'Set HADOOP_LOG_DIR directory' => {
+ ensure => present,
+ path => '/etc/dse/dse-env.sh',
+ line => 'export HADOOP_LOG_DIR=/var/log/hadoop',
+ match => '^# export HADOOP_LOG_DIR=<log_dir>',
+ },
+ 'Set DSE_HOME' => {
+ ensure => present,
+ path => '/etc/dse/dse-env.sh',
+ line => 'export DSE_HOME=/usr/share/dse',
+ match => '^#export DSE_HOME',
+ },
+ },
+ settings => {
+ ldap_options => {
+ server_host => localhost,
+ server_port => 389,
+ search_dn => 'cn=Admin',
+ search_password => secret,
+ use_ssl => false,
+ use_tls => false,
+ truststore_type => jks,
+ user_search_base => 'ou=users,dc=example,dc=com',
+ user_search_filter => '(uid={0})',
+ credentials_validity_in_ms => 0,
+ connection_pool => {
+ max_active => 8,
+ max_idle => 8,
+ }
+ }
+ }
+}
+
+
+DataStax announced in late October 2016 that it was no longer supporting
+the community edition of Cassandra or DSC as it was known (see
+[Take a bow Planet
+Cassandra](http://www.datastax.com/2016/10/take-a-bow-planet-cassandra)
+for details). However, the following snippet of code running on Ubuntu
+14.04 worked fine without having to change any of the ::cassandra
class
+settings:
require cassandra::java
+include cassandra::optutils
+
+class { 'cassandra::apache_repo':
+ release => '310x',
+ before => Class['cassandra', 'cassandra::optutils'],
+}
+
+class { 'cassandra':
+ ...
+}
+
+
+The reference documentation is generated using the +puppet-strings tool. To see +all of it, please go to +http://voxpupuli.github.io/puppet-cassandra.
+ +cassandra::system::transparent_hugepage
does not
+persist between reboots.Contributions will be gratefully accepted. Please go to the project page, +fork the project, make your changes locally and then raise a pull request. +Details on how to do this are available at +https://guides.github.com/activities/contributing-to-open-source.
+ +Please also see the +CONTRIBUTING.md +page for project specific requirements.
+ +For a list of contributers see +CONTRIBUTING.md +and https://github.com/voxpupuli/puppet-cassandra/graphs/contributors
+A Puppet module to install and manage Cassandra, DataStax Agent & OpsCenter
+ +${config_path}/cassandra.yaml
.init
service provider is used, then cassandra
+is added as a system service./etc/init.d/cassandra
with a workaround for
+CASSANDRA-9822./etc/dse
directory if one is using
+DataStax Enterprise.We follow SemVer Versioning and an update of the major +release (i.e. from 1.Y.Z to 2.Y.Z) will indicate a significant change +to the API which will most probably require a change to your manifest.
+ +This is a major change to the API and you will more than likely need to +change your manifest to accomodate these changes.
+ +The service_ensure
attribute of the cassandra class now defaults to
+undef, users who do want to manage service status in Puppet can still set
+it to true. If leaving the value at the default and setting
+service_refresh
and service_enable
to false will mean that the
+user and not Puppet running will control the running state of
+Cassandra. This currently works OK on the Red Hat family, but
+has issues on Debian due to
+CASSANDRA-2356
+during an initial install or package upgrade.
All the functionality relating to OpsCenter has been divested to the +locp/opscenter module on +Puppet Forge.
+ +It should also be noted that the module no longer creates directories for
+the data
, commitlog
, saved_caches
and for Cassandra 3 the hints
+directory. These resources will now need to be defined in your
+manifest/profile.
For a list of features that have been deprecated in this release, please see +https://github.com/voxpupuli/puppet-cassandra/wiki/Deprecations
+ +For details on migrating from the version 1.X.X attributes to the settings
+hash, see
+(https://github.com/voxpupuli/puppet-cassandra/wiki/Suggested-Baseline-Settings)
Please also see the notes for 2.0.0 in the +CHANGELOG.
+ +The hints_directory documentation will cause a change in the cassandra.yaml +file regardless of the value you set it to. If you do not wish this to +result in a refesh of the Cassandra service, please set service_refresh to +false.
+ +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.
+ + if $::osfamily == 'RedHat' {
+ $version = '2.2.4-1'
+ } else {
+ $version = '2.2.4'
+ }
+
+ class { 'cassandra':
+ package_ensure => $version,
+ }
+
+
+A somewhat embarrassing correction to the spelling of the +cassandra::fail_on_non_suppoted_os to cassandra::fail_on_non_supported_os.
+ +Unfortunately both releases 1.3.7 and 1.4.0 have subsequently been found to +call a refresh service even when no changes had been made to the underlying +configuration. In release 1.8.0 (somewhat belatedly) the service_refresh +flag has been introduced to mitigate against similar problems.
+ +There is now a cassandra::datastax_agent class, therefore:
+ +Likewise now there is a new class for handling the installation of Java:
+ +Also there is now a class for installing the optional utilities:
+ +cassandra_opt_package_ensure changed from 'present' to undef.
The manage_service option has been replaced with service_enable and +service_ensure.
Create a Cassandra 2.X cluster called MyCassandraCluster which uses the +GossipingPropertyFileSnitch and password authentication. In this very +basic example the node itself becomes a seed for the cluster and the +credentials will default to a user called cassandra with a password +called of cassandra.
+ +# Cassandra pre-requisites
+include cassandra::datastax_repo
+include cassandra::java
+
+class { 'cassandra':
+ settings => {
+ 'authenticator' => 'PasswordAuthenticator',
+ 'cluster_name' => 'MyCassandraCluster',
+ 'commitlog_directory' => '/var/lib/cassandra/commitlog',
+ 'commitlog_sync' => 'periodic',
+ 'commitlog_sync_period_in_ms' => 10000,
+ 'data_file_directories' => ['/var/lib/cassandra/data'],
+ 'endpoint_snitch' => 'GossipingPropertyFileSnitch',
+ 'listen_address' => $::ipaddress,
+ 'partitioner' => 'org.apache.cassandra.dht.Murmur3Partitioner',
+ 'saved_caches_directory' => '/var/lib/cassandra/saved_caches',
+ 'seed_provider' => [
+ {
+ 'class_name' => 'org.apache.cassandra.locator.SimpleSeedProvider',
+ 'parameters' => [
+ {
+ 'seeds' => $::ipaddress,
+ },
+ ],
+ },
+ ],
+ 'start_native_transport' => true,
+ },
+ require => Class['cassandra::datastax_repo', 'cassandra::java'],
+}
+
+
+However, PLEASE note that this is the ABSOLUTE MINIMUM configuration +to get Cassandra up and running but will probably give you a rather badly +configured node. Please see +Suggested Baseline Settings +for details on making your configuration a lot more robust.
+ +For this code to run with version 3.X of Cassandra, the hints_directory
will
+also need to be specified:
...
+
+class { 'cassandra':
+ settings => {
+ ...
+ 'hints_directory' => '/var/lib/cassandra/hints',
+ ...
+ },
+ require => Class['cassandra::datastax_repo', 'cassandra::java'],
+}
+
+
+In your top level node classification (usually common.yaml
), add the
+settings hash and all the tweaks you want all the clusters to use:
cassandra::baseline_settings:
+ authenticator: AllowAllAuthenticator
+ authorizer: AllowAllAuthorizer
+ auto_bootstrap: true
+ auto_snapshot: true
+ ...
+
+
+Then, in the individual node classification add the parts which define +the cluster:
+ +cassandra::settings:
+ cluster_name: developer playground cassandra cluster
+cassandra::dc: Onsite1
+cassandra::rack: RAC1
+cassandra::package_ensure: 3.0.5-1
+cassandra::package_name: cassandra30
+
+
+We assume that authentication has been enabled for the cassandra +cluster and we are connecting with the default user name and password +('cassandra/cassandra').
+ +In this example, we create a keyspace (mykeyspace) with a table called +'users' and an index called 'users_lname_idx'.
+ +We also add three users (to Cassandra, not the mykeyspace.users +table) called spillman, akers and boone while ensuring that a user +called lucan is absent.
+ +class { 'cassandra':
+ ...
+}
+
+class { 'cassandra::schema':
+ cqlsh_password => 'cassandra',
+ cqlsh_user => 'cassandra',
+ cqlsh_host => $::ipaddress,
+ indexes => {
+ 'users_lname_idx' => {
+ table => 'users',
+ keys => 'lname',
+ keyspace => 'mykeyspace',
+ },
+ },
+ keyspaces => {
+ 'mykeyspace' => {
+ durable_writes => false,
+ replication_map => {
+ keyspace_class => 'SimpleStrategy',
+ replication_factor => 1,
+ },
+ }
+ },
+ permissions => {
+ 'Grant select permissions to spillman to all keyspaces' => {
+ permission_name => 'SELECT',
+ user_name => 'spillman',
+ },
+ 'Grant modify to to keyspace mykeyspace to akers' => {
+ keyspace_name => 'mykeyspace',
+ permission_name => 'MODIFY',
+ user_name => 'akers',
+ },
+ 'Grant alter permissions to mykeyspace to boone' => {
+ keyspace_name => 'mykeyspace',
+ permission_name => 'ALTER',
+ user_name => 'boone',
+ },
+ 'Grant ALL permissions to mykeyspace.users to gbennet' => {
+ keyspace_name => 'mykeyspace',
+ permission_name => 'ALTER',
+ table_name => 'users',
+ user_name => 'gbennet',
+ },
+ },
+ tables => {
+ 'users' => {
+ columns => {
+ user_id => 'int',
+ fname => 'text',
+ lname => 'text',
+ 'PRIMARY KEY' => '(user_id)',
+ },
+ keyspace => 'mykeyspace',
+ },
+ },
+ users => {
+ 'spillman' => {
+ password => 'Niner27',
+ },
+ 'akers' => {
+ password => 'Niner2',
+ superuser => true,
+ },
+ 'boone' => {
+ password => 'Niner75',
+ },
+ 'gbennet' => {
+ 'password' => 'foobar',
+ },
+ 'lucan' => {
+ 'ensure' => absent
+ },
+ },
+}
+
+
+In the DataStax documentation Initializing a multiple node cluster (single +data center) +http://docs.datastax.com/en/cassandra/2.2/cassandra/initialize/initSingleDS.html +there is a basic example of a six node cluster with two seeds to be created in +a single data center spanning two racks. The nodes in the cluster are:
+ +Node Name | +IP Address | +
---|---|
node0 (seed 1) | +110.82.155.0 | +
node1 | +110.82.155.1 | +
node2 | +110.82.155.2 | +
node3 (seed 2) | +110.82.156.3 | +
node4 | +110.82.156.4 | +
node5 | +110.82.156.5 | +
Each node is configured to use the GossipingPropertyFileSnitch and 256 virtual +nodes (vnodes). The name of the cluster is MyCassandraCluster. Also, +while building the initial cluster, we are setting the auto_bootstrap +to false.
+ +In this initial example, we are going to expand the example by:
+ +cassandra::datastax_repo
. This needs to be
+executed before the Cassandra package is installed.cassandra::java
. This need to be executed
+before the Cassandra service is started.node /^node\d+$/ {
+ class { 'cassandra::datastax_repo':
+ before => Class['cassandra']
+ }
+
+ class { 'cassandra::java':
+ before => Class['cassandra']
+ }
+
+ class { 'cassandra':
+ settings => {
+ 'authenticator' => 'AllowAllAuthenticator',
+ 'auto_bootstrap' => false,
+ 'cluster_name' => 'MyCassandraCluster',
+ 'commitlog_directory' => '/var/lib/cassandra/commitlog',
+ 'commitlog_sync' => 'periodic',
+ 'commitlog_sync_period_in_ms' => 10000,
+ 'data_file_directories' => ['/var/lib/cassandra/data'],
+ 'endpoint_snitch' => 'GossipingPropertyFileSnitch',
+ 'hints_directory' => '/var/lib/cassandra/hints',
+ 'listen_interface' => 'eth1',
+ 'num_tokens' => 256,
+ 'partitioner' => 'org.apache.cassandra.dht.Murmur3Partitioner',
+ 'saved_caches_directory' => '/var/lib/cassandra/saved_caches',
+ 'seed_provider' => [
+ {
+ 'class_name' => 'org.apache.cassandra.locator.SimpleSeedProvider',
+ 'parameters' => [
+ {
+ 'seeds' => '110.82.155.0,110.82.156.3',
+ },
+ ],
+ },
+ ],
+ 'start_native_transport' => true,
+ },
+ }
+}
+
+
+The default value for the num_tokens is already 256, but it is +included in the example for clarity. Do not forget to either +set auto_bootstrap to true or not set the attribute at all +after initializing the cluster.
+ +To continue with the examples provided by DataStax, we look at the example +for a cluster across multiple data centers +http://docs.datastax.com/en/cassandra/2.2/cassandra/initialize/initMultipleDS.html.
+ +Node Name | +IP Address | +Data Center | +Rack | +
---|---|---|---|
node0 (seed 1) | +10.168.66.41 | +DC1 | +RAC1 | +
node1 | +10.176.43.66 | +DC1 | +RAC1 | +
node2 | +10.168.247.41 | +DC1 | +RAC1 | +
node3 (seed 2) | +10.176.170.59 | +DC2 | +RAC1 | +
node4 | +10.169.61.170 | +DC2 | +RAC1 | +
node5 | +10.169.30.138 | +DC2 | +RAC1 | +
For the sake of simplicity, we will confine this example to the nodes:
+ +node /^node[012]$/ {
+ class { 'cassandra':
+ dc => 'DC1',
+ settings => {
+ 'authenticator' => 'AllowAllAuthenticator',
+ 'auto_bootstrap' => false,
+ 'cluster_name' => 'MyCassandraCluster',
+ 'commitlog_directory' => '/var/lib/cassandra/commitlog',
+ 'commitlog_sync' => 'periodic',
+ 'commitlog_sync_period_in_ms' => 10000,
+ 'data_file_directories' => ['/var/lib/cassandra/data'],
+ 'endpoint_snitch' => 'GossipingPropertyFileSnitch',
+ 'hints_directory' => '/var/lib/cassandra/hints',
+ 'listen_interface' => 'eth1',
+ 'num_tokens' => 256,
+ 'partitioner' => 'org.apache.cassandra.dht.Murmur3Partitioner',
+ 'saved_caches_directory' => '/var/lib/cassandra/saved_caches',
+ 'seed_provider' => [
+ {
+ 'class_name' => 'org.apache.cassandra.locator.SimpleSeedProvider',
+ 'parameters' => [
+ {
+ 'seeds' => '110.82.155.0,110.82.156.3',
+ },
+ ],
+ },
+ ],
+ 'start_native_transport' => true,
+ },
+ }
+}
+
+node /^node[345]$/ {
+ class { 'cassandra':
+ dc => 'DC2',
+ settings => {
+ 'authenticator' => 'AllowAllAuthenticator',
+ 'auto_bootstrap' => false,
+ 'cluster_name' => 'MyCassandraCluster',
+ 'commitlog_directory' => '/var/lib/cassandra/commitlog',
+ 'commitlog_sync' => 'periodic',
+ 'commitlog_sync_period_in_ms' => 10000,
+ 'data_file_directories' => ['/var/lib/cassandra/data'],
+ 'endpoint_snitch' => 'GossipingPropertyFileSnitch',
+ 'hints_directory' => '/var/lib/cassandra/hints',
+ 'listen_interface' => 'eth1',
+ 'num_tokens' => 256,
+ 'partitioner' => 'org.apache.cassandra.dht.Murmur3Partitioner',
+ 'saved_caches_directory' => '/var/lib/cassandra/saved_caches',
+ 'seed_provider' => [
+ {
+ 'class_name' => 'org.apache.cassandra.locator.SimpleSeedProvider',
+ 'parameters' => [
+ {
+ 'seeds' => '110.82.155.0,110.82.156.3',
+ },
+ ],
+ },
+ ],
+ 'start_native_transport' => true,
+ },
+ }
+}
+
+
+We don't need to specify the rack name (with the rack attribute) as RAC1 is +the default value. Again, do not forget to either set auto_bootstrap to +true or not set the attribute at all after initializing the cluster.
+ +After configuring the relevant repository, the following snippet works on +CentOS 7 to install DSE Cassandra 4.7.0, set the HADOOP_LOG_DIR, set the +DSE_HOME and configure DataStax Enterprise to use LDAP for authentication:
+ +class { 'cassandra::datastax_repo':
+ descr => 'DataStax Repo for DataStax Enterprise',
+ pkg_url => 'https://username:password@rpm.datastax.com/enterprise',
+ before => Class['cassandra'],
+}
+
+class { 'cassandra':
+ cluster_name => 'MyCassandraCluster',
+ config_path => '/etc/dse/cassandra',
+ package_ensure => '4.7.0-1',
+ package_name => 'dse-full',
+ service_name => 'dse',
+ ...
+}
+
+class { 'cassandra::dse':
+ file_lines => {
+ 'Set HADOOP_LOG_DIR directory' => {
+ ensure => present,
+ path => '/etc/dse/dse-env.sh',
+ line => 'export HADOOP_LOG_DIR=/var/log/hadoop',
+ match => '^# export HADOOP_LOG_DIR=<log_dir>',
+ },
+ 'Set DSE_HOME' => {
+ ensure => present,
+ path => '/etc/dse/dse-env.sh',
+ line => 'export DSE_HOME=/usr/share/dse',
+ match => '^#export DSE_HOME',
+ },
+ },
+ settings => {
+ ldap_options => {
+ server_host => localhost,
+ server_port => 389,
+ search_dn => 'cn=Admin',
+ search_password => secret,
+ use_ssl => false,
+ use_tls => false,
+ truststore_type => jks,
+ user_search_base => 'ou=users,dc=example,dc=com',
+ user_search_filter => '(uid={0})',
+ credentials_validity_in_ms => 0,
+ connection_pool => {
+ max_active => 8,
+ max_idle => 8,
+ }
+ }
+ }
+}
+
+
+DataStax announced in late October 2016 that it was no longer supporting
+the community edition of Cassandra or DSC as it was known (see
+[Take a bow Planet
+Cassandra](http://www.datastax.com/2016/10/take-a-bow-planet-cassandra)
+for details). However, the following snippet of code running on Ubuntu
+14.04 worked fine without having to change any of the ::cassandra
class
+settings:
require cassandra::java
+include cassandra::optutils
+
+class { 'cassandra::apache_repo':
+ release => '310x',
+ before => Class['cassandra', 'cassandra::optutils'],
+}
+
+class { 'cassandra':
+ ...
+}
+
+
+The reference documentation is generated using the +puppet-strings tool. To see +all of it, please go to +http://voxpupuli.github.io/puppet-cassandra.
+ +cassandra::system::transparent_hugepage
does not
+persist between reboots.Contributions will be gratefully accepted. Please go to the project page, +fork the project, make your changes locally and then raise a pull request. +Details on how to do this are available at +https://guides.github.com/activities/contributing-to-open-source.
+ +Please also see the +CONTRIBUTING.md +page for project specific requirements.
+ +For a list of contributers see +CONTRIBUTING.md +and https://github.com/voxpupuli/puppet-cassandra/graphs/contributors
+t |
+ + + +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161 +162 +163 +164 +165 +166 +167 +168 +169 +170 +171 +172 +173 +174 +175 +176 +177 +178 +179 +180 +181 +182 +183 +184 +185 +186 +187 +188 +189 +190 +191 +192 +193 +194 +195 +196 +197 +198 +199 +200 +201 +202 +203 +204 +205 +206 +207 +208 +209 +210 +211 +212 +213 +214 +215 +216 +217 +218 +219 +220 +221 +222 +223 +224 +225 +226 +227 +228 +229 +230 +231 +232 +233 +234 +235 +236 +237 +238 +239 +240 +241 +242 +243 +244 +245 +246 +247 +248 +249 +250 +251 +252 +253 +254 +255 +256 +257 +258 +259 +260 +261 +262 +263 +264 +265 +266 +267 +268 +269 +270 +271 +272 +273 +274 +275 +276 +277 +278 +279 +280 +281 +282 +283 +284 +285 +286 +287 +288 +289 +290 +291 +292 +293 +294 +295 +296 +297 +298 +299 +300 +301 +302 +303 +304 +305 +306 +307 +308 +309 +310 +311 +312 +313 +314 +315 +316 +317 +318 +319 +320 +321 +322 +323 +324 +325 +326 +327 +328 +329 +330 +331 +332 +333 +334 +335 +336 +337 +338 +339 +340 +341 +342 +343 +344 +345 +346 +347 +348 +349 +350 +351 +352 +353 +354 +355 +356 +357 +358 +359 +360 +361 +362 +363 +364 +365 +366 +367 +368 +369 +370 +371 +372 +373 +374 +375 +376 +377 +378 +379 +380 +381 +382 +383 +384 +385 +386 +387+ |
+
+ # File 'manifests/init.pp', line 130
+
+class cassandra (
+ $baseline_settings = {},
+ $cassandra_2356_sleep_seconds = 5,
+ $cassandra_9822 = false,
+ $cassandra_yaml_tmpl = 'cassandra/cassandra.yaml.erb',
+ $commitlog_directory = undef,
+ $commitlog_directory_mode = '0750',
+ Boolean $manage_config_file = true,
+ $config_file_mode = '0644',
+ $config_path = $::cassandra::params::config_path,
+ $data_file_directories = undef,
+ $data_file_directories_mode = '0750',
+ $dc = 'DC1',
+ $dc_suffix = undef,
+ $fail_on_non_supported_os = true,
+ $hints_directory = undef,
+ $hints_directory_mode = '0750',
+ $package_ensure = 'present',
+ $package_name = $::cassandra::params::cassandra_pkg,
+ $prefer_local = undef,
+ $rack = 'RAC1',
+ $rackdc_tmpl = 'cassandra/cassandra-rackdc.properties.erb',
+ $saved_caches_directory = undef,
+ $saved_caches_directory_mode = '0750',
+ $service_enable = true,
+ $service_ensure = undef,
+ $service_name = 'cassandra',
+ $service_provider = undef,
+ $service_refresh = true,
+ $settings = {},
+ $snitch_properties_file = 'cassandra-rackdc.properties',
+ $systemctl = $::cassandra::params::systemctl,
+ ) inherits cassandra::params {
+ if $service_provider != undef {
+ Service {
+ provider => $service_provider,
+ }
+ }
+
+ $config_file = "${config_path}/cassandra.yaml"
+ $dc_rack_properties_file = "${config_path}/${snitch_properties_file}"
+
+ case $::osfamily {
+ 'RedHat': {
+ $config_file_require = Package['cassandra']
+ $config_file_before = []
+ $config_path_require = Package['cassandra']
+ $dc_rack_properties_file_require = Package['cassandra']
+ $dc_rack_properties_file_before = []
+ $data_dir_require = Package['cassandra']
+ $data_dir_before = []
+
+ if $::operatingsystemmajrelease == '7' and $::cassandra::service_provider == 'init' {
+ exec { "/sbin/chkconfig --add ${service_name}":
+ unless => "/sbin/chkconfig --list ${service_name}",
+ require => Package['cassandra'],
+ before => Service['cassandra'],
+ }
+ }
+ }
+ 'Debian': {
+ $config_file_require = [ User['cassandra'], File[$config_path] ]
+ $config_file_before = Package['cassandra']
+ $config_path_require = []
+ $dc_rack_properties_file_require = [ User['cassandra'], File[$config_path] ]
+ $dc_rack_properties_file_before = Package['cassandra']
+ $data_dir_require = File[$config_file]
+ $data_dir_before = Package['cassandra']
+
+ if $cassandra_9822 {
+ file { '/etc/init.d/cassandra':
+ source => 'puppet:///modules/cassandra/CASSANDRA-9822/cassandra',
+ mode => '0555',
+ before => Package['cassandra'],
+ }
+ }
+ # Sleep after package install and before service resource to prevent
+ # possible duplicate processes arising from CASSANDRA-2356.
+ exec { 'CASSANDRA-2356 sleep':
+ command => "/bin/sleep ${cassandra_2356_sleep_seconds}",
+ refreshonly => true,
+ user => 'root',
+ subscribe => Package['cassandra'],
+ before => Service['cassandra'],
+ }
+
+ group { 'cassandra':
+ ensure => present,
+ }
+
+ $user = 'cassandra'
+
+ user { $user:
+ ensure => present,
+ comment => 'Cassandra database,,,',
+ gid => 'cassandra',
+ home => '/var/lib/cassandra',
+ shell => '/bin/false',
+ managehome => true,
+ require => Group['cassandra'],
+ }
+ # End of CASSANDRA-2356 specific resources.
+ }
+ default: {
+ $config_file_before = [ Package['cassandra'] ]
+ $config_file_require = []
+ $config_path_require = []
+ $dc_rack_properties_file_require = Package['cassandra']
+ $dc_rack_properties_file_before = []
+
+ if $fail_on_non_supported_os {
+ fail("OS family ${::osfamily} not supported")
+ } else {
+ warning("OS family ${::osfamily} not supported")
+ }
+ }
+ }
+
+ package { 'cassandra':
+ ensure => $package_ensure,
+ name => $package_name,
+ notify => Exec['cassandra_reload_systemctl'],
+ }
+
+ exec { 'cassandra_reload_systemctl':
+ command => "${systemctl} daemon-reload",
+ onlyif => "test -x ${systemctl}",
+ path => ['/usr/bin', '/bin'],
+ refreshonly => true,
+ }
+
+ if $manage_config_file {
+ file { $config_path:
+ ensure => directory,
+ group => 'cassandra',
+ owner => 'cassandra',
+ mode => '0755',
+ require => $config_path_require,
+ }
+ }
+
+ if $commitlog_directory {
+ file { $commitlog_directory:
+ ensure => directory,
+ owner => 'cassandra',
+ group => 'cassandra',
+ mode => $commitlog_directory_mode,
+ require => $data_dir_require,
+ before => $data_dir_before,
+ }
+
+ $commitlog_directory_settings = merge($settings,
+ { 'commitlog_directory' => $commitlog_directory, })
+ } else {
+ $commitlog_directory_settings = $settings
+ }
+
+ if is_array($data_file_directories) {
+ file { $data_file_directories:
+ ensure => directory,
+ owner => 'cassandra',
+ group => 'cassandra',
+ mode => $data_file_directories_mode,
+ require => $data_dir_require,
+ before => $data_dir_before,
+ }
+
+ $data_file_directories_settings = merge($settings, {
+ 'data_file_directories' => $data_file_directories,
+ })
+ } else {
+ $data_file_directories_settings = $settings
+ }
+
+ if $hints_directory {
+ file { $hints_directory:
+ ensure => directory,
+ owner => 'cassandra',
+ group => 'cassandra',
+ mode => $hints_directory_mode,
+ require => $data_dir_require,
+ before => $data_dir_before,
+ }
+
+ $hints_directory_settings = merge($settings,
+ { 'hints_directory' => $hints_directory, })
+ } else {
+ $hints_directory_settings = $settings
+ }
+
+ if $saved_caches_directory {
+ file { $saved_caches_directory:
+ ensure => directory,
+ owner => 'cassandra',
+ group => 'cassandra',
+ mode => $saved_caches_directory_mode,
+ require => $data_dir_require,
+ before => $data_dir_before,
+ }
+
+ $saved_caches_directory_settings = merge($settings,
+ { 'saved_caches_directory' => $saved_caches_directory, })
+ } else {
+ $saved_caches_directory_settings = $settings
+ }
+
+ $merged_settings = merge($baseline_settings, $settings,
+ $commitlog_directory_settings,
+ $data_file_directories_settings,
+ $hints_directory_settings,
+ $saved_caches_directory_settings)
+
+ file { $config_file:
+ ensure => present,
+ owner => 'cassandra',
+ group => 'cassandra',
+ content => template($cassandra_yaml_tmpl),
+ mode => $config_file_mode,
+ require => $config_file_require,
+ before => $config_file_before,
+ }
+
+ file { $dc_rack_properties_file:
+ ensure => file,
+ content => template($rackdc_tmpl),
+ owner => 'cassandra',
+ group => 'cassandra',
+ mode => '0644',
+ require => $dc_rack_properties_file_require,
+ before => $dc_rack_properties_file_before,
+ }
+
+ if $package_ensure != 'absent' and $package_ensure != 'purged' {
+ if $service_refresh {
+ service { 'cassandra':
+ ensure => $service_ensure,
+ name => $service_name,
+ enable => $service_enable,
+ subscribe => [
+ File[$config_file],
+ File[$dc_rack_properties_file],
+ Package['cassandra'],
+ ],
+ }
+ } else {
+ service { 'cassandra':
+ ensure => $service_ensure,
+ name => $service_name,
+ enable => $service_enable,
+ require => [
+ File[$config_file],
+ File[$dc_rack_properties_file],
+ Package['cassandra'],
+ ],
+ }
+ }
+ }
+}
+ |
+
An optional class that will allow a suitable repository to be configured +from which packages for Apache Cassandra can be downloaded.
+ +
+ + + +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85+ |
+
+ # File 'manifests/apache_repo.pp', line 23
+
+class cassandra::apache_repo (
+ $descr = 'Repo for Apache Cassandra',
+ $key_id = 'A26E528B271F19B9E5D8E19EA278B781FE4B2BDA',
+ $key_url = 'https://www.apache.org/dist/cassandra/KEYS',
+ $pkg_url = undef,
+ $release = 'main',
+ ) {
+ case $::osfamily {
+ 'RedHat': {
+ if $pkg_url != undef {
+ $baseurl = $pkg_url
+ } else {
+ $url = 'http://www.apache.org/dist/cassandra/redhat'
+ $baseurl = "${url}/${release}"
+ }
+
+ yumrepo { 'cassandra_apache':
+ ensure => present,
+ descr => $descr,
+ baseurl => $baseurl,
+ enabled => 1,
+ gpgcheck => 1,
+ gpgkey => $key_url,
+ }
+ }
+ 'Debian': {
+ include apt
+ include apt::update
+
+ apt::key {'apache.cassandra':
+ id => $key_id,
+ source => $key_url,
+ before => Apt::Source['cassandra.sources'],
+ }
+
+ if $pkg_url != undef {
+ $location = $pkg_url
+ } else {
+ $location = 'http://www.apache.org/dist/cassandra/debian'
+ }
+
+ apt::source {'cassandra.sources':
+ location => $location,
+ comment => $descr,
+ release => $release,
+ include => {
+ 'src' => false,
+ },
+ notify => Exec['update-apache-cassandra-repo'],
+ }
+
+ # Required to wrap apt_update
+ exec {'update-apache-cassandra-repo':
+ refreshonly => true,
+ command => '/bin/true',
+ require => Exec['apt_update'],
+ }
+ }
+ default: {
+ warning("OS family ${::osfamily} not supported")
+ }
+ }
+}
+ |
+
A class for installing the DataStax Agent and to point it at an OpsCenter +instance.
+ +
+ + + +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122+ |
+
+ # File 'manifests/datastax_agent.pp', line 48
+
+class cassandra::datastax_agent (
+ $address_config_file = '/var/lib/datastax-agent/conf/address.yaml',
+ $defaults_file = '/etc/default/datastax-agent',
+ $java_home = undef,
+ $package_ensure = 'present',
+ $package_name = 'datastax-agent',
+ $service_ensure = 'running',
+ $service_enable = true,
+ $service_name = 'datastax-agent',
+ $service_provider = undef,
+ $settings = {},
+ ) inherits cassandra::params {
+ require '::cassandra'
+
+ if $service_provider != undef {
+ System {
+ provider => $service_provider,
+ }
+ }
+
+ package { $package_name:
+ ensure => $package_ensure,
+ require => Class['cassandra'],
+ notify => Exec['datastax_agent_reload_systemctl'],
+ }
+
+ exec { 'datastax_agent_reload_systemctl':
+ command => "${::cassandra::params::systemctl} daemon-reload",
+ onlyif => "test -x ${::cassandra::params::systemctl}",
+ path => ['/usr/bin', '/bin'],
+ refreshonly => true,
+ notify => Service['datastax-agent'],
+ }
+
+ file { $address_config_file:
+ owner => 'cassandra',
+ group => 'cassandra',
+ mode => '0644',
+ require => Package[$package_name],
+ }
+
+ if $java_home != undef {
+ ini_setting { 'java_home':
+ ensure => present,
+ path => $defaults_file,
+ section => '',
+ key_val_separator => '=',
+ setting => 'JAVA_HOME',
+ value => $java_home,
+ notify => Service['datastax-agent'],
+ }
+ }
+
+ service { 'datastax-agent':
+ ensure => $service_ensure,
+ enable => $service_enable,
+ name => $service_name,
+ }
+
+ if $settings {
+ $defaults = {
+ path => $address_config_file,
+ key_val_separator => ': ',
+ require => Package[$package_name],
+ notify => Service['datastax-agent'],
+ }
+
+ $full_settings = {
+ '' => $settings,
+ }
+
+ validate_hash($full_settings)
+ create_ini_settings($full_settings, $defaults)
+ }
+}
+ |
+
An optional class that will allow a suitable repository to be configured +from which packages for DataStax Community can be downloaded. Changing +the defaults will allow any Debian Apt or Red Hat Yum repository to be +configured.
+ +
+ + + +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82+ |
+
+ # File 'manifests/datastax_repo.pp', line 22
+
+class cassandra::datastax_repo (
+ $descr = 'DataStax Repo for Apache Cassandra',
+ $key_id = '7E41C00F85BFC1706C4FFFB3350200F2B999A372',
+ $key_url = 'http://debian.datastax.com/debian/repo_key',
+ $pkg_url = undef,
+ $release = 'stable',
+ ) {
+ case $::osfamily {
+ 'RedHat': {
+ if $pkg_url != undef {
+ $baseurl = $pkg_url
+ } else {
+ $baseurl = 'http://rpm.datastax.com/community'
+ }
+
+ yumrepo { 'datastax':
+ ensure => present,
+ descr => $descr,
+ baseurl => $baseurl,
+ enabled => 1,
+ gpgcheck => 0,
+ }
+ }
+ 'Debian': {
+ include apt
+ include apt::update
+
+ apt::key {'datastaxkey':
+ id => $key_id,
+ source => $key_url,
+ before => Apt::Source['datastax'],
+ }
+
+ if $pkg_url != undef {
+ $location = $pkg_url
+ } else {
+ $location = 'http://debian.datastax.com/community'
+ }
+
+ apt::source {'datastax':
+ location => $location,
+ comment => $descr,
+ release => $release,
+ include => {
+ 'src' => false,
+ },
+ notify => Exec['update-cassandra-repos'],
+ }
+
+ # Required to wrap apt_update
+ exec {'update-cassandra-repos':
+ refreshonly => true,
+ command => '/bin/true',
+ require => Exec['apt_update'],
+ }
+ }
+ default: {
+ warning("OS family ${::osfamily} not supported")
+ }
+ }
+}
+ |
+
A class for configuring DataStax Enterprise (DSE) specific settings.
+ +
+ + + +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85+ |
+
+ # File 'manifests/dse.pp', line 48
+
+class cassandra::dse (
+ $config_file = '/etc/dse/dse.yaml',
+ $config_file_mode = '0644',
+ $dse_yaml_tmpl = 'cassandra/dse.yaml.erb',
+ $file_lines = undef,
+ $service_refresh = true,
+ $settings = undef,
+ ) {
+ include cassandra
+ include stdlib
+
+ if $service_refresh {
+ $notifications = Service['cassandra']
+ } else {
+ $notifications = []
+ }
+
+ if is_hash($file_lines) {
+ $default_file_line = {
+ require => Package['cassandra'],
+ notify => $notifications,
+ }
+
+ create_resources(file_line, $file_lines, $default_file_line)
+ }
+
+ if is_hash($settings) {
+ file { $config_file:
+ ensure => present,
+ owner => 'cassandra',
+ group => 'cassandra',
+ content => template($dse_yaml_tmpl),
+ mode => $config_file_mode,
+ require => Package['cassandra'],
+ notify => $notifications,
+ }
+ }
+}
+ |
+
An optional class to configure incoming network ports on the host that are +relevant to the Cassandra installation. If firewalls are being managed +already, simply do not include this module in your manifest.
+ +IMPORTANT: The full list of which ports should be configured is assessed at +evaluation time of the configuration. Therefore if one is to use this class, +it must be the final cassandra class included in the manifest.
+ +
+ + + +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76+ |
+
+ # File 'manifests/firewall_ports.pp', line 31
+
+class cassandra::firewall_ports (
+ $client_ports = [9042, 9160],
+ $client_subnets = ['0.0.0.0/0'],
+ $inter_node_ports = [7000, 7001, 7199],
+ $inter_node_subnets = ['0.0.0.0/0'],
+ $public_ports = [8888],
+ $public_subnets = ['0.0.0.0/0'],
+ $ssh_port = 22,
+ $opscenter_ports = [9042, 9160, 61620, 61621],
+ $opscenter_subnets = ['0.0.0.0/0'],
+ ) {
+ # Public connections on any node.
+ $public_subnets_array = prefix($public_subnets, '200_Public_')
+
+ cassandra::private::firewall_ports::rule { $public_subnets_array:
+ ports => concat($public_ports, [$ssh_port]),
+ }
+
+ # If this is a Cassandra node.
+ if defined ( Class['::cassandra'] ) {
+ # Inter-node connections for Cassandra
+ $inter_node_subnets_array = prefix($inter_node_subnets,
+ '210_InterNode_')
+
+ cassandra::private::firewall_ports::rule { $inter_node_subnets_array:
+ ports => $inter_node_ports,
+ }
+
+ # Client connections for Cassandra
+ $client_subnets_array = prefix($client_subnets, '220_Client_')
+
+ cassandra::private::firewall_ports::rule {$client_subnets_array:
+ ports => $client_ports,
+ }
+ }
+
+ # Connections for DataStax Agent
+ if defined ( Class['::cassandra::datastax_agent'] ) or defined ( Class['::cassandra::opscenter'] ) {
+ $opscenter_subnets_opc_agent = prefix($opscenter_subnets,
+ '230_OpsCenter_')
+
+ cassandra::private::firewall_ports::rule { $opscenter_subnets_opc_agent:
+ ports => $opscenter_ports,
+ }
+ }
+}
+ |
+
A class to install Java and JNA packages.
+ +
+ + + +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66+ |
+
+ # File 'manifests/java.pp', line 17
+
+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],
+ }
+
+ 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,
+ }
+}
+ |
+
A class to install the optional Cassandra tools package.
+ +
+ + + +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16+ |
+
+ # File 'manifests/optutils.pp', line 6
+
+class cassandra::optutils (
+ $package_ensure = 'present',
+ $package_name = $::cassandra::params::optutils_package_name,
+ ) inherits cassandra::params {
+ include '::cassandra'
+
+ package { $package_name:
+ ensure => $package_ensure,
+ require => Class['cassandra'],
+ }
+}
+ |
+
This class is meant to be called from the locp-cassandra module. +It sets variables according to platform.
+ +
+ + + +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51+ |
+
+ # File 'manifests/params.pp', line 3
+
+class cassandra::params {
+ case $::osfamily {
+ 'Debian': {
+ case $::operatingsystemmajrelease {
+ 12.04: {
+ $net_ipv4_tcp_rmem = '4096 87380 16777216'
+ $net_ipv4_tcp_wmem = '4096 65536 16777216'
+ }
+ default: {
+ $net_ipv4_tcp_rmem = '4096, 87380, 16777216'
+ $net_ipv4_tcp_wmem = '4096, 65536, 16777216'
+ }
+ }
+
+ $cassandra_pkg = 'cassandra'
+ $config_path = '/etc/cassandra'
+ $java_package = 'openjdk-7-jre-headless'
+ $jna_package_name = 'libjna-java'
+ $optutils_package_name = 'cassandra-tools'
+ $sysctl_file = '/etc/sysctl.d/10-cassandra.conf'
+ $systemctl = '/bin/systemctl'
+ }
+ 'RedHat': {
+ case $::operatingsystemmajrelease {
+ 6: {
+ $net_ipv4_tcp_rmem = '4096 87380 16777216'
+ $net_ipv4_tcp_wmem = '4096 65536 16777216'
+ $sysctl_file = '/etc/sysctl.conf'
+ }
+ 7: {
+ $net_ipv4_tcp_rmem = '4096, 87380, 16777216'
+ $net_ipv4_tcp_wmem = '4096, 65536, 16777216'
+ $sysctl_file = '/etc/sysctl.d/10-cassandra.conf'
+ }
+ default: {}
+ }
+
+ $cassandra_pkg = 'cassandra22'
+ $config_path = '/etc/cassandra/default.conf'
+ $java_package = 'java-1.8.0-openjdk-headless'
+ $jna_package_name = 'jna'
+ $optutils_package_name = 'cassandra22-tools'
+ $systemctl = '/usr/bin/systemctl'
+ }
+ default: {
+ $config_path_parents = []
+ }
+ }
+}
+ |
+
A class to maintain the database schema. Please note that cqlsh expects +Python 2.7 to be installed. This may be a problem of older distributions +(CentOS 6 for example).
+ +
+ + + +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128+ |
+
+ # File 'manifests/schema.pp', line 35
+
+class cassandra::schema (
+ $connection_tries = 6,
+ $connection_try_sleep = 30,
+ $cql_types = {},
+ $cqlsh_additional_options = '',
+ $cqlsh_client_config = undef,
+ $cqlsh_client_tmpl = 'cassandra/cqlshrc.erb',
+ $cqlsh_command = '/usr/bin/cqlsh',
+ $cqlsh_host = 'localhost',
+ $cqlsh_password = undef,
+ $cqlsh_port = 9042,
+ $cqlsh_user = 'cassandra',
+ $indexes = {},
+ $keyspaces = {},
+ $permissions = {},
+ $tables = {},
+ $users = {},
+ ) inherits cassandra::params {
+ require '::cassandra'
+
+ if $cqlsh_client_config != undef {
+ file { $cqlsh_client_config :
+ ensure => file,
+ group => $::gid,
+ mode => '0600',
+ owner => $::id,
+ content => template( $cqlsh_client_tmpl ),
+ before => Exec['::cassandra::schema connection test'],
+ }
+
+ $cmdline_login = "--cqlshrc=${cqlsh_client_config}"
+ } else {
+ if $cqlsh_password != undef {
+ warning('You may want to consider using the cqlsh_client_config attribute')
+ $cmdline_login = "-u ${cqlsh_user} -p ${cqlsh_password}"
+ } else {
+ $cmdline_login = ''
+ }
+ }
+
+ $cqlsh_opts = "${cqlsh_command} ${cmdline_login} ${cqlsh_additional_options}"
+ $cqlsh_conn = "${cqlsh_host} ${cqlsh_port}"
+
+ # See if we can make a connection to Cassandra. Try $connection_tries
+ # number of times with $connection_try_sleep in seconds between each try.
+ $connection_test = "${cqlsh_opts} -e 'DESC KEYSPACES' ${cqlsh_conn}"
+ exec { '::cassandra::schema connection test':
+ command => $connection_test,
+ returns => 0,
+ tries => $connection_tries,
+ try_sleep => $connection_try_sleep,
+ unless => $connection_test,
+ }
+
+ # manage keyspaces if present
+ if $keyspaces {
+ create_resources('cassandra::schema::keyspace', $keyspaces)
+ }
+
+ # manage cql_types if present
+ if $cql_types {
+ create_resources('cassandra::schema::cql_type', $cql_types)
+ }
+
+ # manage tables if present
+ if $tables {
+ create_resources('cassandra::schema::table', $tables)
+ }
+
+ # manage indexes if present
+ if $indexes {
+ create_resources('cassandra::schema::index', $indexes)
+ }
+
+ # manage users if present
+ if $users {
+ create_resources('cassandra::schema::user', $users)
+ }
+
+ # manage permissions if present
+ if $permissions {
+ create_resources('cassandra::schema::permission', $permissions)
+ }
+
+ # Resource Ordering
+ Cassandra::Schema::Keyspace <| |> -> Cassandra::Schema::Cql_type <| |>
+ Cassandra::Schema::Keyspace <| |> -> Cassandra::Schema::Table <| |>
+ Cassandra::Schema::Keyspace <| |> -> Cassandra::Schema::Permission <| |>
+ Cassandra::Schema::Cql_type <| |> -> Cassandra::Schema::Table <| |>
+ Cassandra::Schema::Table <| |> -> Cassandra::Schema::Index <| |>
+ Cassandra::Schema::Table <| |> -> Cassandra::Schema::Permission <| |>
+ Cassandra::Schema::Index <| |> -> Cassandra::Schema::User <| |>
+ Cassandra::Schema::User <| |> -> Cassandra::Schema::Permission <| |>
+}
+ |
+
Disable swap on the node as suggested at +http://docs.datastax.com/en/landing_page/doc/landing_page/recommendedSettingsLinux.html
+ +
+ + + +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27+ |
+
+ # File 'manifests/system/swapoff.pp', line 9
+
+class cassandra::system::swapoff(
+ $device = undef,
+ $mount = 'swap',
+ $path = '/proc/swaps',
+ ) {
+ exec { 'Disable Swap':
+ command => 'swapoff --all',
+ onlyif => "grep -q '^/' ${path}",
+ path => [ '/bin', '/sbin', '/usr/bin', '/usr/sbin' ],
+ }
+
+ if $device {
+ mount { $mount:
+ ensure => absent,
+ device => $device,
+ fstype => 'swap',
+ }
+ }
+}
+ |
+
Set Sysctl (kernel runtime parameters) as suggested in +http://docs.datastax.com/en/landing_page/doc/landing_page/recommendedSettingsLinux.html
+ +If any of the values is set into the target file, the sysctl command will +be called with the provided file name as an argument.
+ +
+ + + +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113+ |
+
+ # File 'manifests/system/sysctl.pp', line 24
+
+class cassandra::system::sysctl(
+ $sysctl_args = '-p',
+ $sysctl_file = $cassandra::params::sysctl_file,
+ $net_core_optmem_max = 40960,
+ $net_core_rmem_default = 16777216,
+ $net_core_rmem_max = 16777216,
+ $net_core_wmem_default = 16777216,
+ $net_core_wmem_max = 16777216,
+ $net_ipv4_tcp_rmem = $::cassandra::params::net_ipv4_tcp_rmem,
+ $net_ipv4_tcp_wmem = $::cassandra::params::net_ipv4_tcp_wmem,
+ $vm_max_map_count = 1048575,
+ ) inherits cassandra::params {
+
+ ini_setting { "net.core.rmem_max = ${net_core_rmem_max}":
+ ensure => present,
+ path => $sysctl_file,
+ section => '',
+ setting => 'net.core.rmem_max',
+ value => $net_core_rmem_max,
+ notify => Exec['Apply sysctl changes'],
+ }
+
+ ini_setting { "net.core.wmem_max = ${net_core_wmem_max}":
+ ensure => present,
+ path => $sysctl_file,
+ section => '',
+ setting => 'net.core.wmem_max',
+ value => $net_core_wmem_max,
+ notify => Exec['Apply sysctl changes'],
+ }
+
+ ini_setting { "net.core.rmem_default = ${net_core_rmem_default}":
+ ensure => present,
+ path => $sysctl_file,
+ section => '',
+ setting => 'net.core.rmem_default',
+ value => $net_core_rmem_default,
+ notify => Exec['Apply sysctl changes'],
+ }
+
+ ini_setting { "net.core.wmem_default = ${net_core_wmem_default}":
+ ensure => present,
+ path => $sysctl_file,
+ section => '',
+ setting => 'net.core.wmem_default',
+ value => $net_core_wmem_default,
+ notify => Exec['Apply sysctl changes'],
+ }
+
+ ini_setting { "net.core.optmem_max = ${net_core_optmem_max}":
+ ensure => present,
+ path => $sysctl_file,
+ section => '',
+ setting => 'net.core.optmem_max',
+ value => $net_core_optmem_max,
+ notify => Exec['Apply sysctl changes'],
+ }
+
+ ini_setting { "net.ipv4.tcp_rmem = ${net_ipv4_tcp_rmem}":
+ ensure => present,
+ path => $sysctl_file,
+ section => '',
+ setting => 'net.ipv4.tcp_rmem',
+ value => $net_ipv4_tcp_rmem,
+ notify => Exec['Apply sysctl changes'],
+ }
+
+ ini_setting { "net.ipv4.tcp_wmem = ${net_ipv4_tcp_wmem}":
+ ensure => present,
+ path => $sysctl_file,
+ section => '',
+ setting => 'net.ipv4.tcp_wmem',
+ value => $net_ipv4_tcp_wmem,
+ notify => Exec['Apply sysctl changes'],
+ }
+
+ ini_setting { "vm.max_map_count = ${vm_max_map_count}":
+ ensure => present,
+ path => $sysctl_file,
+ section => '',
+ setting => 'vm.max_map_count',
+ value => $vm_max_map_count,
+ notify => Exec['Apply sysctl changes'],
+ }
+
+ exec { 'Apply sysctl changes':
+ command => "/sbin/sysctl ${sysctl_args} ${sysctl_file}",
+ refreshonly => true,
+ }
+}
+ |
+
Disable Transparant Huge Pages as suggested in +http://docs.datastax.com/en/landing_page/doc/landing_page/recommendedSettingsLinux.html.
+ +
+ + + +6 +7 +8 +9 +10 +11 +12 +13 +14+ |
+
+ # File 'manifests/system/transparent_hugepage.pp', line 6
+
+class cassandra::system::transparent_hugepage (
+ $path = '/sys/kernel/mm/transparent_hugepage/defrag',
+ ) inherits cassandra::params {
+ exec { 'Disable Java Hugepages':
+ command => "/bin/echo never > ${path}",
+ path => [ '/bin', '/usr/bin' ],
+ unless => "grep -q '\\[never\\]' ${path}",
+ }
+}
+ |
+
A defined type for altering files relative to the configuration directory.
+ +
+ + + +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85+ |
+
+ # File 'manifests/file.pp', line 57
+
+define cassandra::file(
+ $file = $title,
+ $config_path = $::cassandra::config_path,
+ $file_lines = undef,
+ $service_refresh = true,
+ ) {
+ include cassandra
+ include cassandra::params
+ include stdlib
+
+ $path = "${config_path}/${file}"
+
+ if $file_lines != undef {
+ if $service_refresh {
+ $default_file_line = {
+ path => $path,
+ require => Package['cassandra'],
+ notify => Service['cassandra'],
+ }
+ } else {
+ $default_file_line = {
+ path => $path,
+ require => Package['cassandra'],
+ }
+ }
+
+ create_resources(file_line, $file_lines, $default_file_line)
+ }
+}
+ |
+
A defined type to be used as a macro for setting host based firewall +rules. This is not intended to be used by a user (who should use the +API provided by cassandra::firewall_ports instead) but is documented +here for completeness.
+ +
+ + + +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22+ |
+
+ # File 'manifests/private/firewall_ports/rule.pp', line 6
+
+define cassandra::private::firewall_ports::rule(
+ $ports,
+ ) {
+ $array_var1 = split($title, '_')
+ $rule_number = $array_var1[0]
+ $rule_description = $array_var1[1]
+ $source = $array_var1[2]
+
+ if size($ports) > 0 {
+ firewall { "${rule_number} - Cassandra (${rule_description}) - ${source}":
+ action => 'accept',
+ dport => $ports,
+ proto => 'tcp',
+ source => $source,
+ }
+ }
+}
+ |
+
Create or drop user defined data types within the schema.
+ +
+ + + +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43+ |
+
+ # File 'manifests/schema/cql_type.pp', line 14
+
+define cassandra::schema::cql_type (
+ $keyspace,
+ $ensure = present,
+ $fields = {},
+ $cql_type_name = $title,
+ ){
+ include 'cassandra::schema'
+ $read_script = "DESC TYPE ${keyspace}.${cql_type_name}"
+ $read_command = "${::cassandra::schema::cqlsh_opts} -e \"${read_script}\" ${::cassandra::schema::cqlsh_conn}"
+
+ if $ensure == present {
+ $create_script1 = "CREATE TYPE IF NOT EXISTS ${keyspace}.${cql_type_name}"
+ $create_script2 = join(join_keys_to_values($fields, ' '), ', ')
+ $create_script = "${create_script1} (${create_script2})"
+ $create_command = "${::cassandra::schema::cqlsh_opts} -e \"${create_script}\" ${::cassandra::schema::cqlsh_conn}"
+ exec { $create_command:
+ unless => $read_command,
+ require => Exec['::cassandra::schema connection test'],
+ }
+ } elsif $ensure == absent {
+ $delete_script = "DROP type ${keyspace}.${cql_type_name}"
+ $delete_command = "${::cassandra::schema::cqlsh_opts} -e \"${delete_script}\" ${::cassandra::schema::cqlsh_conn}"
+ exec { $delete_command:
+ onlyif => $read_command,
+ require => Exec['::cassandra::schema connection test'],
+ }
+ } else {
+ fail("Unknown action (${ensure}) for ensure attribute.")
+ }
+}
+ |
+
Create or drop indexes within the schema.
+ +
+ + + +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66+ |
+
+ # File 'manifests/schema/index.pp', line 12
+
+define cassandra::schema::index(
+ $keyspace,
+ $table,
+ $ensure = present,
+ $class_name = undef,
+ $index = $title,
+ $keys = undef,
+ $options = undef,
+ ) {
+ include 'cassandra::schema'
+
+ # Fully qualified index name.
+ $fqin = "${keyspace}.${index}"
+ # Fully qualified table name.
+ $fqtn = "${keyspace}.${table}"
+
+ $read_script = "DESC INDEX ${fqin}"
+ $read_command = "${::cassandra::schema::cqlsh_opts} -e \"${read_script}\" ${::cassandra::schema::cqlsh_conn}"
+
+ if $ensure == present {
+ if $class_name != undef {
+ $create_part1 = "CREATE CUSTOM INDEX IF NOT EXISTS ${index} ON ${keyspace}.${table}"
+ } else {
+ $create_part1 = "CREATE INDEX IF NOT EXISTS ${index} ON ${keyspace}.${table}"
+ }
+
+ if $class_name != undef {
+ $create_part2 = "${create_part1} (${keys}) USING '${class_name}'"
+ } else {
+ $create_part2 = "${create_part1} (${keys})"
+ }
+
+ if $options != undef {
+ $create_script = "${create_part2} WITH OPTIONS = ${options}"
+ } else {
+ $create_script = $create_part2
+ }
+
+ $create_command = "${::cassandra::schema::cqlsh_opts} -e \"${create_script}\" ${::cassandra::schema::cqlsh_conn}"
+
+ exec { $create_command:
+ unless => $read_command,
+ require => Exec['::cassandra::schema connection test'],
+ }
+ } elsif $ensure == absent {
+ $delete_script = "DROP INDEX ${fqin}"
+ $delete_command = "${::cassandra::schema::cqlsh_opts} -e \"${delete_script}\" ${::cassandra::schema::cqlsh_conn}"
+ exec { $delete_command:
+ onlyif => $read_command,
+ require => Exec['::cassandra::schema connection test'],
+ }
+ } else {
+ fail("Unknown action (${ensure}) for ensure attribute.")
+ }
+}
+ |
+
Create or drop keyspaces within the schema.
+ +
+ + + +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76+ |
+
+ # File 'manifests/schema/keyspace.pp', line 24
+
+define cassandra::schema::keyspace(
+ $ensure = present,
+ $durable_writes = true,
+ $keyspace_name = $title,
+ $replication_map = {},
+ ) {
+ include 'cassandra::schema'
+
+ $read_script = "DESC KEYSPACE ${keyspace_name}"
+ $read_command = "${::cassandra::schema::cqlsh_opts} -e \"${read_script}\" ${::cassandra::schema::cqlsh_conn}"
+
+ if $ensure == present {
+ $keyspace_class = $replication_map[keyspace_class]
+
+ case $keyspace_class {
+ 'SimpleStrategy': {
+ $replication_factor = $replication_map[replication_factor]
+ $map_str = "{ 'class' : 'SimpleStrategy', 'replication_factor' : ${replication_factor} }"
+ }
+ 'NetworkTopologyStrategy': {
+ $map_str1 = "{ 'class' : 'NetworkTopologyStrategy'"
+ $new_map = prefix(delete($replication_map, 'keyspace_class'), "'")
+ $map_str2 = join(join_keys_to_values($new_map, "': "), ', ')
+ $map_str = "${map_str1}, ${map_str2} }"
+ }
+ default: {
+ $msg_part1 = "Invalid or no class (${keyspace_class}) specified for"
+ $msg_part2 = "keyspace ${keyspace_name}."
+ fail("${msg_part1} ${msg_part2}")
+ }
+ }
+
+ $create_script1 = "CREATE KEYSPACE IF NOT EXISTS ${keyspace_name}"
+ $create_script2 = "WITH REPLICATION = ${map_str}"
+ $create_script3 = "AND DURABLE_WRITES = ${durable_writes}"
+ $create_script = "${create_script1} ${create_script2} ${create_script3}"
+ $create_command = "${::cassandra::schema::cqlsh_opts} -e \"${create_script}\" ${::cassandra::schema::cqlsh_conn}"
+
+ exec { $create_command:
+ unless => $read_command,
+ require => Exec['::cassandra::schema connection test'],
+ }
+ } elsif $ensure == absent {
+ $delete_script = "DROP KEYSPACE ${keyspace_name}"
+ $delete_command = "${::cassandra::schema::cqlsh_opts} -e \"${delete_script}\" ${::cassandra::schema::cqlsh_conn}"
+ exec { $delete_command:
+ onlyif => $read_command,
+ require => Exec['::cassandra::schema connection test'],
+ }
+ } else {
+ fail("Unknown action (${ensure}) for ensure attribute.")
+ }
+}
+ |
+
Grant or revoke permissions.
+To use this class, a suitable authenticator
(e.g. PasswordAuthenticator)
+and authorizer
(e.g. CassandraAuthorizer) must be set in the Cassandra
+class.
WARNING: Specifying keyspace 'ALL' and 'ALL' for permissions at the same +time is not currently supported by this module.
+ +
+ + + +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127+ |
+
+ # File 'manifests/schema/permission.pp', line 30
+
+define cassandra::schema::permission (
+ $user_name,
+ $ensure = present,
+ $keyspace_name = 'ALL',
+ $permission_name = 'ALL',
+ $table_name = undef,
+ ){
+ include 'cassandra::schema'
+
+ if upcase($keyspace_name) == 'ALL' and upcase($permission_name) == 'ALL' {
+ fail('"ALL" keyspaces AND "ALL" permissions are mutually exclusive.')
+ } elsif $table_name {
+ $resource = "TABLE ${keyspace_name}.${table_name}"
+ } elsif upcase($keyspace_name) == 'ALL' {
+ $resource = 'ALL KEYSPACES'
+ } else {
+ $resource = "KEYSPACE ${keyspace_name}"
+ }
+
+ $read_script = "LIST ALL PERMISSIONS ON ${resource}"
+ $upcase_permission_name = upcase($permission_name)
+ $pattern = "\s${user_name} |\s*${user_name} |\s.*\s${upcase_permission_name}$"
+ $read_command = "${::cassandra::schema::cqlsh_opts} -e \"${read_script}\" ${::cassandra::schema::cqlsh_conn} | grep '${pattern}'"
+
+ if upcase($permission_name) == 'ALL' {
+ cassandra::schema::permission { "${title} - ALTER":
+ ensure => $ensure,
+ user_name => $user_name,
+ keyspace_name => $keyspace_name,
+ permission_name => 'ALTER',
+ table_name => $table_name,
+ }
+
+ cassandra::schema::permission { "${title} - AUTHORIZE":
+ ensure => $ensure,
+ user_name => $user_name,
+ keyspace_name => $keyspace_name,
+ permission_name => 'AUTHORIZE',
+ table_name => $table_name,
+ }
+
+ # The CREATE permission is not relevant to tables.
+ if !$table_name {
+ cassandra::schema::permission { "${title} - CREATE":
+ ensure => $ensure,
+ user_name => $user_name,
+ keyspace_name => $keyspace_name,
+ permission_name => 'CREATE',
+ table_name => $table_name,
+ }
+ }
+
+ cassandra::schema::permission { "${title} - DROP":
+ ensure => $ensure,
+ user_name => $user_name,
+ keyspace_name => $keyspace_name,
+ permission_name => 'DROP',
+ table_name => $table_name,
+ }
+
+ cassandra::schema::permission { "${title} - MODIFY":
+ ensure => $ensure,
+ user_name => $user_name,
+ keyspace_name => $keyspace_name,
+ permission_name => 'MODIFY',
+ table_name => $table_name,
+ }
+
+ cassandra::schema::permission { "${title} - SELECT":
+ ensure => $ensure,
+ user_name => $user_name,
+ keyspace_name => $keyspace_name,
+ permission_name => 'SELECT',
+ table_name => $table_name,
+ }
+ } elsif $ensure == present {
+ $create_script = "GRANT ${permission_name} ON ${resource} TO ${user_name}"
+ $create_command = "${::cassandra::schema::cqlsh_opts} -e \"${create_script}\" ${::cassandra::schema::cqlsh_conn
+}"
+
+ exec { $create_script:
+ command => $create_command,
+ unless => $read_command,
+ require => Exec['::cassandra::schema connection test'],
+ }
+ } elsif $ensure == absent {
+ $delete_script = "REVOKE ${permission_name} ON ${resource} FROM ${user_name}"
+ $delete_command = "${::cassandra::schema::cqlsh_opts} -e \"${delete_script}\" ${::cassandra::schema::cqlsh_conn}"
+
+ exec { $delete_script:
+ command => $delete_command,
+ onlyif => $read_command,
+ require => Exec['::cassandra::schema connection test'],
+ }
+ } else {
+ fail("Unknown action (${ensure}) for ensure attribute.")
+ }
+}
+ |
+
Create or drop tables within the schema.
+ +
+ + + +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57+ |
+
+ # File 'manifests/schema/table.pp', line 19
+
+define cassandra::schema::table (
+ $keyspace,
+ $ensure = present,
+ $columns = {},
+ $options = [],
+ $table = $title,
+ ){
+ include 'cassandra::schema'
+ $read_script = "DESC TABLE ${keyspace}.${table}"
+ $read_command = "${::cassandra::schema::cqlsh_opts} -e \"${read_script}\" ${::cassandra::schema::cqlsh_conn}"
+
+ if $ensure == present {
+ $create_script1 = "CREATE TABLE IF NOT EXISTS ${keyspace}.${table}"
+ $cols_def = join(join_keys_to_values($columns, ' '), ', ')
+ $cols_def_rm_collection_type = delete($cols_def, 'COLLECTION-TYPE ')
+
+ if count($options) > 0 {
+ $options_def = join($options, ' AND ')
+ $create_script = "${create_script1} (${cols_def_rm_collection_type}) WITH ${options_def}"
+ } else {
+ $create_script = "${create_script1} (${cols_def_rm_collection_type})"
+ }
+
+ $create_command = "${::cassandra::schema::cqlsh_opts} -e \"${create_script}\" ${::cassandra::schema::cqlsh_conn}"
+ exec { $create_command:
+ unless => $read_command,
+ require => Exec['::cassandra::schema connection test'],
+ }
+ } elsif $ensure == absent {
+ $delete_script = "DROP TABLE IF EXISTS ${keyspace}.${table}"
+ $delete_command = "${::cassandra::schema::cqlsh_opts} -e \"${delete_script}\" ${::cassandra::schema::cqlsh_conn}"
+ exec { $delete_command:
+ onlyif => $read_command,
+ require => Exec['::cassandra::schema connection test'],
+ }
+ } else {
+ fail("Unknown action (${ensure}) for ensure attribute.")
+ }
+}
+ |
+
Create or drop users.
+To use this class, a suitable authenticator
(e.g. PasswordAuthenticator)
+must be set in the Cassandra class.
+ + + +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115+ |
+
+ # File 'manifests/schema/user.pp', line 19
+
+define cassandra::schema::user (
+ $ensure = present,
+ $login = true,
+ $password = undef,
+ $superuser = false,
+ $user_name = $title,
+ ){
+ include 'cassandra::schema'
+
+ if $::cassandrarelease != undef {
+ if versioncmp($::cassandrarelease, '2.2') < 0 {
+ $operate_with_roles = false
+ } else {
+ $operate_with_roles = true
+ }
+ } else {
+ $operate_with_roles = false
+ }
+
+ if $operate_with_roles {
+ $read_script = 'LIST ROLES'
+ } else {
+ $read_script = 'LIST USERS'
+ }
+ $read_command = "${::cassandra::schema::cqlsh_opts} -e \"${read_script}\" ${::cassandra::schema::cqlsh_conn} | grep '\s*${user_name} |'"
+
+ if $ensure == present {
+ if $operate_with_roles {
+ # we are running cassandra > 2.2
+ $create_script1 = "CREATE ROLE IF NOT EXISTS ${user_name}"
+
+ if $password != undef {
+ $create_script2 = "${create_script1} WITH PASSWORD = '${password}'"
+ } else {
+ $create_script2 = $create_script1
+ }
+
+ if $superuser {
+ if $password != undef {
+ $create_script3 = "${create_script2} AND SUPERUSER = true"
+ } else {
+ $create_script3 = "${create_script2} WITH SUPERUSER = true"
+ }
+ } else {
+ $create_script3 = $create_script2
+ }
+
+ if $login {
+ if $superuser or $password != undef {
+ $create_script = "${create_script3} AND LOGIN = true"
+ }
+ else {
+ $create_script = "${create_script3} WITH LOGIN = true"
+ }
+ } else {
+ $create_script = $create_script3
+ }
+ } else {
+ $create_script1 = "CREATE USER IF NOT EXISTS ${user_name}"
+
+ if $password != undef {
+ $create_script2 = "${create_script1} WITH PASSWORD '${password}'"
+ } else {
+ $create_script2 = $create_script1
+ }
+
+ if $superuser {
+ $create_script = "${create_script2} SUPERUSER"
+ } else {
+ $create_script = "${create_script2} NOSUPERUSER"
+ }
+ }
+
+ $create_command = "${::cassandra::schema::cqlsh_opts} -e \"${create_script}\" ${::cassandra::schema::cqlsh_conn}"
+
+ exec { "Create user (${user_name})":
+ command => $create_command,
+ unless => $read_command,
+ require => Exec['::cassandra::schema connection test'],
+ }
+ } elsif $ensure == absent {
+ if $operate_with_roles {
+ $delete_script = "DROP ROLE ${user_name}"
+ } else {
+ $delete_script = "DROP USER ${user_name}"
+ }
+ $delete_command = "${::cassandra::schema::cqlsh_opts} -e \"${delete_script}\" ${::cassandra::schema::cqlsh_conn}"
+
+ exec { "Delete user (${user_name})":
+ command => $delete_command,
+ onlyif => $read_command,
+ require => Exec['::cassandra::schema connection test'],
+ }
+ } else {
+ fail("Unknown action (${ensure}) for ensure attribute.")
+ }
+}
+ |
+
Returns a value (MB) that might be suitable to set the HEAP_NEWSIZE when using the Concurrent Mark Sweep (CMS) Collector.
+Returns a value (MB) that might be suitable to set the MAX_HEAP_SIZE when using the Concurrent Mark Sweep (CMS) Collector.
+Returns a value (MB) that might be suitable to set the HEAP_NEWSIZE.
+Extract the major version from the cassandrarelease fact.
+Returns a value (MB) that might be suitable to set the MAX_HEAP_SIZE.
+Extract the minor version from the cassandrarelease fact.
+Extract the patch version from the cassandrarelease fact.
+Extract the release string from the running Cassandra instance.
+Returns a value (MB) that might be suitable to set the HEAP_NEWSIZE when using +the Concurrent Mark Sweep (CMS) Collector. +See Tuning Java resources +for more details.
+ + +
+ + + +11 +12 +13 +14 +15 +16 +17 +18+ |
+
+ # File 'lib/facter/cassandracmsheapnewsize.rb', line 11 + +Facter.add('cassandracmsheapnewsize') do + setcode do + maxheapsize = Facter.value(:cassandracmsmaxheapsize).to_f + processorcount = Facter.value(:processorcount).to_f + heapnewsize = [100 * processorcount, maxheapsize * 0.25].min + heapnewsize.round + end +end+ |
+
Returns a value (MB) that might be suitable to set the MAX_HEAP_SIZE when using +the Concurrent Mark Sweep (CMS) Collector. +See Tuning Java resources +for more details.
+ + +
+ + + +11 +12 +13 +14 +15 +16 +17 +18 +19+ |
+
+ # File 'lib/facter/cassandracmsmaxheapsize.rb', line 11 + +Facter.add('cassandracmsmaxheapsize') do + setcode do + memorysize_mb = Facter.value(:memorysize_mb).to_f + calc1 = [memorysize_mb * 0.5, 1024].min + calc2 = [memorysize_mb * 0.25, 14_336].min + maxheapsize = [calc1, calc2].max + maxheapsize.round + end +end+ |
+
Returns a value (MB) that might be suitable to set the HEAP_NEWSIZE. +See Tuning Java resources +for more details.
+ + +
+ + + +10 +11 +12 +13 +14 +15 +16 +17+ |
+
+ # File 'lib/facter/cassandraheapnewsize.rb', line 10 + +Facter.add('cassandraheapnewsize') do + setcode do + maxheapsize = Facter.value(:cassandramaxheapsize).to_f + processorcount = Facter.value(:processorcount).to_f + heapnewsize = [100 * processorcount, maxheapsize * 0.25].min + heapnewsize.round + end +end+ |
+
Extract the major version from the cassandrarelease fact.
+ + +
+ + + +6 +7 +8 +9 +10 +11+ |
+
+ # File 'lib/facter/cassandramajorversion.rb', line 6 + +Facter.add('cassandramajorversion') do + setcode do + release = Facter.value(:cassandrarelease) + release.split('.')[0].to_i if release + end +end+ |
+
Returns a value (MB) that might be suitable to set the MAX_HEAP_SIZE. +See Tuning Java resources +for more details.
+ + +
+ + + +10 +11 +12 +13 +14 +15 +16 +17 +18+ |
+
+ # File 'lib/facter/cassandramaxheapsize.rb', line 10 + +Facter.add('cassandramaxheapsize') do + setcode do + memorysize_mb = Facter.value(:memorysize_mb).to_f + calc1 = [memorysize_mb * 0.5, 1024].min + calc2 = [memorysize_mb * 0.25, 8192].min + maxheapsize = [calc1, calc2].max + maxheapsize.round + end +end+ |
+
Extract the minor version from the cassandrarelease fact.
+ + +
+ + + +6 +7 +8 +9 +10 +11+ |
+
+ # File 'lib/facter/cassandraminorversion.rb', line 6 + +Facter.add('cassandraminorversion') do + setcode do + release = Facter.value(:cassandrarelease) + release.split('.')[1].to_i if release + end +end+ |
+
Extract the patch version from the cassandrarelease fact.
+ + +
+ + + +6 +7 +8 +9 +10 +11+ |
+
+ # File 'lib/facter/cassandrapatchversion.rb', line 6 + +Facter.add('cassandrapatchversion') do + setcode do + release = Facter.value(:cassandrarelease) + release.split('.')[2].to_i if release + end +end+ |
+
Extract the release string from the running Cassandra instance.
+ +undefined.
+ + +
+ + + +9 +10 +11 +12 +13 +14+ |
+
+ # File 'lib/facter/cassandrarelease.rb', line 9 + +Facter.add('cassandrarelease') do + setcode do + version = Facter::Util::Resolution.exec('nodetool version') + version.match(%r{\d+\.\d+\.\d+}).to_s if version && version != '' + end +end+ |
+