Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/1804 #2

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions manifests/init.pp
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
class rethinkdb (
$manage_service = $rethinkdb::params::manage_service,
$service_ensure = $rethinkdb::params::service_ensure,
$package_ensure = $rethinkdb::params::package_ensure,
$package_name = $rethinkdb::params::package_name,
$service_name = $rethinkdb::params::service_name,
$service_user = $rethinkdb::params::service_user,
$service_group = $rethinkdb::params::service_group,
$default_instance = $rethinkdb::params::default_instance,
$default_instance_config = $rethinkdb::params::default_instance_config,
$instance_path = $rethinkdb::params::instance_path,
$manage_repo = $rethinkdb::params::manage_repo
$install_packages = $rethinkdb::params::install_packages,
$checksum = $::rethink::params::checksum,
$fetch_url = $::rethink::params::fetch_url,
) inherits rethinkdb::params {

validate_bool($manage_service)
Expand Down
82 changes: 62 additions & 20 deletions manifests/install.pp
Original file line number Diff line number Diff line change
@@ -1,28 +1,70 @@
class rethinkdb::install inherits rethinkdb {

include 'apt'
$user = $::rethinkdb::service_user
$group = $::rethinkdb::service_group
$checksum = $::rethinkdb::checksum
$fetch_url = $::rethinkdb::fetch_url
$instance_path = $::rethinkdb::instance_path
$install_packages = $::rethinkdb::install_packages

if ($rethinkdb::manage_repo) {
apt::source { 'rethinkdb':
comment => 'The official rethinkdb debian repo.',
location => 'http://download.rethinkdb.com/apt',
key => {
'id' => '3B87619DF812A63A8C1005C30742918E5C8DA04A',
'source' => 'http://download.rethinkdb.com/apt/pubkey.gpg',
},
include => {
deb => true,
},
}
if ($install_packages) {
include rethinkdb::packages
}

package { 'rethinkdb':
name => $rethinkdb::package_name,
ensure => $rethinkdb::package_ensure,
require => [
Class['apt::update'],
Apt::Source['rethinkdb'],
],
user { $user:
comment => 'The user used to run rethinkdb.',
ensure => 'present',
home => '/var/lib/rethinkdb',
membership => 'minimum',
}->
file { '/etc/rethinkdb':
owner => $user,
group => $group,
mode => '0755',
ensure => 'directory',
}->
file { $instance_path:
owner => $user,
group => $group,
mode => '0755',
ensure => 'directory',
}

wget::fetch { "${fetch_url}":
destination => "/tmp/rethinkdb.tgz",
# Currently, cache_dir doesn't work with source_hash.
# https://github.com/voxpupuli/puppet-wget/issues/87
#cache_dir => '/var/cache/rethinkdb',
#unless => "/usr/bin/test /tmp/rethinkdb",
redownload => false,
source_hash => $checksum,
timeout => 0,
verbose => false,
}~>
exec { "uncompress /tmp/rethinkdb.tgz":
command => "/bin/tar -xzf /tmp/rethinkdb.tgz",
cwd => '/tmp',
creates => "/tmp/rethinkdb",
}~>
file { '/usr/bin/rethinkdb':
ensure => present,
source => "/tmp/rethinkdb",
owner => 'root',
group => 'root',
mode => '0755',
}~>
file { '/usr/lib/tmpfiles.d/rethinkdb.conf':
ensure => present,
content => 'd /run/rethinkdb 0755 rethinkdb rethinkdb -',
owner => $user,
group => $group,
mode => '0644',
}~>
file { '/lib/systemd/system/[email protected]':
ensure => present,
content => template("${module_name}/rethinkdb.service.erb"),
owner => $user,
group => $group,
mode => '0644',
}
}
7 changes: 7 additions & 0 deletions manifests/instance.pp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
) {

validate_hash($conf)
$user = $::rethinkdb::service_user
$group = $::rethinkdb::service_group
$path = $conf[directory]

file { "rethinkdb-instance-${name}":
path => "${rethinkdb::instance_path}/${name}.conf",
Expand All @@ -13,4 +16,8 @@
notify => Service[$rethinkdb::service_name],
require => Class['rethinkdb::install'],
}

exec {"/usr/bin/rethinkdb create -d ${path}; /bin/chown ${user}:${group} -R ${path}":
creates => $path,
}
}
26 changes: 26 additions & 0 deletions manifests/packages.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
class rethinkdb::packages {

$dependencies = [
'protobuf-compiler',
'python',
'python-pip',
'libprotobuf-dev',
'libprotobuf10',
'libcurl4-openssl-dev',
#'libboost-all-dev',
'libncurses5-dev',
'libjemalloc-dev',
'm4'
]

package { $dependencies:
ensure => 'installed'
}->

# https://github.com/rethinkdb/rethinkdb/issues/6725
package { "rethinkdb":
ensure => '2.3.0.post6',
provider => pip,
}

}
10 changes: 6 additions & 4 deletions manifests/params.pp
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
class rethinkdb::params {
$manage_service = true
$service_ensure = 'running'
$package_ensure = 'present'
$package_name = 'rethinkdb'
$service_name = 'rethinkdb'
$service_name = '[email protected]'
$service_user = 'rethinkdb'
$service_group = 'rethinkdb'
$default_instance = true
$instance_path = '/etc/rethinkdb/instances.d'
$install_packages = true
$checksum = '2c3ca9deddd2f1867ad472dbba1c7986'
$fetch_url = null
$default_instance_config = {}
$manage_repo = true
}
2 changes: 1 addition & 1 deletion manifests/service.pp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

service { $rethinkdb::service_name:
ensure => $rethinkdb::service_ensure,
require => Package[$rethinkdb::package_name],
require => File['/lib/systemd/system/rethinkdb@.service'],
}
}
5 changes: 2 additions & 3 deletions metadata.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
{
"name": "zivtech-rethinkdb",
"version": "0.1.2",
"version": "1.0.0",
"author": "zivtech",
"summary": "Install and configure rethinkdb from official package sources.",
"license": "Apache 2.0",
"source": "https://github.com/zivtech/puppet-rethinkdb.git",
"project_page": "https://github.com/zivtech/puppet-rethinkdb",
"issues_url": "https://github.com/zivtech/puppet-rethinkdb/issues",
"dependencies": [
{"name":"puppetlabs-stdlib","version_requirement":">= 1.0.0"},
{"name":"puppetlabs-apt","version_requirement":">= 2.0.0"}
{"name":"puppetlabs-stdlib","version_requirement":">= 1.0.0"}
]
}
12 changes: 12 additions & 0 deletions templates/rethinkdb.service.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[Unit]
Description=RethinkDB database server for instance '%i'

[Service]
User=<%= @user %>
Group=<%= @group %>
ExecStart=/usr/bin/rethinkdb serve --config-file /etc/rethinkdb/instances.d/%i.conf
KillMode=process
PrivateTmp=true

[Install]
WantedBy=multi-user.target