Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

updating mongoid.yml to v3 format

  • Loading branch information...
commit 9c31615f73572aedb139a3df8e02a17f0552834b 1 parent 94ea01d
Ines Sombra authored
View
16 cookbooks/mongodb/recipes/app.rb
@@ -2,23 +2,23 @@
# no-op here as there are no utility instances, do not pass.
else
user = @node[:users].first
-
+
if ['app_master','app'].include?(node[:instance_role])
mongo_replication_sets = @node[:utility_instances].select { |instance| instance[:name].match(/^mongodb_repl/) }.map { |instance| instance[:name].split("_")[1].sub("repl","") }.uniq
end
mongo_app_names = @node[:applications].keys
-
+
# Chef::Log.info "app.rb - mongo_replication_sets = #{mongo_replication_sets} | node app keys = #{@node[:applications].keys}"
-
+
mongo_app_names.each do |mongo_app_name|
# Chef::Log.info "looping for mongo_app_name = #{mongo_app_name}"
-
+
template "/data/#{mongo_app_name}/shared/config/mongodb.yml" do
source "mongodb.yml.erb"
owner user[:username]
group user[:username]
mode 0755
-
+
if @node[:instance_role] == "solo" && @node[:mongo_utility_instances].length == 0
variables(:yaml_file => {
node[:environment][:framework_env] => {
@@ -30,15 +30,15 @@
node[:environment][:framework_env] => {
:hosts => hosts} })
end
-
end
+ #Mongoid.yml_v3
template "/data/#{mongo_app_name}/shared/config/mongoid.yml" do
- source "mongoid.yml.erb"
+ source "mongoid_v3.yml.erb"
owner user[:username]
group user[:username]
mode 0755
-
+
hosts = @node[:mongo_utility_instances].select { |instance| instance[:name].match(/#{mongo_app_name}/) }.map { |instance| [ instance[:hostname], @node[:mongo_port].to_i ] }
replica_set = @node[:mongo_utility_instances].any? { |instance| instance[:name].match(/^mongodb_repl/) }
if replica_set
View
0  ...mongodb/templates/default/mongoid.yml.erb → ...godb/templates/default/mongoid_v2.yml.erb
File renamed without changes
View
12 cookbooks/mongodb/templates/default/mongoid_v3.yml.erb
@@ -0,0 +1,12 @@
+<%= @environment %>:
+ sessions:
+ default:
+ hosts:
+ <% @hosts.each do |host, port| -%>
+ - <%= host %>:<%= port %>
+ <% end -%>
+ database: <%=@mongo_replsetname%>
+ # Mongoid specific configuration options
+ options:
+ consistency: :eventual
+ max_retries_on_connection_failure: 5
Please sign in to comment.
Something went wrong with that request. Please try again.