Skip to content

Commit

Permalink
Merge pull request #9 from Viximo/feature/default-roles
Browse files Browse the repository at this point in the history
Allow default cluster/facet roles to be overridden
  • Loading branch information
howech committed May 16, 2011
2 parents b7d214d + 2c5ab7b commit 98e5e3d
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions lib/cluster_chef/compute.rb
Expand Up @@ -115,10 +115,13 @@ def setup_role_implications
#
class Cluster < ClusterChef::ComputeBuilder
attr_reader :facets
has_keys :cluster_role

def initialize clname
super(clname)
@facets = {}
chef_attributes :cluster_name => clname
cluster_role "#{clname}_cluster"
end

def facet facet_name, &block
Expand All @@ -143,15 +146,15 @@ def merge! other_cluster

class Facet < ClusterChef::ComputeBuilder
attr_reader :cluster
has_keys :chef_node_name, :instances, :facet_index
has_keys :chef_node_name, :instances, :facet_index, :facet_role

def initialize cluster, facet_name
super(facet_name)
@cluster = cluster
chef_attributes :cluster_role => facet_name # backwards compatibility
chef_attributes :facet_name => facet_name
role "#{@cluster.name}_cluster"
role "#{@cluster.name}_#{facet_name}"
facet_role "#{@cluster.name}_#{facet_name}"

unless facet_index.blank?
chef_node_name "#{@cluster.name}-#{facet_name}-#{facet_index}"
chef_attributes :node_name => chef_node_name
Expand All @@ -174,6 +177,10 @@ def resolve!
cloud.keypair clname if cloud.keypair.blank?
cloud.security_group clname do authorize_group clname end
cloud.security_group "#{clname}-#{self.name}"

role cluster.cluster_role if cluster.cluster_role
role self.facet_role if self.facet_role

@settings[:run_list] = @cluster.run_list + self.run_list
@settings[:chef_attributes] = @cluster.chef_attributes.merge(self.chef_attributes)
chef_attributes :run_list => run_list
Expand Down

0 comments on commit 98e5e3d

Please sign in to comment.