Skip to content

Commit

Permalink
Implement attribute to avoid auto assigning the server
Browse files Browse the repository at this point in the history
If the `auto_assign_server` attribute is set to false then the server
auto assign process is skipped on the initial deploy.
  • Loading branch information
Rick Salevsky committed Apr 28, 2015
1 parent ad2b468 commit 8ffbbfc
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 6 deletions.
5 changes: 3 additions & 2 deletions chef/data_bags/crowbar/bc-template-dns.json
Expand Up @@ -7,14 +7,15 @@
"forwarders": [ ],
"allow_transfer": [ ],
"nameservers": [ ],
"records": { }
"records": { },
"auto_assign_server": true
}
},
"deployment": {
"dns": {
"crowbar-revision": 0,
"crowbar-applied": false,
"schema-revision": 3,
"schema-revision": 4,
"element_states": {
"dns-server": [ "readying", "ready", "applying" ],
"dns-client": [ "all" ]
Expand Down
4 changes: 4 additions & 0 deletions chef/data_bags/crowbar/bc-template-dns.schema
Expand Up @@ -44,6 +44,10 @@
}
}
}
},
"auto_assign_server": {
"type": "bool",
"required": false

This comment has been minimized.

Copy link
@rhafer

rhafer Apr 28, 2015

Please make this attribute required.

}
}
}
Expand Down
@@ -0,0 +1,9 @@
def upgrade ta, td, a, d
a['auto_assign_server'] = ta['auto_assign_server']
return a, d
end

def downgrade ta, td, a, d
a.delete('auto_assign_server')
return a, d
end
10 changes: 6 additions & 4 deletions crowbar_framework/app/models/dns_service.rb
Expand Up @@ -71,10 +71,12 @@ def transition(inst, name, state)
db = ProposalObject.find_proposal "dns", inst
role = RoleObject.find_role_by_name "dns-config-#{inst}"

if role.override_attributes["dns"]["elements"]["dns-server"].nil? or
role.override_attributes["dns"]["elements"]["dns-server"].empty?
@logger.debug("DNS transition: adding #{name} to dns-server role")
result = add_role_to_instance_and_node("dns", inst, name, db, role, "dns-server")
if proposal["attributes"]["dns"]["auto_assign_server"] then
if role.override_attributes["dns"]["elements"]["dns-server"].nil? or
role.override_attributes["dns"]["elements"]["dns-server"].empty?
@logger.debug("DNS transition: adding #{name} to dns-server role")
result = add_role_to_instance_and_node("dns", inst, name, db, role, "dns-server")
end
end

# Always add the dns client
Expand Down

0 comments on commit 8ffbbfc

Please sign in to comment.