Module: CapistranoProvisioning::NamespaceExtension
- Defined in:
- lib/capistrano-provisioning/namespaces.rb
Instance Attribute Summary collapse
-
#clusters ⇒ Object
Returns the value of attribute clusters.
Instance Method Summary collapse
- #bootstrap(&block) ⇒ Object
- #cluster(name, *servers) {|block| ... } ⇒ Object
- #default_user_group(group) ⇒ Object
- #default_users(*args) ⇒ Object (also: #default_user)
- #inherit_default_users(*args) ⇒ Object (also: #inherit_default_user)
- #servers(*servers) ⇒ Object (also: #server)
- #unique_name ⇒ Object
- #users(*args) ⇒ Object (also: #user)
Instance Attribute Details
#clusters ⇒ Object
Returns the value of attribute clusters.
4 5 6 |
# File 'lib/capistrano-provisioning/namespaces.rb', line 4 def clusters @clusters end |
Instance Method Details
#bootstrap(&block) ⇒ Object
86 87 88 |
# File 'lib/capistrano-provisioning/namespaces.rb', line 86 def bootstrap(&block) @current_cluster.bootstrap = block end |
#cluster(name, *servers) {|block| ... } ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/capistrano-provisioning/namespaces.rb', line 5 def cluster(name, *servers, &block) # A note on initialising. At the moment I can't figure out how to initialize stuff from this module, # hence the untidy defaulting here. self.clusters ||= {} self.create_namespace_all_task cluster = CapistranoProvisioning::Cluster.new(name, :config => self) self.clusters[cluster.unique_name] = cluster self.clusters[cluster.unique_name].servers = servers return unless block_given? @current_cluster = cluster yield block @current_cluster = nil end |
#default_user_group(group) ⇒ Object
46 47 48 |
# File 'lib/capistrano-provisioning/namespaces.rb', line 46 def default_user_group(group) @user_groups[group] end |
#default_users(*args) ⇒ Object Also known as: default_user
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/capistrano-provisioning/namespaces.rb', line 28 def default_users(*args) return @users || [] if args.empty? name, users, = (args) new_users = users.collect do |user| CapistranoProvisioning::User.new(.merge!(:name => user, :config => self)) end if name @user_groups ||= {} @user_groups[name] = new_users end @users ||= [] @users += new_users end |
#inherit_default_users(*args) ⇒ Object Also known as: inherit_default_user
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/capistrano-provisioning/namespaces.rb', line 50 def inherit_default_users(*args) groups, = (args) [:additional_groups] = [:additional_groups].to_a parent_users = clone_parent_users(groups) if [:additional_groups] parent_users.collect! do |user| user.groups += [:additional_groups] user end end @users ||= [] @users += parent_users end |
#servers(*servers) ⇒ Object Also known as: server
23 24 25 |
# File 'lib/capistrano-provisioning/namespaces.rb', line 23 def servers(*servers) @current_cluster.servers = servers end |
#unique_name ⇒ Object
90 91 92 93 94 95 96 |
# File 'lib/capistrano-provisioning/namespaces.rb', line 90 def unique_name if self.parent.respond_to?(:unique_name) self.parent.unique_name + ":" + self.name.to_s else self.name.to_s end end |
#users(*args) ⇒ Object Also known as: user
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/capistrano-provisioning/namespaces.rb', line 68 def users(*args) users, = (args) users_to_add = users.collect do |user| if user.is_a? Symbol group_users = @current_cluster.config.default_user_group(user).flatten abort "Can't find user group for #{user} (in #{self.name})" unless group_users group_users else user end end users_to_add.flatten! @current_cluster.add_users(users_to_add, ) end |