diff --git a/Gemfile b/Gemfile index d9cab0c..fb429fa 100644 --- a/Gemfile +++ b/Gemfile @@ -1,84 +1,85 @@ source ENV['GEM_SOURCE'] || "https://rubygems.org" def location_for(place, fake_version = nil) if place =~ /^(git[:@][^#]*)#(.*)/ [fake_version, { :git => $1, :branch => $2, :require => false }].compact elsif place =~ /^file:\/\/(.*)/ ['>= 0', { :path => File.expand_path($1), :require => false }] else [place, { :require => false }] end end group :test do gem 'puppetlabs_spec_helper', '>= 2.11.0', :require => false gem 'rspec-puppet-facts', '>= 1.8.0', :require => false gem 'rspec-puppet-utils', :require => false gem 'puppet-lint-leading_zero-check', :require => false gem 'puppet-lint-trailing_comma-check', :require => false gem 'puppet-lint-version_comparison-check', :require => false gem 'puppet-lint-classes_and_types_beginning_with_digits-check', :require => false gem 'puppet-lint-unquoted_string-check', :require => false gem 'puppet-lint-variable_contains_upcase', :require => false gem 'puppet-lint-absolute_classname-check', :require => false + gem 'puppet-lint-topscope-variable-check', :require => false gem 'metadata-json-lint', :require => false gem 'redcarpet', :require => false gem 'rubocop', '~> 0.49.1', :require => false if RUBY_VERSION >= '2.3.0' gem 'rubocop-rspec', '~> 1.15.0', :require => false if RUBY_VERSION >= '2.3.0' gem 'mocha', '~> 1.4.0', :require => false gem 'coveralls', :require => false gem 'simplecov-console', :require => false gem 'rack', '~> 1.0', :require => false if RUBY_VERSION < '2.2.2' gem 'parallel_tests', '2.24.0', :require => false if RUBY_VERSION < '2.2.0' gem 'parallel_tests', :require => false if RUBY_VERSION >= '2.2.0' end group :development do gem 'travis', :require => false gem 'travis-lint', :require => false gem 'guard-rake', :require => false gem 'overcommit', '>= 0.39.1', :require => false end group :system_tests do gem 'winrm', :require => false if beaker_version = ENV['BEAKER_VERSION'] gem 'beaker', *location_for(beaker_version) else gem 'beaker', '>= 4.2.0', :require => false end if beaker_rspec_version = ENV['BEAKER_RSPEC_VERSION'] gem 'beaker-rspec', *location_for(beaker_rspec_version) else gem 'beaker-rspec', :require => false end gem 'serverspec', :require => false gem 'beaker-hostgenerator', '>= 1.1.22', :require => false gem 'beaker-docker', :require => false gem 'beaker-puppet', :require => false gem 'beaker-puppet_install_helper', :require => false gem 'beaker-module_install_helper', :require => false gem 'rbnacl', '>= 4', :require => false if RUBY_VERSION >= '2.2.6' gem 'rbnacl-libsodium', :require => false if RUBY_VERSION >= '2.2.6' gem 'bcrypt_pbkdf', :require => false end group :release do gem 'github_changelog_generator', :require => false, :git => 'https://github.com/github-changelog-generator/github-changelog-generator' if RUBY_VERSION >= '2.2.2' gem 'puppet-blacksmith', :require => false gem 'voxpupuli-release', :require => false, :git => 'https://github.com/voxpupuli/voxpupuli-release-gem' gem 'puppet-strings', '>= 1.0', :require => false end if facterversion = ENV['FACTER_GEM_VERSION'] gem 'facter', facterversion.to_s, :require => false, :groups => [:test] else gem 'facter', :require => false, :groups => [:test] end ENV['PUPPET_VERSION'].nil? ? puppetversion = '~> 5.0' : puppetversion = ENV['PUPPET_VERSION'].to_s gem 'puppet', puppetversion, :require => false, :groups => [:test] # vim: syntax=ruby diff --git a/manifests/datastax_agent.pp b/manifests/datastax_agent.pp index 943098d..8343d47 100644 --- a/manifests/datastax_agent.pp +++ b/manifests/datastax_agent.pp @@ -1,120 +1,120 @@ # A class for installing the DataStax Agent and to point it at an OpsCenter # instance. # # @param address_config_file The full path to the address config file. # @param defaults_file The full path name to the file where `java_home` is set. # @param java_home If the value of this variable is left as *undef*, no # action is taken. Otherwise the value is set as JAVA_HOME in # `defaults_file`. # @param package_ensure Is passed to the package reference. Valid values are # **present** or a version number. # @param package_name Is passed to the package reference. # @param service_ensure Is passed to the service reference. # @param service_enable Is passed to the service reference. # @param service_name Is passed to the service reference. # @param service_provider The name of the provider that runs the service. # If left as *undef* then the OS family specific default will be used, # otherwise the specified value will be used instead. # @param settings A hash that is passed to # [create_ini_settings] # (https://github.com/puppetlabs/puppetlabs-inifile#function-create_ini_settings) # with the following additional defaults: # # ```puppet # { # path => $address_config_file, # key_val_separator => ': ', # require => Package[$package_name], # notify => Service['datastax-agent'], # } # ``` # # @example Set agent_alias to foobar, stomp_interface to localhost and ensure that async_pool_size is absent from the file. # class { 'cassandra::datastax_agent': # settings => { # 'agent_alias' => { # 'setting' => 'agent_alias', # 'value' => 'foobar', # }, # 'stomp_interface' => { # 'setting' => 'stomp_interface', # 'value' => 'localhost', # }, # 'async_pool_size' => { # 'ensure' => absent, # }, # }, # } 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}", + 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, } create_ini_settings($full_settings, $defaults) } } diff --git a/manifests/file.pp b/manifests/file.pp index c35b9b3..0a6698d 100644 --- a/manifests/file.pp +++ b/manifests/file.pp @@ -1,85 +1,85 @@ # A defined type for altering files relative to the configuration directory. # @param file [string] The name of the file relative to the `config_path`. # @param config_path [string] The path to the configuration directory. # @param file_lines [string] If set, then the [create_resources] # (https://docs.puppet.com/puppet/latest/reference/function.html#createresources) # will be used to create an array of [file_line] # (https://forge.puppet.com/puppetlabs/stdlib#file_line) resources. # @param service_refresh [boolean] Is the Cassandra service is to be notified # if the environment file is changed. # @example # if $::memorysize_mb < 24576.0 { # $max_heap_size_in_mb = floor($::memorysize_mb / 2) # } elsif $::memorysize_mb < 8192.0 { # $max_heap_size_in_mb = floor($::memorysize_mb / 4) # } else { # $max_heap_size_in_mb = 8192 # } # # $heap_new_size = $::processorcount * 100 # # cassandra::file { "Set Java/Cassandra max heap size to ${max_heap_size_in_mb}.": # file => 'cassandra-env.sh', # file_lines => { # 'MAX_HEAP_SIZE' => { # line => "MAX_HEAP_SIZE='${max_heap_size_in_mb}M'", # match => '^#?MAX_HEAP_SIZE=.*', # }, # } # } # # cassandra::file { "Set Java/Cassandra heap new size to ${heap_new_size}.": # file => 'cassandra-env.sh', # file_lines => { # 'HEAP_NEWSIZE' => { # line => "HEAP_NEWSIZE='${heap_new_size}M'", # match => '^#?HEAP_NEWSIZE=.*', # } # } # } # $tmpdir = '/var/lib/cassandra/tmp' # # file { $tmpdir: # ensure => directory, # owner => 'cassandra', # group => 'cassandra', # } # # cassandra::file { 'Set java.io.tmpdir': # file => 'jvm.options', # file_lines => { # 'java.io.tmpdir' => { # line => "-Djava.io.tmpdir=${tmpdir}", # }, # }, # require => File[$tmpdir], # } define cassandra::file( $file = $title, - $config_path = $::cassandra::config_path, + $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) } } diff --git a/manifests/init.pp b/manifests/init.pp index 06c4b3f..963cd04 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -1,390 +1,390 @@ # A class for installing the Cassandra package and manipulate settings in the # configuration file. # # @param baseline_settings [hash] If set, this is a baseline of settings that # are merged with the `settings` hash. The values of the `settings` # hash overriding the values in this hash. This is most useful when used # with hiera. # @param cassandra_2356_sleep_seconds [boolean] # This will provide a workaround for # [CASSANDRA-2356](https://issues.apache.org/jira/browse/CASSANDRA-2356) by # sleeping for the specifed number of seconds after an event involving the # Cassandra package. This option is silently ignored on the Red Hat family # of operating systems as this bug only affects Debian systems. # @param cassandra_9822 [boolean] If set to true, this will apply a patch to the init # file for the Cassandra service as a workaround for # [CASSANDRA-9822](https://issues.apache.org/jira/browse/CASSANDRA-9822). # This this bug only affects Debian systems. # @param cassandra_yaml_tmpl [string] The path to the Puppet template for the # Cassandra configuration file. This allows the user to supply their own # customized template.` # @param commitlog_directory [string] The path to the commitlog directory. # If set, the directory will be managed as a Puppet resource. Do not # specify a value here and in the `settings` hash as they are mutually # exclusive. # @param commitlog_directory_mode [string] The mode for the # `commitlog_directory` is ignored unless `commitlog_directory` is # specified. # @param manage_config_file [boolean] Whether or not to manage the cassandra configuration # file. # @param config_file_mode [string] The permissions mode of the cassandra configuration # file. # @param config_path [string] The path to the cassandra configuration file. # @param data_file_directories [array] The path(s) to the date directory or # directories. # If set, the directories will be managed as a Puppet resource. Do not # specify a value here and in the `settings` hash as they are mutually # exclusive. # @param data_file_directories_mode [string] The mode for the # `data_file_directories` is ignored unless `data_file_directories` is # specified. # @param dc [string] Sets the value for dc in *config_path*/*snitch_properties_file* # http://docs.datastax.com/en/cassandra/2.1/cassandra/architecture/architectureSnitchesAbout_c.html # for more details. # @param dc_suffix [string] Sets the value for dc_suffix in # *config_path*/*snitch_properties_file* see # http://docs.datastax.com/en/cassandra/2.1/cassandra/architecture/architectureSnitchesAbout_c.html # for more details. If the value is *undef* then no change will be made to # the snitch properties file for this setting. # @param fail_on_non_supported_os [boolean] A flag that dictates if the module should # fail if it is not RedHat or Debian. If you set this option to false then # you must also at least set the `config_path` attribute as well. # @param hints_directory [string] The path to the hints directory. # If set, the directory will be managed as a Puppet resource. Do not # specify a value here and in the `settings` hash as they are mutually # exclusive. Do not set this option in Cassandra versions before 3.0.0. # @param hints_directory_mode [string] The mode for the # `hints_directory` is ignored unless `hints_directory` is # specified. # @param package_ensure [present|latest|string] The status of the package specified in # **package_name**. Can be *present*, *latest* or a specific version # number. # @param package_name [string] The name of the Cassandra package which must be available # from a repository. # @param prefer_local [boolean] Sets the value for prefer_local in # *config_path*/*snitch_properties_file* see # http://docs.datastax.com/en/cassandra/2.1/cassandra/architecture/architectureSnitchesAbout_c.html # for more details. Valid values are true, false or *undef*. If the value # is *undef* then change will be made to the snitch properties file for # this setting. # @param rack [string] Sets the value for rack in # *config_path*/*snitch_properties_file* see # http://docs.datastax.com/en/cassandra/2.1/cassandra/architecture/architectureSnitchesAbout_c.html # for more details. # @param rackdc_tmpl [string] The template for creating the snitch properties file. # @param saved_caches_directory [string] The path to the saved caches directory. # If set, the directory will be managed as a Puppet resource. Do not # specify a value here and in the `settings` hash as they are mutually # exclusive. # @param saved_caches_directory_mode [string] The mode for the # `saved_caches_directory` is ignored unless `saved_caches_directory` is # specified. # @param service_enable [boolean] enable the Cassandra service to start at boot time. # @param service_ensure [string] Ensure the Cassandra service is running. Valid values # are running or stopped. # @param service_name [string] The name of the service that runs the Cassandra software. # @param service_provider [string] The name of the provider that runs the service. # If left as *undef* then the OS family specific default will # be used, otherwise the specified value will be used instead. # @param service_refresh [boolean] If set to true, changes to the Cassandra config file # or the data directories will ensure that Cassandra service is refreshed # after the changes. Setting this flag to false will disable this # behaviour, therefore allowing the changes to be made but allow the user # to control when the service is restarted. # @param settings [hash] A hash that is passed to `to_yaml` which dumps the results # to the Cassandra configuring file. The minimum required settings for # Cassandra 2.X are as follows: # # ```puppet # { # '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, # } # ``` # For Cassandra 3.X you will also need to specify the `hints_directory` # attribute. # @param snitch_properties_file [string] The name of the snitch properties file. The # full path name would be *config_path*/*snitch_properties_file*. # @param systemctl [string] The full path to the systemctl command. Only # needed when the package is installed. Will silently continue if the # executable does not exist. 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, + $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, + $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, + $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' { + 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, } 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) if $manage_config_file { 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, } $service_dependencies = [ File[$config_file], File[$dc_rack_properties_file], Package['cassandra'], ] } else { $service_dependencies = [ File[$dc_rack_properties_file], Package['cassandra'], ] } 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 => $service_dependencies, } } else { service { 'cassandra': ensure => $service_ensure, name => $service_name, enable => $service_enable, require => $service_dependencies, } } } } diff --git a/manifests/java.pp b/manifests/java.pp index 99c9a66..31aa7a3 100644 --- a/manifests/java.pp +++ b/manifests/java.pp @@ -1,67 +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, + $jna_package_name = $cassandra::params::jna_package_name, $package_ensure = present, - $package_name = $::cassandra::params::java_package, + $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/manifests/optutils.pp b/manifests/optutils.pp index 6aaf5ff..3895c4e 100644 --- a/manifests/optutils.pp +++ b/manifests/optutils.pp @@ -1,16 +1,16 @@ # A class to install the optional Cassandra tools package. # @param package_ensure [string] Can be `present`, `latest` or a specific # version number. # @param package_name [string] The name of the optional utilities package to # be installed. class cassandra::optutils ( $package_ensure = 'present', - $package_name = $::cassandra::params::optutils_package_name, + $package_name = $cassandra::params::optutils_package_name, ) inherits cassandra::params { include 'cassandra' package { $package_name: ensure => $package_ensure, require => Class['cassandra'], } } diff --git a/manifests/schema/cql_type.pp b/manifests/schema/cql_type.pp index 043bbc1..0e8bd0a 100644 --- a/manifests/schema/cql_type.pp +++ b/manifests/schema/cql_type.pp @@ -1,67 +1,67 @@ # Create or drop user defined data types within the schema. # @param keyspace [string] The name of the keyspace that the data type is to be associated with. # @param ensure [present|absent] ensure the data type is created, or is dropped. # @param fields [hash] A hash of the fields that will be components for the data type. # @param cql_type_name [string] The name of the CQL type to be created. # @example # cassandra::schema::cql_type { 'fullname': # keyspace => 'mykeyspace', # fields => { # 'fname' => 'text', # 'lname' => 'text', # }, # } define cassandra::schema::cql_type ( $keyspace, $ensure = present, $fields = {}, $cql_type_name = $title, Boolean $use_scl = $cassandra::params::use_scl, String[1] $scl_name = $cassandra::params::scl_name, ){ include 'cassandra::schema' if $use_scl { $quote = '\"' } else { $quote = '"' } $read_script = "DESC TYPE ${keyspace}.${cql_type_name}" - $read_command_tmp = "${::cassandra::schema::cqlsh_opts} -e ${quote}${read_script}${quote} ${::cassandra::schema::cqlsh_conn}" + $read_command_tmp = "${cassandra::schema::cqlsh_opts} -e ${quote}${read_script}${quote} ${cassandra::schema::cqlsh_conn}" if $use_scl { $read_command = "/usr/bin/scl enable ${scl_name} \"${read_command_tmp}\"" } else { $read_command = $read_command_tmp } 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_tmp = "${::cassandra::schema::cqlsh_opts} -e ${quote}${create_script}${quote} ${::cassandra::schema::cqlsh_conn}" + $create_command_tmp = "${cassandra::schema::cqlsh_opts} -e ${quote}${create_script}${quote} ${cassandra::schema::cqlsh_conn}" if $use_scl { $create_command = "/usr/bin/scl enable ${scl_name} \"${create_command_tmp}\"" } else { $create_command = $create_command_tmp } 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_tmp = "${::cassandra::schema::cqlsh_opts} -e ${quote}${delete_script}${quote} ${::cassandra::schema::cqlsh_conn}" + $delete_command_tmp = "${cassandra::schema::cqlsh_opts} -e ${quote}${delete_script}${quote} ${cassandra::schema::cqlsh_conn}" if $use_scl { $delete_command = "/usr/bin/scl enable ${scl_name} \"${delete_command_tmp}\"" } else { $delete_command = $delete_command_tmp } exec { $delete_command: onlyif => $read_command, require => Exec['::cassandra::schema connection test'], } } else { fail("Unknown action (${ensure}) for ensure attribute.") } } diff --git a/manifests/schema/index.pp b/manifests/schema/index.pp index 897f45b..ee47cbd 100644 --- a/manifests/schema/index.pp +++ b/manifests/schema/index.pp @@ -1,90 +1,90 @@ # Create or drop indexes within the schema. # @param ensure [present|absent] Create or dro[ the index. # @param class_name [string] The name of the class to be associated with an # index when creating a custom index. # @param index [string] The name of the index. Defaults to the name of the # resource. # @param keys [string] The columns that the index is being created on. # @param keyspace [string] The name the keyspace that the index is to be associated # with. # @param options [string] Any options to be added to the index. # @param table [string] The name of the table that the index is to be associated with. define cassandra::schema::index( $keyspace, $table, $ensure = present, $class_name = undef, $index = $title, $keys = undef, $options = undef, Boolean $use_scl = $cassandra::params::use_scl, String[1] $scl_name = $cassandra::params::scl_name, ) { include 'cassandra::schema' if $use_scl { $quote = '\"' } else { $quote = '"' } # Fully qualified index name. $fqin = "${keyspace}.${index}" # Fully qualified table name. $fqtn = "${keyspace}.${table}" $read_script = "DESC INDEX ${fqin}" - $read_command_tmp = "${::cassandra::schema::cqlsh_opts} -e ${quote}${read_script}${quote} ${::cassandra::schema::cqlsh_conn}" + $read_command_tmp = "${cassandra::schema::cqlsh_opts} -e ${quote}${read_script}${quote} ${cassandra::schema::cqlsh_conn}" if $use_scl { $read_command = "/usr/bin/scl enable ${scl_name} \"${read_command_tmp}\"" } else { $read_command = $read_command_tmp } 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_tmp = "${::cassandra::schema::cqlsh_opts} -e ${quote}${create_script}${quote} ${::cassandra::schema::cqlsh_conn}" + $create_command_tmp = "${cassandra::schema::cqlsh_opts} -e ${quote}${create_script}${quote} ${cassandra::schema::cqlsh_conn}" if $use_scl { $create_command = "/usr/bin/scl enable ${scl_name} \"${create_command_tmp}\"" } else { $create_command = $create_command_tmp } exec { $create_command: unless => $read_command, require => Exec['::cassandra::schema connection test'], } } elsif $ensure == absent { $delete_script = "DROP INDEX ${fqin}" - $delete_command_tmp = "${::cassandra::schema::cqlsh_opts} -e ${quote}${delete_script}${quote} ${::cassandra::schema::cqlsh_conn}" + $delete_command_tmp = "${cassandra::schema::cqlsh_opts} -e ${quote}${delete_script}${quote} ${cassandra::schema::cqlsh_conn}" if $use_scl { $delete_command = "/usr/bin/scl enable ${scl_name} \"${delete_command_tmp}\"" } else { $delete_command = $delete_command_tmp } exec { $delete_command: onlyif => $read_command, require => Exec['::cassandra::schema connection test'], } } else { fail("Unknown action (${ensure}) for ensure attribute.") } } diff --git a/manifests/schema/keyspace.pp b/manifests/schema/keyspace.pp index 87ec12e..8e784ee 100644 --- a/manifests/schema/keyspace.pp +++ b/manifests/schema/keyspace.pp @@ -1,98 +1,98 @@ # Create or drop keyspaces within the schema. # @param ensure [present|absent] Create or drop the keyspace. # @param durable_writes [boolean] When set to false, data written to the # keyspace bypasses the commit log. Be careful using this option # because you risk losing data. Set this attribute to false on a keyspace # using the SimpleStrategy. # @param keyspace_name [string] The name of the keyspace to be created. # @param replication_map [hash] Needed if the keyspace is to be present. # Optional if it is to be absent. # @example # $network_topology_strategy = { # keyspace_class => 'NetworkTopologyStrategy', # dc1 => 3, # dc2 => 2 # } # @example # cassandra::schema::keyspace { 'mykeyspace': # replication_map => { # keyspace_class => 'SimpleStrategy', # replication_factor => 1, # }, # durable_writes => false, # } define cassandra::schema::keyspace( $ensure = present, $durable_writes = true, $keyspace_name = $title, $replication_map = {}, Boolean $use_scl = $cassandra::params::use_scl, String[1] $scl_name = $cassandra::params::scl_name, ) { include 'cassandra::schema' if $use_scl { $quote = '\"' } else { $quote = '"' } $read_script = "DESC KEYSPACE ${keyspace_name}" - $read_command_tmp = "${::cassandra::schema::cqlsh_opts} -e ${quote}${read_script}${quote} ${::cassandra::schema::cqlsh_conn}" + $read_command_tmp = "${cassandra::schema::cqlsh_opts} -e ${quote}${read_script}${quote} ${cassandra::schema::cqlsh_conn}" if $use_scl { $read_command = "/usr/bin/scl enable ${scl_name} \"${read_command_tmp}\"" } else { $read_command = $read_command_tmp } 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_tmp = "${::cassandra::schema::cqlsh_opts} -e ${quote}${create_script}${quote} ${::cassandra::schema::cqlsh_conn}" + $create_command_tmp = "${cassandra::schema::cqlsh_opts} -e ${quote}${create_script}${quote} ${cassandra::schema::cqlsh_conn}" if $use_scl { $create_command = "/usr/bin/scl enable ${scl_name} \"${create_command_tmp}\"" } else { $create_command = $create_command_tmp } exec { $create_command: unless => $read_command, require => Exec['::cassandra::schema connection test'], } } elsif $ensure == absent { $delete_script = "DROP KEYSPACE ${keyspace_name}" - $delete_command_tmp = "${::cassandra::schema::cqlsh_opts} -e ${quote}${delete_script}${quote} ${::cassandra::schema::cqlsh_conn}" + $delete_command_tmp = "${cassandra::schema::cqlsh_opts} -e ${quote}${delete_script}${quote} ${cassandra::schema::cqlsh_conn}" if $use_scl { $delete_command = "/usr/bin/scl enable ${scl_name} \"${delete_command_tmp}\"" } else { $delete_command = $delete_command_tmp } exec { $delete_command: onlyif => $read_command, require => Exec['::cassandra::schema connection test'], } } else { fail("Unknown action (${ensure}) for ensure attribute.") } } diff --git a/manifests/schema/permission.pp b/manifests/schema/permission.pp index d2415da..b98291d 100644 --- a/manifests/schema/permission.pp +++ b/manifests/schema/permission.pp @@ -1,161 +1,161 @@ # 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. # # @param user_name [string] The name of the user who is to be granted or # revoked. # @param ensure [ present | absent ] Set to present to grant a permission or # absent to revoke it. # @param keyspace_name [string] The name of the keyspace to grant/revoke the # permissions on. If set to 'ALL' then the permission will be applied to # all of the keyspaces. # @param permission_name [string] Can be one of the following: # # * 'ALTER' - ALTER KEYSPACE, ALTER TABLE, CREATE INDEX, DROP INDEX. # * 'AUTHORIZE' - GRANT, REVOKE. # * 'CREATE' - CREATE KEYSPACE, CREATE TABLE. # * 'DROP' - DROP KEYSPACE, DROP TABLE. # * 'MODIFY' - INSERT, DELETE, UPDATE, TRUNCATE. # * 'SELECT' - SELECT. # # If the permission_name is set to 'ALL', this will set all of the specific # permissions listed. # @param table_name [string] The name of a table within the specified # keyspace. If left unspecified, the procedure will be applied to all # tables within the keyspace. define cassandra::schema::permission ( $user_name, $ensure = present, $keyspace_name = 'ALL', $permission_name = 'ALL', $table_name = undef, Boolean $use_scl = $cassandra::params::use_scl, String[1] $scl_name = $cassandra::params::scl_name, ){ include 'cassandra::schema' if $use_scl { $quote = '\"' } else { $quote = '"' } 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_tmp = "${::cassandra::schema::cqlsh_opts} -e ${quote}${read_script}${quote} ${::cassandra::schema::cqlsh_conn} | grep '${pattern}'" + $read_command_tmp = "${cassandra::schema::cqlsh_opts} -e ${quote}${read_script}${quote} ${cassandra::schema::cqlsh_conn} | grep '${pattern}'" if $use_scl { $read_command = "/usr/bin/scl enable ${scl_name} \"${read_command_tmp}\"" } else { $read_command = $read_command_tmp } 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, use_scl => $use_scl, scl_name => $scl_name, } cassandra::schema::permission { "${title} - AUTHORIZE": ensure => $ensure, user_name => $user_name, keyspace_name => $keyspace_name, permission_name => 'AUTHORIZE', table_name => $table_name, use_scl => $use_scl, scl_name => $scl_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, use_scl => $use_scl, scl_name => $scl_name, } } cassandra::schema::permission { "${title} - DROP": ensure => $ensure, user_name => $user_name, keyspace_name => $keyspace_name, permission_name => 'DROP', table_name => $table_name, use_scl => $use_scl, scl_name => $scl_name, } cassandra::schema::permission { "${title} - MODIFY": ensure => $ensure, user_name => $user_name, keyspace_name => $keyspace_name, permission_name => 'MODIFY', table_name => $table_name, use_scl => $use_scl, scl_name => $scl_name, } cassandra::schema::permission { "${title} - SELECT": ensure => $ensure, user_name => $user_name, keyspace_name => $keyspace_name, permission_name => 'SELECT', table_name => $table_name, use_scl => $use_scl, scl_name => $scl_name, } } elsif $ensure == present { $create_script = "GRANT ${permission_name} ON ${resource} TO ${user_name}" - $create_command_tmp = "${::cassandra::schema::cqlsh_opts} -e ${quote}${create_script}${quote} ${::cassandra::schema::cqlsh_conn}" + $create_command_tmp = "${cassandra::schema::cqlsh_opts} -e ${quote}${create_script}${quote} ${cassandra::schema::cqlsh_conn}" if $use_scl { $create_command = "/usr/bin/scl enable ${scl_name} \"${create_command_tmp}\"" } else { $create_command = $create_command_tmp } 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_tmp = "${::cassandra::schema::cqlsh_opts} -e ${quote}${delete_script}${quote} ${::cassandra::schema::cqlsh_conn}" + $delete_command_tmp = "${cassandra::schema::cqlsh_opts} -e ${quote}${delete_script}${quote} ${cassandra::schema::cqlsh_conn}" if $use_scl { $delete_command = "/usr/bin/scl enable ${scl_name} \"${delete_command_tmp}\"" } else { $delete_command = $delete_command_tmp } exec { $delete_script: command => $delete_command, onlyif => $read_command, require => Exec['::cassandra::schema connection test'], } } else { fail("Unknown action (${ensure}) for ensure attribute.") } } diff --git a/manifests/schema/table.pp b/manifests/schema/table.pp index 279d3f5..02eb21b 100644 --- a/manifests/schema/table.pp +++ b/manifests/schema/table.pp @@ -1,81 +1,81 @@ # Create or drop tables within the schema. # @param keyspace [string] The name of the keyspace. # @param columns [hash] A hash of the columns to be placed in the table. # Optional if the table is to be absent. # @param ensure [present|absent] Ensure a keyspace is created or dropped. # @param options [array] Options to be added to the table creation. # @param table [string] The name of the table. Defaults to the name of the # resource. # @example # cassandra::schema::table { 'users': # keyspace => 'mykeyspace', # columns => { # 'userid' => 'int', # 'fname' => 'text', # 'lname' => 'text', # 'PRIMARY KEY' => '(userid)', # }, # } define cassandra::schema::table ( $keyspace, $ensure = present, $columns = {}, $options = [], $table = $title, Boolean $use_scl = $cassandra::params::use_scl, String[1] $scl_name = $cassandra::params::scl_name, ){ include 'cassandra::schema' if $use_scl { $quote = '\"' } else { $quote = '"' } $read_script = "DESC TABLE ${keyspace}.${table}" - $read_command_tmp = "${::cassandra::schema::cqlsh_opts} -e ${quote}${read_script}${quote} ${::cassandra::schema::cqlsh_conn}" + $read_command_tmp = "${cassandra::schema::cqlsh_opts} -e ${quote}${read_script}${quote} ${cassandra::schema::cqlsh_conn}" if $use_scl { $read_command = "/usr/bin/scl enable ${scl_name} \"${read_command_tmp}\"" } else { $read_command = $read_command_tmp } 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_tmp = "${::cassandra::schema::cqlsh_opts} -e ${quote}${create_script}${quote} ${::cassandra::schema::cqlsh_conn}" + $create_command_tmp = "${cassandra::schema::cqlsh_opts} -e ${quote}${create_script}${quote} ${cassandra::schema::cqlsh_conn}" if $use_scl { $create_command = "/usr/bin/scl enable ${scl_name} \"${create_command_tmp}\"" } else { $create_command = $create_command_tmp } 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_tmp = "${::cassandra::schema::cqlsh_opts} -e ${quote}${delete_script}${quote} ${::cassandra::schema::cqlsh_conn}" + $delete_command_tmp = "${cassandra::schema::cqlsh_opts} -e ${quote}${delete_script}${quote} ${cassandra::schema::cqlsh_conn}" if $use_scl { $delete_command = "/usr/bin/scl enable ${scl_name} \"${delete_command_tmp}\"" } else { $delete_command = $delete_command_tmp } exec { $delete_command: onlyif => $read_command, require => Exec['::cassandra::schema connection test'], } } else { fail("Unknown action (${ensure}) for ensure attribute.") } } diff --git a/manifests/schema/user.pp b/manifests/schema/user.pp index a2216bc..f6e292a 100644 --- a/manifests/schema/user.pp +++ b/manifests/schema/user.pp @@ -1,137 +1,137 @@ # Create or drop users. # To use this class, a suitable `authenticator` (e.g. PasswordAuthenticator) # must be set in the Cassandra class. # @param ensure [ present | absent ] Valid values can be **present** to # ensure a user is created, or **absent** to remove the user if it exists. # @param password [string] A password for the user. # @param superuser [boolean] If the user is to be a super-user on the system. # @param login [boolean] Allows the role to log in. # @param user_name [string] The name of the user. # @example # cassandra::schema::user { 'akers': # password => 'Niner2', # superuser => true, # } # # cassandra::schema::user { 'lucan': # ensure => absent, # } define cassandra::schema::user ( $ensure = present, $login = true, $password = undef, $superuser = false, $user_name = $title, Boolean $use_scl = $cassandra::params::use_scl, String[1] $scl_name = $cassandra::params::scl_name, ){ include 'cassandra::schema' if $use_scl { $quote = '\"' } else { $quote = '"' } 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' } $str_match = '\s' - $read_command_tmp = "${::cassandra::schema::cqlsh_opts} -e ${quote}${read_script}${quote} ${::cassandra::schema::cqlsh_conn} | grep '${str_match}*${user_name} |'" + $read_command_tmp = "${cassandra::schema::cqlsh_opts} -e ${quote}${read_script}${quote} ${cassandra::schema::cqlsh_conn} | grep '${str_match}*${user_name} |'" if $use_scl { $read_command = "/usr/bin/scl enable ${scl_name} \"${read_command_tmp}\"" } else { $read_command = $read_command_tmp } 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_tmp = "${::cassandra::schema::cqlsh_opts} -e ${quote}${create_script}${quote} ${::cassandra::schema::cqlsh_conn}" + $create_command_tmp = "${cassandra::schema::cqlsh_opts} -e ${quote}${create_script}${quote} ${cassandra::schema::cqlsh_conn}" if $use_scl { $create_command = "/usr/bin/scl enable ${scl_name} \"${create_command_tmp}\"" } else { $create_command = $create_command_tmp } 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_tmp = "${::cassandra::schema::cqlsh_opts} -e ${quote}${delete_script}${quote} ${::cassandra::schema::cqlsh_conn}" + $delete_command_tmp = "${cassandra::schema::cqlsh_opts} -e ${quote}${delete_script}${quote} ${cassandra::schema::cqlsh_conn}" if $use_scl { $delete_command = "/usr/bin/scl enable ${scl_name} \"${delete_command_tmp}\"" } else { $delete_command = $delete_command_tmp } 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.") } } diff --git a/manifests/system/sysctl.pp b/manifests/system/sysctl.pp index 425d68d..c226d8a 100644 --- a/manifests/system/sysctl.pp +++ b/manifests/system/sysctl.pp @@ -1,113 +1,113 @@ # 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. # # @example Basic requirement # require cassandra::system::sysctl # # @param sysctl_args [string] Passed to the `sysctl` command # @param sysctl_file [string] Path to the file to insert the settings into. # @param net_core_optmem_max [integer] The value to set for # net.core.optmem_max # @param net_core_rmem_default [integer] The value to set for # net.core.rmem_default. # @param net_core_rmem_max [integer] The value to set for net_core_rmem_max. # @param net_core_wmem_default [integer] The value to set for # net.core.wmem_default. # @param net_core_wmem_max [integer] The value to set for net.core.wmem_max. # @param net_ipv4_tcp_rmem [string] The value to set for net.ipv4.tcp_rmem. # @param net_ipv4_tcp_wmem [string] The value to set for net.ipv4.tcp_wmem. # @param vm_max_map_count [integer] The value to set for vm.max_map_count. # @see cassandra::params 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, + $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, } }