Skip to content
This repository has been archived by the owner on May 20, 2020. It is now read-only.

allow override of the cookbook used for systemd mongod templates #63

Open
wants to merge 6 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
3 changes: 3 additions & 0 deletions attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@
# Disable Transparent Huge Pages (THP)
default['mongodb3']['mongod']['disable-transparent-hugepages'] = false

# Systemd template cookbook for mongod
default['mongodb3']['mongod']['systemd_template_cookbook'] = 'mongodb3'

# Mongos config file
default['mongodb3']['mongos']['config_file'] = '/etc/mongos.conf'

Expand Down
2 changes: 1 addition & 1 deletion metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
license 'Apache 2.0'
description 'Installs/Configures mongodb3'
long_description 'Installs/Configures mongodb3'
version '5.3.0'
version '5.3.2'

supports 'ubuntu', '>= 12.04'
supports 'debian', '= 7.8'
Expand Down
1 change: 1 addition & 0 deletions recipes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@
case node['platform']
when 'ubuntu'
template '/lib/systemd/system/mongod.service' do
cookbook node['mongodb3']['mongod']['systemd_template_cookbook']
source 'mongod.service.erb'
mode 0644
only_if { node['platform_version'].to_f >= 15.04 }
Expand Down
55 changes: 23 additions & 32 deletions recipes/mongos.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
:config => node['mongodb3']['config']['mongos']
)
helpers Mongodb3Helper
notifies :restart, 'runit_service[mongos]'
end

# Create the log directory
Expand All @@ -54,37 +53,29 @@
recursive true
end

# Install runit service package
# packagecloud cookbook is not working for oracle linux.
if node['platform'] == 'oracle'
# Install pygpgme package for imeyer runit yum repository
package 'pygpgme' do
ignore_failure true
end
# Install imeyer runit packagecloud yum repository
yum_repository 'imeyer_runit' do
description 'imeyer_runit'
baseurl 'https://packagecloud.io/imeyer/runit/el/6/$basearch'
gpgkey 'https://packagecloud.io/gpg.key'
sslcacert '/etc/pki/tls/certs/ca-bundle.crt'
sslverify false
gpgcheck false
action :create
end
# Set `['runit']['prefer_local_yum'] = true` to avoid install yum repository through packagecloud cookbook
node.set['runit']['prefer_local_yum'] = true
end

# Install runit service package through runit::default recipe
include_recipe 'runit::default'
# Create the mongod.service file
case node['platform']
when 'ubuntu'
template '/lib/systemd/system/mongos.service' do
cookbook node['mongodb3']['mongos']['systemd_template_cookbook']
source 'mongos.service.erb'
mode 0644
only_if { node['platform_version'].to_f >= 15.04 }
end
end

# Adding `mongos` service with runit
runit_service 'mongos' do
retries 3
restart_on_update true
cookbook node['mongodb3']['mongos']['runit_template_cookbook']
options ({
:user => node['mongodb3']['user'],
:config_file => node['mongodb3']['mongos']['config_file']
})
# Start the mongod service
service 'mongos' do
case node['platform']
when 'ubuntu'
if node['platform_version'].to_f >= 15.04
provider Chef::Provider::Service::Systemd
elsif node['platform_version'].to_f >= 14.04
provider Chef::Provider::Service::Upstart
end
end
supports :start => true, :stop => true, :restart => true, :status => true
action :enable
subscribes :restart, "template[#{node['mongodb3']['mongos']['config_file']}]", :delayed
end
29 changes: 29 additions & 0 deletions templates/default/mongos.service.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[Unit]
Description=High-performance, schema-free document-oriented database
Documentation=man:mongos(1)
Requires=encryptdisks.service disable-transparent-hugepages.service
After=network.target encryptdisks.service disable-transparent-hugepages.service

[Service]
LimitFSIZE=infinity
LimitCPU=infinity
LimitAS=infinity
LimitNOFILE=422767
LimitNPROC=422767
LimitRSS=infinity
DefaultTasksMax=infinity
Type=forking
User=mongodb
Group=mongodb
RuntimeDirectory=mongod
PIDFile=/var/run/mongod/mongod.pid
ExecStart=/usr/bin/mongos --quiet \
--config /etc/mongos.conf \
--pidfilepath /var/run/mongod/mongos.pid \
--fork
ExecReload=/bin/kill -HUP $MAINPID
TimeoutStopSec=5
KillMode=mixed

[Install]
WantedBy=multi-user.target
1 change: 1 addition & 0 deletions templates/default/monitoring-agent.config.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# Enter your API key - See: cloud.mongodb.com/settings/group
#
mmsApiKey=<%= @config['mmsApiKey'] %>
mmsGroupId=<%= @config['mmsGroupId'] %>

#
# Hostname of the MMS monitoring web server.
Expand Down