From eec1c9c267aad21de6ecd80a52dcf31eee666d24 Mon Sep 17 00:00:00 2001 From: Matt Date: Sat, 12 Jan 2019 15:18:57 -0500 Subject: [PATCH 1/9] Setting up rethink download --- manifests/init.pp | 7 ++-- manifests/install.pp | 74 +++++++++++++++++++++++---------- manifests/params.pp | 7 ++-- manifests/service.pp | 2 +- metadata.json | 5 +-- templates/rethinkdb.service.erb | 12 ++++++ 6 files changed, 74 insertions(+), 33 deletions(-) create mode 100644 templates/rethinkdb.service.erb diff --git a/manifests/init.pp b/manifests/init.pp index 8904e81..c10ed6d 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -1,13 +1,14 @@ 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 + $checksum = $::rethink::params::checksum, + $fetch_url = $::rethink::params::fetch_url, ) inherits rethinkdb::params { validate_bool($manage_service) diff --git a/manifests/install.pp b/manifests/install.pp index 1665d69..a3f4e21 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -1,28 +1,56 @@ class rethinkdb::install inherits rethinkdb { - include 'apt' + $user = $::rethinkdb::service_user + $group = $::rethinkdb::service_group + $checksum = $::rethinkdb::checksum + $fetch_url = $::rethinkdb::fetch_url - 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, - }, - } + user { $user: + comment => 'The user used to run rethinkdb.', + ensure => 'present', + home => '/var/lib/rethinkdb', + membership => 'minimum', + }-> + file { '/var/lib/rethinkdb': + 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 /usr/bin/rethinkdb", + source_hash => $checksum, + timeout => 0, + verbose => false, + }-> + exec { "uncompress ${fetch_binary_url}": + command => "/bin/tar xzf ${fetch_binary_url}", + 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 { '/usr/lib/systemd/system/rethinkdb@.service': + ensure => present, + content => "${module_name}/rethink.service.erb"), + owner => $user, + group => $group, + mode => '0644', } - - package { 'rethinkdb': - name => $rethinkdb::package_name, - ensure => $rethinkdb::package_ensure, - require => [ - Class['apt::update'], - Apt::Source['rethinkdb'], - ], - } - } diff --git a/manifests/params.pp b/manifests/params.pp index 156c31b..436c351 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -1,11 +1,12 @@ class rethinkdb::params { $manage_service = true $service_ensure = 'running' - $package_ensure = 'present' - $package_name = 'rethinkdb' $service_name = 'rethinkdb' + $service_user = 'rethinkdb' + $service_group = 'rethinkdb' $default_instance = true $instance_path = '/etc/rethinkdb/instances.d' + $checksum = '2c3ca9deddd2f1867ad472dbba1c7986' + $fetch_url = null $default_instance_config = {} - $manage_repo = true } diff --git a/manifests/service.pp b/manifests/service.pp index 0c9132d..a6cad25 100644 --- a/manifests/service.pp +++ b/manifests/service.pp @@ -2,6 +2,6 @@ service { $rethinkdb::service_name: ensure => $rethinkdb::service_ensure, - require => Package[$rethinkdb::package_name], + require => File['/usr/lib/systemd/system/rethinkdb@.service'], } } diff --git a/metadata.json b/metadata.json index fb80bbd..e1ee692 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "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", @@ -8,7 +8,6 @@ "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"} ] } diff --git a/templates/rethinkdb.service.erb b/templates/rethinkdb.service.erb new file mode 100644 index 0000000..f44c911 --- /dev/null +++ b/templates/rethinkdb.service.erb @@ -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 \ No newline at end of file From 589d2de630b33a7978c4f52c922eccbbf43d2470 Mon Sep 17 00:00:00 2001 From: Matt Date: Fri, 8 Feb 2019 10:19:34 -0500 Subject: [PATCH 2/9] Fix syntax error --- manifests/install.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/install.pp b/manifests/install.pp index a3f4e21..b023735 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -48,7 +48,7 @@ }-> file { '/usr/lib/systemd/system/rethinkdb@.service': ensure => present, - content => "${module_name}/rethink.service.erb"), + content => "${module_name}/rethink.service.erb", owner => $user, group => $group, mode => '0644', From 2916a334baffc460cdac2f4c515c3bb811b4665c Mon Sep 17 00:00:00 2001 From: Matt Date: Mon, 18 Feb 2019 13:17:58 -0500 Subject: [PATCH 3/9] Fixes for installation --- manifests/install.pp | 22 +++++++++++++++++----- manifests/params.pp | 2 +- manifests/service.pp | 2 +- templates/rethinkdb.service.erb | 4 ++-- 4 files changed, 21 insertions(+), 9 deletions(-) diff --git a/manifests/install.pp b/manifests/install.pp index b023735..6514709 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -11,6 +11,18 @@ home => '/var/lib/rethinkdb', membership => 'minimum', }-> + file { '/etc/rethinkdb': + owner => $user, + group => $group, + mode => '0755', + ensure => 'directory', + }-> + file { $::rethinkdb::instance_path: + owner => $user, + group => $group, + mode => '0755', + ensure => 'directory', + }-> file { '/var/lib/rethinkdb': owner => $user, group => $group, @@ -22,13 +34,13 @@ # 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 /usr/bin/rethinkdb", + unless => "/usr/bin/test -f /usr/bin/rethinkdb", source_hash => $checksum, timeout => 0, verbose => false, }-> - exec { "uncompress ${fetch_binary_url}": - command => "/bin/tar xzf ${fetch_binary_url}", + exec { "uncompress /tmp/rethinkdb.tgz": + command => "/bin/tar xzf /tmp/rethinkdb.tgz", cwd => '/tmp', creates => "/tmp/rethinkdb", }-> @@ -46,9 +58,9 @@ group => $group, mode => '0644', }-> - file { '/usr/lib/systemd/system/rethinkdb@.service': + file { '/lib/systemd/system/rethinkdb@.service': ensure => present, - content => "${module_name}/rethink.service.erb", + content => template("${module_name}/rethinkdb.service.erb"), owner => $user, group => $group, mode => '0644', diff --git a/manifests/params.pp b/manifests/params.pp index 436c351..879a80d 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -1,7 +1,7 @@ class rethinkdb::params { $manage_service = true $service_ensure = 'running' - $service_name = 'rethinkdb' + $service_name = 'rethinkdb@rethinkdb.service' $service_user = 'rethinkdb' $service_group = 'rethinkdb' $default_instance = true diff --git a/manifests/service.pp b/manifests/service.pp index a6cad25..05f4c8d 100644 --- a/manifests/service.pp +++ b/manifests/service.pp @@ -2,6 +2,6 @@ service { $rethinkdb::service_name: ensure => $rethinkdb::service_ensure, - require => File['/usr/lib/systemd/system/rethinkdb@.service'], + require => File['/lib/systemd/system/rethinkdb@.service'], } } diff --git a/templates/rethinkdb.service.erb b/templates/rethinkdb.service.erb index f44c911..f7e0788 100644 --- a/templates/rethinkdb.service.erb +++ b/templates/rethinkdb.service.erb @@ -2,8 +2,8 @@ Description=RethinkDB database server for instance '%i' [Service] -User=<%= @user %>] -Group=<%= @group %>] +User=<%= @user %> +Group=<%= @group %> ExecStart=/usr/bin/rethinkdb serve --config-file /etc/rethinkdb/instances.d/%i.conf KillMode=process PrivateTmp=true From 76b17da20ecd4be0ac5f594fb46483ef34740c1f Mon Sep 17 00:00:00 2001 From: Matt Date: Tue, 30 Apr 2019 21:13:26 -0400 Subject: [PATCH 4/9] some more fixes --- manifests/install.pp | 28 +++++++++------------------- templates/rethinkdb.service.erb | 2 +- 2 files changed, 10 insertions(+), 20 deletions(-) diff --git a/manifests/install.pp b/manifests/install.pp index 6514709..cdc5f01 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -11,53 +11,43 @@ home => '/var/lib/rethinkdb', membership => 'minimum', }-> - file { '/etc/rethinkdb': - owner => $user, - group => $group, - mode => '0755', - ensure => 'directory', - }-> - file { $::rethinkdb::instance_path: - owner => $user, - group => $group, - mode => '0755', - ensure => 'directory', - }-> file { '/var/lib/rethinkdb': 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 -f /usr/bin/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", + 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/rethinkdb@.service': ensure => present, content => template("${module_name}/rethinkdb.service.erb"), diff --git a/templates/rethinkdb.service.erb b/templates/rethinkdb.service.erb index f7e0788..bd97336 100644 --- a/templates/rethinkdb.service.erb +++ b/templates/rethinkdb.service.erb @@ -9,4 +9,4 @@ KillMode=process PrivateTmp=true [Install] -WantedBy=multi-user.target \ No newline at end of file +WantedBy=multi-user.target From 2bc6feaa0a3149e0831ee163d66b73b55a6dd98e Mon Sep 17 00:00:00 2001 From: Matt Date: Thu, 2 May 2019 22:14:56 -0400 Subject: [PATCH 5/9] Create config directories --- manifests/install.pp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/manifests/install.pp b/manifests/install.pp index cdc5f01..90bb501 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -4,6 +4,7 @@ $group = $::rethinkdb::service_group $checksum = $::rethinkdb::checksum $fetch_url = $::rethinkdb::fetch_url + $instance_path = $::rethinkdb::instance_path user { $user: comment => 'The user used to run rethinkdb.', @@ -16,6 +17,18 @@ group => $group, mode => '0755', ensure => 'directory', + }-> + 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}": From f578afd09fdfee6f98f802217220ca9b5559b1c9 Mon Sep 17 00:00:00 2001 From: Matt Date: Thu, 9 May 2019 14:15:07 -0400 Subject: [PATCH 6/9] Change to instance creation --- manifests/install.pp | 6 ------ manifests/instance.pp | 7 +++++++ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/manifests/install.pp b/manifests/install.pp index 90bb501..5546bfc 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -12,12 +12,6 @@ home => '/var/lib/rethinkdb', membership => 'minimum', }-> - file { '/var/lib/rethinkdb': - owner => $user, - group => $group, - mode => '0755', - ensure => 'directory', - }-> file { '/etc/rethinkdb': owner => $user, group => $group, diff --git a/manifests/instance.pp b/manifests/instance.pp index bed93cd..1e7d980 100644 --- a/manifests/instance.pp +++ b/manifests/instance.pp @@ -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", @@ -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, + } } From fd1d7adaebaeb2fdcba5d26c8372b9996f4eabf8 Mon Sep 17 00:00:00 2001 From: Matt Date: Thu, 23 May 2019 17:52:51 -0400 Subject: [PATCH 7/9] Allow option to install package dependencies --- manifests/init.pp | 1 + manifests/install.pp | 5 +++++ manifests/packages.pp | 26 ++++++++++++++++++++++++++ manifests/params.pp | 1 + 4 files changed, 33 insertions(+) create mode 100644 manifests/packages.pp diff --git a/manifests/init.pp b/manifests/init.pp index c10ed6d..88bde28 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -7,6 +7,7 @@ $default_instance = $rethinkdb::params::default_instance, $default_instance_config = $rethinkdb::params::default_instance_config, $instance_path = $rethinkdb::params::instance_path, + $install_packages = $rethinkdb::params::install_packages, $checksum = $::rethink::params::checksum, $fetch_url = $::rethink::params::fetch_url, ) inherits rethinkdb::params { diff --git a/manifests/install.pp b/manifests/install.pp index 5546bfc..8d82890 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -5,6 +5,11 @@ $checksum = $::rethinkdb::checksum $fetch_url = $::rethinkdb::fetch_url $instance_path = $::rethinkdb::instance_path + $install_packages = $::rethinkdb::install_packages + + if ($install_packages) { + include rethinkdb::packages + } user { $user: comment => 'The user used to run rethinkdb.', diff --git a/manifests/packages.pp b/manifests/packages.pp new file mode 100644 index 0000000..b64ccce --- /dev/null +++ b/manifests/packages.pp @@ -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, + } + +} diff --git a/manifests/params.pp b/manifests/params.pp index 879a80d..f157f90 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -6,6 +6,7 @@ $service_group = 'rethinkdb' $default_instance = true $instance_path = '/etc/rethinkdb/instances.d' + $install_packages = true, $checksum = '2c3ca9deddd2f1867ad472dbba1c7986' $fetch_url = null $default_instance_config = {} From 753ff4b37e5ae0c12289015293e7c9469f6c1439 Mon Sep 17 00:00:00 2001 From: Jason Moore Date: Thu, 6 Jun 2019 15:50:39 -0400 Subject: [PATCH 8/9] Removing comma as it's causing puppet install to fail --- manifests/params.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/params.pp b/manifests/params.pp index f157f90..d837e33 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -6,7 +6,7 @@ $service_group = 'rethinkdb' $default_instance = true $instance_path = '/etc/rethinkdb/instances.d' - $install_packages = true, + $install_packages = true $checksum = '2c3ca9deddd2f1867ad472dbba1c7986' $fetch_url = null $default_instance_config = {} From 93707b5fe7df0cf8b522f0d3282687f7d6e07288 Mon Sep 17 00:00:00 2001 From: kleinmp Date: Wed, 15 Jan 2020 14:38:03 -0500 Subject: [PATCH 9/9] Fix type --- manifests/params.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/params.pp b/manifests/params.pp index f157f90..d837e33 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -6,7 +6,7 @@ $service_group = 'rethinkdb' $default_instance = true $instance_path = '/etc/rethinkdb/instances.d' - $install_packages = true, + $install_packages = true $checksum = '2c3ca9deddd2f1867ad472dbba1c7986' $fetch_url = null $default_instance_config = {}