Puppet Class: cassandra::schema
- Inherits:
- cassandra::params
- Defined in:
- manifests/schema.pp
Overview
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 <| |>
}
|