engineyard-metadata 0.2.4 → 0.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.document +1 -1
- data/.gitignore +3 -1
- data/Gemfile +5 -0
- data/{README.rdoc → README.markdown} +81 -72
- data/Rakefile +2 -9
- data/engineyard-metadata.gemspec +0 -3
- data/lib/engineyard-metadata/amazon_ec2_api.rb +3 -3
- data/lib/engineyard-metadata/version.rb +1 -1
- data/spec/spec_helper.rb +16 -16
- metadata +10 -43
data/.document
CHANGED
data/.gitignore
CHANGED
data/Gemfile
CHANGED
@@ -1,46 +1,44 @@
|
|
1
|
-
|
1
|
+
# engineyard-metadata
|
2
2
|
|
3
3
|
Presents a simple interface to get metadata about your EngineYard AppCloud instances running on Amazon EC2.
|
4
4
|
|
5
|
-
|
5
|
+
## Purpose
|
6
6
|
|
7
7
|
To define a simple interface to useful metadata (passwords, IP addresses, etc.) that is otherwise buried deep inside EngineYard's chef config files and various API calls.
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
* Get the current database password so that you can write a script that connects to it. (<tt>EY.metadata.database_password</tt>)
|
9
|
+
## Examples
|
12
10
|
|
13
11
|
Here's the current method list:
|
14
12
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
13
|
+
EY.metadata.app_master
|
14
|
+
EY.metadata.app_name
|
15
|
+
EY.metadata.app_servers
|
16
|
+
EY.metadata.app_slaves
|
17
|
+
EY.metadata.current_path
|
18
|
+
EY.metadata.database_host
|
19
|
+
EY.metadata.database_name
|
20
|
+
EY.metadata.database_password (only works from cloud instances)
|
21
|
+
EY.metadata.database_username
|
22
|
+
EY.metadata.db_master
|
23
|
+
EY.metadata.db_servers
|
24
|
+
EY.metadata.db_slaves
|
25
|
+
EY.metadata.environment_name
|
26
|
+
EY.metadata.mysql_command (only works from cloud instances)
|
27
|
+
EY.metadata.mysqldump_command (only works from cloud instances)
|
28
|
+
EY.metadata.present_instance_id (only works from cloud instances)
|
29
|
+
EY.metadata.present_instance_role (only works from cloud instances)
|
30
|
+
EY.metadata.present_public_hostname (only works from cloud instances)
|
31
|
+
EY.metadata.present_security_group (only works from cloud instances)
|
32
|
+
EY.metadata.repository_uri
|
33
|
+
EY.metadata.shared_path
|
34
|
+
EY.metadata.solo
|
35
|
+
EY.metadata.ssh_aliases
|
36
|
+
EY.metadata.ssh_password (only works from cloud instances)
|
37
|
+
EY.metadata.ssh_username
|
38
|
+
EY.metadata.stack_name
|
39
|
+
EY.metadata.utilities
|
40
|
+
|
41
|
+
## public\_hostname, amazon\_id, etc.
|
44
42
|
|
45
43
|
Thanks to Nick Marden, you can do things like:
|
46
44
|
|
@@ -49,11 +47,11 @@ Thanks to Nick Marden, you can do things like:
|
|
49
47
|
|
50
48
|
By default, you get the public hostname.
|
51
49
|
|
52
|
-
|
50
|
+
## Use
|
53
51
|
|
54
|
-
See the
|
52
|
+
See the documentation at (the engineyard-metadata documentation}[http://rubydoc.info/gems/engineyard-metadata].
|
55
53
|
|
56
|
-
|
54
|
+
### When you're executing this gem from INSIDE the cloud
|
57
55
|
|
58
56
|
When you're executing the gem from your instances, you don't have to configure anything. Just require the gem.
|
59
57
|
|
@@ -67,56 +65,67 @@ then I suggest adding something like this to `deploy/before_bundle.rb`
|
|
67
65
|
|
68
66
|
or find some other way to make the file readable.
|
69
67
|
|
70
|
-
|
68
|
+
The Engine Yard recipes will often reset the permissions on the file, so you can periodically fix that using
|
69
|
+
a custom chef recipe like this:
|
70
|
+
|
71
|
+
# Only run on app server instances.
|
72
|
+
if ['app','app_master'].include?(node[:instance_role]) then
|
73
|
+
cron "Make /etc/chef/dna.json readable" do
|
74
|
+
minute "*/5"
|
75
|
+
command "chmod a+r /etc/chef/dna.json"
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
### When you're executing this gem from OUTSIDE the cloud
|
71
80
|
|
72
81
|
You must...
|
73
82
|
|
74
|
-
* have
|
75
|
-
* execute the gem from the local copy of your application's repo or set
|
83
|
+
* have `~/.eyrc` or set `EY.metadata.ey_cloud_token=` or set `ENV['EY_CLOUD_TOKEN']`.
|
84
|
+
* execute the gem from the local copy of your application's repo or set `EY.metadata.environment_name=` or set `ENV['EY_ENVIRONMENT_NAME']`.
|
76
85
|
|
77
|
-
|
86
|
+
### Where the methods are defined
|
78
87
|
|
79
|
-
Metadata getters are defined directly on
|
88
|
+
Metadata getters are defined directly on `EY.metadata` (which in turn delegates out to various adapters). Even if EngineYard changes the structure of the config files or Amazon EC2's API changes, these methods will stay the same.
|
80
89
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
90
|
+
[...]
|
91
|
+
>> require 'rubygems'
|
92
|
+
[...]
|
93
|
+
>> require 'engineyard-metadata'
|
94
|
+
[...]
|
95
|
+
>> EY.metadata.database_host
|
96
|
+
=> "external_db_master.compute-1.amazonaws.com"
|
97
|
+
>> EY.metadata.app_servers
|
98
|
+
=> [ 'app_1.compute-1.amazonaws.com' , 'app_master.compute-1.amazonaws.com' ]
|
99
|
+
>> EY.metadata.db_servers
|
100
|
+
=> [ 'db_master.compute-1.amazonaws.com', 'db_slave_1.compute-1.amazonaws.com' ]
|
101
|
+
[...and many more...]
|
93
102
|
|
94
|
-
|
103
|
+
## SSH alias helper
|
95
104
|
|
96
|
-
You can put the output of
|
105
|
+
You can put the output of `ey_ssh_aliases` into `~/.ssh/config`:
|
97
106
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
107
|
+
$ EY_ENVIRONMENT_NAME=my_env ey_ssh_aliases
|
108
|
+
Host my_env-app_master
|
109
|
+
Hostname ec2-11-11-111-11.compute-1.amazonaws.com
|
110
|
+
User deploy
|
111
|
+
StrictHostKeyChecking no
|
103
112
|
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
113
|
+
Host my_env-db_master
|
114
|
+
Hostname ec2-111-11-11-11.compute-1.amazonaws.com
|
115
|
+
User deploy
|
116
|
+
StrictHostKeyChecking no
|
108
117
|
|
109
|
-
|
118
|
+
## Known issues
|
110
119
|
|
111
120
|
* Doesn't work with multiple apps per environment. [FIXED!]
|
112
|
-
* It's not always clear what environment you're running in. For example, you say
|
113
|
-
* There are no factory methods. If we fully fleshed this out, it might be like
|
121
|
+
* It's not always clear what environment you're running in. For example, you say `EY.metadata.something` and you're just supposed to know what environment you're in. You can use `.environment_name=`, but you might not remember.
|
122
|
+
* There are no factory methods. If we fully fleshed this out, it might be like `my_env = EY::Environment.find('my_env')` and `my_app_master = my_env.app_master`. Not sure that complexity would add a lot of value.
|
114
123
|
|
115
|
-
|
124
|
+
## History
|
116
125
|
|
117
126
|
This is the second generation of http://rubygems.org/gems/ey_cloud_awareness.
|
118
127
|
|
119
|
-
|
128
|
+
## Sample test output
|
120
129
|
|
121
130
|
engineyard-metadata (master) $ rake
|
122
131
|
|
@@ -250,6 +259,6 @@ This is the second generation of http://rubygems.org/gems/ey_cloud_awareness.
|
|
250
259
|
Finished in 0.95816 seconds
|
251
260
|
112 examples, 0 failures
|
252
261
|
|
253
|
-
|
262
|
+
## Copyright
|
254
263
|
|
255
|
-
Copyright (c)
|
264
|
+
Copyright (c) 2012 Seamus Abshere. See LICENSE for details.
|
data/Rakefile
CHANGED
@@ -3,15 +3,8 @@ Bundler::GemHelper.install_tasks
|
|
3
3
|
|
4
4
|
require 'rake'
|
5
5
|
|
6
|
-
require '
|
7
|
-
Rake::
|
8
|
-
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
9
|
-
|
10
|
-
rdoc.rdoc_dir = 'rdoc'
|
11
|
-
rdoc.title = "engineyard-metadata #{version}"
|
12
|
-
rdoc.rdoc_files.include('README*')
|
13
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
14
|
-
end
|
6
|
+
require 'yard'
|
7
|
+
YARD::Rake::YardocTask.new
|
15
8
|
|
16
9
|
require 'rspec/core/rake_task'
|
17
10
|
|
data/engineyard-metadata.gemspec
CHANGED
@@ -22,7 +22,4 @@ Gem::Specification.new do |s|
|
|
22
22
|
s.add_dependency 'activesupport', '>=2.3.4'
|
23
23
|
s.add_dependency 'nap', '>=0.4'
|
24
24
|
s.add_dependency 'eat', '>=0.0.5'
|
25
|
-
s.add_development_dependency "fakeweb"
|
26
|
-
s.add_development_dependency "fakefs"
|
27
|
-
s.add_development_dependency "rspec", "~>2"
|
28
25
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'eat'
|
2
2
|
|
3
3
|
module EY
|
4
4
|
class Metadata
|
@@ -6,12 +6,12 @@ module EY
|
|
6
6
|
class AmazonEc2Api
|
7
7
|
# The present instance's Amazon Ec2 instance id.
|
8
8
|
def present_instance_id
|
9
|
-
@present_instance_id ||=
|
9
|
+
@present_instance_id ||= eat('http://169.254.169.254/latest/meta-data/instance-id')
|
10
10
|
end
|
11
11
|
|
12
12
|
# The present instance's Amazon Ec2 security group.
|
13
13
|
def present_security_group
|
14
|
-
@present_security_group ||=
|
14
|
+
@present_security_group ||= eat('http://169.254.169.254/latest/meta-data/security-groups')
|
15
15
|
end
|
16
16
|
end
|
17
17
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -3,7 +3,7 @@ require 'bundler'
|
|
3
3
|
Bundler.setup
|
4
4
|
require 'rspec'
|
5
5
|
require 'active_support/json/encoding'
|
6
|
-
require '
|
6
|
+
require 'webmock/rspec'
|
7
7
|
require 'fakefs/safe'
|
8
8
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
9
9
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
@@ -14,11 +14,11 @@ FAKE_INSTANCE_ID = 'i-ff17d493'
|
|
14
14
|
FAKE_CLOUD_TOKEN = 'justareallygreatsecret'
|
15
15
|
|
16
16
|
def pretend_we_are_on_a_developer_machine
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
17
|
+
WebMock.enable!
|
18
|
+
WebMock.stub_request(:get, "https://cloud.engineyard.com/api/v2/environments").to_return(
|
19
|
+
:status => 200,
|
20
|
+
:body => File.read(File.join(File.dirname(__FILE__), 'support', 'engine_yard_cloud_api_response.json')))
|
21
|
+
|
22
22
|
dot_git_config = File.read File.join(File.dirname(__FILE__), 'support', 'dot.git.config')
|
23
23
|
FakeFS.activate!
|
24
24
|
git_config_path = File.join Dir.pwd, '.git', 'config'
|
@@ -29,18 +29,18 @@ def pretend_we_are_on_a_developer_machine
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def pretend_we_are_on_an_engineyard_appcloud_ec2_instance
|
32
|
-
|
32
|
+
WebMock.enable!
|
33
33
|
# fake call to amazon ec2 api to get present security group
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
34
|
+
WebMock.stub_request(:get, "http://169.254.169.254/latest/meta-data/security-groups").to_return(
|
35
|
+
:status => 200,
|
36
|
+
:body => FAKE_SECURITY_GROUP
|
37
|
+
)
|
38
38
|
|
39
39
|
# fake call to amazon ec2 api to get present instance id
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
40
|
+
WebMock.stub_request(:get, "http://169.254.169.254/latest/meta-data/instance-id").to_return(
|
41
|
+
:status => 200,
|
42
|
+
:body => FAKE_INSTANCE_ID
|
43
|
+
)
|
44
44
|
|
45
45
|
# first read a file from the real file system...
|
46
46
|
dna_json = File.read File.join(File.dirname(__FILE__), 'support', 'dna.json')
|
@@ -57,5 +57,5 @@ def stop_pretending
|
|
57
57
|
# http://lukeredpath.co.uk/blog/using-fakefs-with-cucumber-features.html
|
58
58
|
FakeFS::FileSystem.clear
|
59
59
|
FakeFS.deactivate!
|
60
|
-
|
60
|
+
WebMock.reset!
|
61
61
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: engineyard-metadata
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-02-
|
12
|
+
date: 2012-02-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
16
|
-
requirement: &
|
16
|
+
requirement: &2156735380 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 2.3.4
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2156735380
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: nap
|
27
|
-
requirement: &
|
27
|
+
requirement: &2156734440 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0.4'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *2156734440
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: eat
|
38
|
-
requirement: &
|
38
|
+
requirement: &2156733900 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,40 +43,7 @@ dependencies:
|
|
43
43
|
version: 0.0.5
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
47
|
-
- !ruby/object:Gem::Dependency
|
48
|
-
name: fakeweb
|
49
|
-
requirement: &2153286600 !ruby/object:Gem::Requirement
|
50
|
-
none: false
|
51
|
-
requirements:
|
52
|
-
- - ! '>='
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
55
|
-
type: :development
|
56
|
-
prerelease: false
|
57
|
-
version_requirements: *2153286600
|
58
|
-
- !ruby/object:Gem::Dependency
|
59
|
-
name: fakefs
|
60
|
-
requirement: &2153285120 !ruby/object:Gem::Requirement
|
61
|
-
none: false
|
62
|
-
requirements:
|
63
|
-
- - ! '>='
|
64
|
-
- !ruby/object:Gem::Version
|
65
|
-
version: '0'
|
66
|
-
type: :development
|
67
|
-
prerelease: false
|
68
|
-
version_requirements: *2153285120
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: rspec
|
71
|
-
requirement: &2153283100 !ruby/object:Gem::Requirement
|
72
|
-
none: false
|
73
|
-
requirements:
|
74
|
-
- - ~>
|
75
|
-
- !ruby/object:Gem::Version
|
76
|
-
version: '2'
|
77
|
-
type: :development
|
78
|
-
prerelease: false
|
79
|
-
version_requirements: *2153283100
|
46
|
+
version_requirements: *2156733900
|
80
47
|
description: Pulls metadata from EC2 and EngineYard so that your EngineYard AppCloud
|
81
48
|
(Amazon EC2) instances know about each other.
|
82
49
|
email:
|
@@ -90,7 +57,7 @@ files:
|
|
90
57
|
- .gitignore
|
91
58
|
- Gemfile
|
92
59
|
- LICENSE
|
93
|
-
- README.
|
60
|
+
- README.markdown
|
94
61
|
- Rakefile
|
95
62
|
- bin/ey_ssh_aliases
|
96
63
|
- engineyard-metadata.gemspec
|
@@ -128,7 +95,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
128
95
|
version: '0'
|
129
96
|
requirements: []
|
130
97
|
rubyforge_project: engineyard-metadata
|
131
|
-
rubygems_version: 1.8.
|
98
|
+
rubygems_version: 1.8.15
|
132
99
|
signing_key:
|
133
100
|
specification_version: 3
|
134
101
|
summary: Make your EngineYard AppCloud (Amazon EC2) instances aware of each other.
|