Class: EC2Launcher::DSL::Environment

Inherits:
Object
  • Object
show all
Includes:
EmailNotifications, SecurityGroupHandler
Defined in:
lib/ec2launcher/dsl/environment.rb

Instance Attribute Summary collapse

Attributes included from EmailNotifications

#email_notifications

Class Method Summary collapse

Instance Method Summary collapse

Methods included from SecurityGroupHandler

#security_groups, #security_groups_for_environment

Methods included from EmailNotifications

#email_notification

Constructor Details

#initializeEnvironment

Returns a new instance of Environment.



17
18
19
20
21
22
23
24
25
26
# File 'lib/ec2launcher/dsl/environment.rb', line 17

def initialize()
	@aliases = []
	@email_notifications = nil
	@gems = []
	@packages = []
	@precommands = []
	@postcommands = []
	@roles = []
	@security_groups = {}
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



13
14
15
# File 'lib/ec2launcher/dsl/environment.rb', line 13

def name
  @name
end

#postcommandsObject (readonly)

Returns the value of attribute postcommands.



15
16
17
# File 'lib/ec2launcher/dsl/environment.rb', line 15

def postcommands
  @postcommands
end

#precommandsObject (readonly)

Returns the value of attribute precommands.



14
15
16
# File 'lib/ec2launcher/dsl/environment.rb', line 14

def precommands
  @precommands
end

Class Method Details

.load(dsl) ⇒ Object



251
252
253
254
# File 'lib/ec2launcher/dsl/environment.rb', line 251

def self.load(dsl)
	env = EC2Launcher::DSL::Environment.new.instance_eval(dsl)
	env
end

Instance Method Details

#aliases(*aliases) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
# File 'lib/ec2launcher/dsl/environment.rb', line 43

def aliases(*aliases)
	if aliases.empty?
		@aliases
	else
		if aliases[0].kind_of? String
			@aliases = [ aliases[0] ]
		else
			@aliases = aliases[0]
		end
	end
end

#ami_name(*ami_name) ⇒ Object



55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/ec2launcher/dsl/environment.rb', line 55

def ami_name(*ami_name)
	if ami_name.empty?
		@ami_name
	else
		if ami_name[0].kind_of? String
			@ami_name = /#{ami_name[0]}/
		else
			@ami_name = ami_name[0]
		end
		self
	end
end

#availability_zone(*zone) ⇒ Object



68
69
70
71
72
73
74
75
# File 'lib/ec2launcher/dsl/environment.rb', line 68

def availability_zone(*zone)
	if zone.empty?
		@availability_zone
	else
		@availability_zone = zone[0].to_s
		self
	end
end

#aws_keyfile(*aws_keyfile) ⇒ Object



34
35
36
37
38
39
40
41
# File 'lib/ec2launcher/dsl/environment.rb', line 34

def aws_keyfile(*aws_keyfile)
	if aws_keyfile.empty?
		@aws_keyfile
	else
		@aws_keyfile = aws_keyfile[0]
		self
	end
end

#chef_path(*chef_path) ⇒ Object



129
130
131
132
133
134
135
# File 'lib/ec2launcher/dsl/environment.rb', line 129

def chef_path(*chef_path)
  if chef_path.empty?
    @chef_path
  else
    @chef_path = chef_path[0]
  end
end

#chef_server_url(*server_url) ⇒ Object



77
78
79
80
81
82
83
84
# File 'lib/ec2launcher/dsl/environment.rb', line 77

def chef_server_url(*server_url)
	if server_url.empty?
		@chef_server_url
	else
		@chef_server_url = server_url[0]
		self
	end
end

#chef_validation_pem_url(*chef_validation_pem_url) ⇒ Object



86
87
88
89
90
91
92
93
# File 'lib/ec2launcher/dsl/environment.rb', line 86

def chef_validation_pem_url(*chef_validation_pem_url)
	if chef_validation_pem_url.empty?
		@chef_validation_pem_url
	else
		@chef_validation_pem_url = chef_validation_pem_url[0]
		self
	end
end

#domain_name(*domain_name) ⇒ Object



95
96
97
98
99
100
101
102
# File 'lib/ec2launcher/dsl/environment.rb', line 95

def domain_name(*domain_name)
	if domain_name.empty?
		@domain_name
	else
		@domain_name = domain_name[0]
		self
	end
end

#environment(name) {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:



28
29
30
31
32
# File 'lib/ec2launcher/dsl/environment.rb', line 28

def environment(name)
	@name = name
	yield self
	self
end

#gem_path(*gem_path) ⇒ Object



113
114
115
116
117
118
119
# File 'lib/ec2launcher/dsl/environment.rb', line 113

def gem_path(*gem_path)
  if gem_path.empty?
    @gem_path
  else
    @gem_path = gem_path[0]
  end
end

#gems(*gems) ⇒ Object



104
105
106
107
108
109
110
111
# File 'lib/ec2launcher/dsl/environment.rb', line 104

def gems(*gems)
	if gems.empty?
		@gems
	else
		@gems = gems[0]
		self
	end
