edelight / chef-mongodb

MongoDB Chef cookbook
https://community.opscode.com/cookbooks/mongodb
Apache License 2.0
362 stars 3 forks source link

Amazon AWS issues #358

Open serebrov opened 9 years ago

serebrov commented 9 years ago

I am learning AWS OpsWorks and trying to deploy a single mongodb instance via OpsWorks. On the way I had problems using the mongodb recipe with both Amazon Linux 2014.09 and Ubuntu 14.04.

Ubuntu 14.04

The default mongo config file is is /etc/mongodb.conf while ubuntu actually uses /etc/monod.conf. So any custom mongo settings are not applied.

The solution seems to be (I didn't actually verify this) to change [:mongodb][:dbconfig_file] setting from '/etc/mongodb.conf' to '/etc/mongod.conf'. And I think this should be fixed or mentioned in documentation.

Amazon Linux 2014.09

Here there is a problem with changing the default db settings using the approach described in the readme. The following code leads to the deployment error:

mongodb_instance "mongodb" do
  bind_ip "127.0.0.1,#{node[:opsworks][:instance][:private_ip]}"
end

And the error is:

[2014-12-18T20:35:10+00:00] INFO: template[/etc/init.d/mongod] sending run action to execute[mongodb-systemctl-daemon-reload] (immediate)
[2014-12-18T20:35:10+00:00] INFO: Processing execute[mongodb-systemctl-daemon-reload] action run (mongodb-singlenode::default line 174)

================================================================================
Error executing action `run` on resource 'execute[mongodb-systemctl-daemon-reload]'
================================================================================

Errno::ENOENT
-------------
No such file or directory - systemctl

Resource Declaration:
---------------------
# In /var/lib/aws/opsworks/cache.stage2/cookbooks/mongodb/definitions/mongodb.rb

174:   execute 'mongodb-systemctl-daemon-reload' do
175:     command 'systemctl daemon-reload'
176:     action :nothing
177:   end
178: 

Compiled Resource:
------------------
# Declared in /var/lib/aws/opsworks/cache.stage2/cookbooks/mongodb/definitions/mongodb.rb:174:in `block in from_file'

execute("mongodb-systemctl-daemon-reload") do
params {:mongodb_type=>"mongod", :action=>[:enable, :start], :logpath=>"/var/log/mongodb/mongodb.log", :dbpath=>"/data", :configservers=>[], :replicaset=>nil, :notifies=>[], :bind_ip=>"127.0.0.1,172.31.45.215", :name=>"mongod"}
action [:nothing]
retries 0
retry_delay 2
command "systemctl daemon-reload"
backup 5
returns 0
cookbook_name "mongodb-singlenode"
recipe_name "default"
end

Here it seems like there is some OS-level incompatibility and Amazon Linux does not have systemctl. The solution was to avoid this restart - I had to set the bind_ip before including the recipe:

node.normal[:mongodb][:config][:bind_ip] = "127.0.0.1,#{node[:opsworks][:instance][:private_ip]}"

include_recipe "mongodb::default"

And one more issue with Amazon Linux is that it shows the following warning during the deploy:

[2014-12-18T21:23:48+00:00] WARN: CentOS doesn't provide mongodb, forcing use of mongodb-org repo
[2014-12-18T21:23:48+00:00] WARN: 10gen_repo is deprecated, use mongodb_org_repo

Sorry for posting multiple problems as a single issue, I just not sure if these are actual problems or this is just me doing something wrong.

mirzali commented 9 years ago

I have installed it into the Ubuntu 14. The cookbook makes config file (among others) at /etc/mongodb.conf . However the problem is that service mongodb is already started with a config file at /etc/mongod.conf (without any custom settings). I presume this is from the default package installation.

So one of the possible solutions is to

service mongod stop
service mongodb start

and it will pick up the correct config file. This does still work after restart, but if you want to make sure, you could remove the mongod(.conf) files from /etc/init and /etc/init.d

geerzo commented 9 years ago

I believe this is fixed with PR #373

nabulaer commented 9 years ago

on first install it will run mongod upstart instead of mongodb , but stop and start the instances and it will revert to mongodb with the correct config

joshystuart commented 9 years ago

I'm still having issues with this. Can anyone detail a step by step solution? Or a more permanent fix in code?

@geerzo I am trying your suggested fix but it doesn't seem to be working.

geerzo commented 9 years ago

@crimsonronin You applied the PR I submitted to your local copy and you are still getting this error?

joshystuart commented 9 years ago

Hi @geerzo, I tried the PR but it still threw up the same error. I then commented out the whole section and it seemed to work fine https://github.com/evergram/chef-mongodb/commit/a9f76e5050268f203ccebd9b97ef11ffc2303f14.

I haven't had time to look into a more permanent solution yet.

dmarcelino commented 9 years ago

:+1: I've also experienced this.

on first install it will run mongod upstart instead of mongodb , but stop and start the instances and it will revert to mongodb with the correct config

@nabulaer's suggestion worked, thanks!

rentrop commented 9 years ago

Are there any updates on this topic? Just tried it again: mongodb::default works fine on Ubuntu LTS 14.04 but fails on Amazon Linux.

geerzo commented 9 years ago

I haven't done anything here because it works for me. I'm using this fork https://github.com/geerzo/chef-mongodb/tree/amazon_linux_support which is where the PR came from. I'm curious why it won't work for others though. I'm running multiple Amazon Linux servers using it just fine.

geerzo commented 9 years ago

Actually, one note is I'm running replica-sets, I don't think I've tried running mongoldb:default in a long time. Maybe that is broken?

mitchross commented 9 years ago

Any update, I think mongodb:default is broken?

miguelcnf commented 9 years ago

The problem is this platform check and the fact that amazon reports as rhel familly.

chef (12.4.3)> node[:platform_family]
 => "rhel"
chef (12.4.3)> node[:platform_version]
 => "2015.09"
chef (12.4.3)> node[:platform_version].to_i >= 7
 => true
chef (12.4.3)> node[:platform_version].to_i
 => 2015
chef (12.4.3)> node[:platform]
 => "amazon"

It should check platform and not only platform_family.

lianyi commented 8 years ago

+1