From 86072e382b3a9c397ee0cecbb41fafa70f0a8811 Mon Sep 17 00:00:00 2001 From: Wayne Egerer Date: Thu, 10 Aug 2017 15:26:41 -0400 Subject: [PATCH 1/6] allow override of the cookbook used for systemd mongod templates --- attributes/default.rb | 3 +++ recipes/default.rb | 1 + 2 files changed, 4 insertions(+) diff --git a/attributes/default.rb b/attributes/default.rb index fdfc912..f7d2951 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -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' diff --git a/recipes/default.rb b/recipes/default.rb index 5e2147b..7227e92 100644 --- a/recipes/default.rb +++ b/recipes/default.rb @@ -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 } From d45a4a42eec1f295fed9d6f80eb1eced9e574721 Mon Sep 17 00:00:00 2001 From: Wayne Egerer Date: Fri, 18 Aug 2017 18:48:37 -0400 Subject: [PATCH 2/6] update mms-monitoring template to include mmsgroupid --- templates/default/monitoring-agent.config.erb | 1 + 1 file changed, 1 insertion(+) diff --git a/templates/default/monitoring-agent.config.erb b/templates/default/monitoring-agent.config.erb index 602fa53..b9a153c 100644 --- a/templates/default/monitoring-agent.config.erb +++ b/templates/default/monitoring-agent.config.erb @@ -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. From 16cfc29bc94d67fd84c5d38922d4c0c858ec7089 Mon Sep 17 00:00:00 2001 From: Wayne Egerer Date: Fri, 18 Aug 2017 18:53:45 -0400 Subject: [PATCH 3/6] version bump --- metadata.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.rb b/metadata.rb index 88556e1..01f9581 100644 --- a/metadata.rb +++ b/metadata.rb @@ -4,7 +4,7 @@ license 'Apache 2.0' description 'Installs/Configures mongodb3' long_description 'Installs/Configures mongodb3' -version '5.3.0' +version '5.3.1' supports 'ubuntu', '>= 12.04' supports 'debian', '= 7.8' From 896fa33e9ba675c3196be9e91c13d9ec46d8e1b2 Mon Sep 17 00:00:00 2001 From: Wayne Egerer Date: Mon, 9 Jul 2018 10:55:09 -0400 Subject: [PATCH 4/6] mongos to systemd --- metadata.rb | 2 +- recipes/mongos.rb | 54 ++++++++++++---------------- templates/default/mongos.service.erb | 29 +++++++++++++++ 3 files changed, 53 insertions(+), 32 deletions(-) create mode 100755 templates/default/mongos.service.erb diff --git a/metadata.rb b/metadata.rb index 01f9581..80653a9 100644 --- a/metadata.rb +++ b/metadata.rb @@ -4,7 +4,7 @@ license 'Apache 2.0' description 'Installs/Configures mongodb3' long_description 'Installs/Configures mongodb3' -version '5.3.1' +version '5.3.2' supports 'ubuntu', '>= 12.04' supports 'debian', '= 7.8' diff --git a/recipes/mongos.rb b/recipes/mongos.rb index 175595e..2417b6b 100644 --- a/recipes/mongos.rb +++ b/recipes/mongos.rb @@ -54,37 +54,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']['mongod']['systemd_template_cookbook'] + source 'mongod.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 diff --git a/templates/default/mongos.service.erb b/templates/default/mongos.service.erb new file mode 100755 index 0000000..6d22b33 --- /dev/null +++ b/templates/default/mongos.service.erb @@ -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 \ No newline at end of file From 1529b9af7e9093071ac8e4c37f3d7bfcd5c4076a Mon Sep 17 00:00:00 2001 From: Wayne Egerer Date: Mon, 9 Jul 2018 10:57:45 -0400 Subject: [PATCH 5/6] systemd start mongos --- recipes/mongos.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/recipes/mongos.rb b/recipes/mongos.rb index 2417b6b..23f2730 100644 --- a/recipes/mongos.rb +++ b/recipes/mongos.rb @@ -59,8 +59,8 @@ case node['platform'] when 'ubuntu' template '/lib/systemd/system/mongos.service' do - cookbook node['mongodb3']['mongod']['systemd_template_cookbook'] - source 'mongod.service.erb' + cookbook node['mongodb3']['mongos']['systemd_template_cookbook'] + source 'mongos.service.erb' mode 0644 only_if { node['platform_version'].to_f >= 15.04 } end From bbb9e670edfe42cc32f9af96b21f2630691e1550 Mon Sep 17 00:00:00 2001 From: Wayne Egerer Date: Mon, 9 Jul 2018 11:17:07 -0400 Subject: [PATCH 6/6] fix --- recipes/mongos.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/recipes/mongos.rb b/recipes/mongos.rb index 23f2730..82e07ad 100644 --- a/recipes/mongos.rb +++ b/recipes/mongos.rb @@ -44,7 +44,6 @@ :config => node['mongodb3']['config']['mongos'] ) helpers Mongodb3Helper - notifies :restart, 'runit_service[mongos]' end # Create the log directory