end

#inherit(*inherit_type) ⇒ Object



145
146
147
148
149
150
151
# File 'lib/ec2launcher/dsl/environment.rb', line 145

def inherit(*inherit_type)
	if inherit_type.empty?
		@inherit_type
	else
		@inherit_type = inherit_type[0]
	end
end

#key_name(*key) ⇒ Object



153
154
155
156
157
158
159
160
# File 'lib/ec2launcher/dsl/environment.rb', line 153

def key_name(*key)
	if key.empty?
		@key_name
	else
		@key_name = key[0]
		self
	end
end

#knife_path(*knife_path) ⇒ Object



137
138
139
140
141
142
143
# File 'lib/ec2launcher/dsl/environment.rb', line 137

def knife_path(*knife_path)
  if knife_path.empty?
    @knife_path
  else
    @knife_path = knife_path[0]
  end
end

#load(dsl) ⇒ Object



246
247
248
249
# File 'lib/ec2launcher/dsl/environment.rb', line 246

def load(dsl)
	self.instance_eval(dsl)
	self
end

#merge(other_env) ⇒ Object

Takes values from the other environment and merges them into this one



213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
# File 'lib/ec2launcher/dsl/environment.rb', line 213

def merge(other_env)
		@name =other_env.name

		@gems += other_env.gems unless other_env.gems.nil?
		@packages += other_env.packages unless other_env.packages.nil?
		@roles += other_env.roles unless other_env.roles.nil?
		@precommands += other_env.precommands unless other_env.precommands.nil?
		@postcommands += other_env.postcommands unless other_env.postcommands.nil?
		unless other_env.security_groups.nil?
			other_env.security_groups.keys.each do |key|
				@security_groups[key] = [] if @security_groups[key].nil?
				@security_groups[key] += other_env.security_groups[key]
			end
		end

		@aliases = other_env.aliases.nil? ? nil : other_env.aliases

		@ami_name = other_env.ami_name unless other_env.ami_name.nil?
		@aws_keyfile = other_env.aws_keyfile unless other_env.aws_keyfile.nil?
		@availability_zone = other_env.availability_zone unless other_env.availability_zone.nil?
		@chef_path = other_env.chef_path unless other_env.chef_path.nil?
		@chef_server_url = other_env.chef_server_url unless other_env.chef_server_url.nil?
		@chef_validation_pem_url = other_env.chef_validation_pem_url unless other_env.chef_validation_pem_url.nil?
		@domain_name = other_env.domain_name unless other_env.domain_name.nil?
		@email_notifications = other_env.email_notifications unless other_env.email_notifications.nil?
		@gem_path = other_env.gem_path unless other_env.gem_path.nil?
		@key_name = other_env.key_name unless other_env.key_name.nil?
		@knife_path = other_env.knife_path unless other_env.knife_path.nil?
		@ruby_path = other_env.ruby_path unless other_env.ruby_path.nil?
		@subnet = other_env.subnet unless other_env.subnet.nil?
		@short_name = other_env.short_name unless other_env.short_name.nil?
end

#packages(*packages) ⇒ Object



162
163
164
165
166
167
168
169
# File 'lib/ec2launcher/dsl/environment.rb', line 162

def packages(*packages)
	if packages.empty?
		@packages
	else
		@packages = packages[0]
		self
	end
end

#postcommand(*command) ⇒ Object



175
176
177
# File 'lib/ec2launcher/dsl/environment.rb', line 175

def postcommand(*command)
	@postcommands << command[0]
end

#precommand(*command) ⇒ Object



171
172
173
# File 'lib/ec2launcher/dsl/environment.rb', line 171

def precommand(*command)
	@precommands << command[0]
end

#roles(*roles) ⇒ Object



179
180
181
182
183
184
185
186
187
188
189
190
191
192
# File 'lib/ec2launcher/dsl/environment.rb', line 179

def roles(*roles)
	if roles.empty?
		@roles
	else
		@roles = [] if @roles.nil?
		if roles[0].kind_of? Array
			@roles += roles[0]
		else
			@roles = []
			@roles << roles[0]
		end
		self
	end
end

#ruby_path(*ruby_path) ⇒ Object



121
122
123
124
125
126
127
# File 'lib/ec2launcher/dsl/environment.rb', line 121

def ruby_path(*ruby_path)
  if ruby_path.empty?
    @ruby_path
  else
    @ruby_path = ruby_path[0]
  end
end

#short_name(*short_name) ⇒ Object



194
195
196
197
198
199
200
201
# File 'lib/ec2launcher/dsl/environment.rb', line 194

def short_name(*short_name)
	if short_name.empty?
		@short_name
	else
		@short_name = short_name[0]
		self
	end
end

#subnet(*subnet) ⇒ Object



203
204
205
206
207
208
209
210
# File 'lib/ec2launcher/dsl/environment.rb', line 203

def subnet(*subnet)
	if subnet.empty?
		@subnet
	else
		@subnet = subnet[0]
		self
	end
end