capistrano-rack 0.1.0 → 0.2.0
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.
- checksums.yaml +4 -4
- data/Gemfile +0 -1
- data/Gemfile.lock +2 -2
- data/README.md +58 -8
- data/lib/capistrano/rack.rb +47 -29
- data/lib/capistrano/rack/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3e6f3618f6ffe51d2586c8bf09c98039c984acd2
|
4
|
+
data.tar.gz: 6cc80001f2afaf300a60e198b9466ab786921c5b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6655301c242d37ac5ab2fcb22bd839592161a16c379f8eee9837e643c6473ccc22556b049ba80721080e96737d59df045601f17078aebadeec9d484dcaac118e
|
7
|
+
data.tar.gz: 3a1a98c0052f14a75fa0a7d687160e8a0c1780045b55f26b828b7d7695dc72a4045117c1e2ee659128d8d52c697d72316c5a65bc2682d0b9921edc43ef64e523
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
capistrano-rack (0.
|
4
|
+
capistrano-rack (0.2.0)
|
5
5
|
capistrano (~> 3.4, >= 3.0.0)
|
6
6
|
fog (~> 1.35)
|
7
7
|
|
@@ -45,7 +45,7 @@ GEM
|
|
45
45
|
fog-xml (~> 0.1.1)
|
46
46
|
ipaddress (~> 0.5)
|
47
47
|
nokogiri
|
48
|
-
fog-aliyun (0.0
|
48
|
+
fog-aliyun (0.1.0)
|
49
49
|
fog-core (~> 1.27)
|
50
50
|
fog-json (~> 1.0)
|
51
51
|
ipaddress (~> 0.8)
|
data/README.md
CHANGED
@@ -18,7 +18,7 @@ require 'capistrano/rack'
|
|
18
18
|
|
19
19
|
And then execute:
|
20
20
|
|
21
|
-
|
21
|
+
$ bundle && bundle exec rake
|
22
22
|
|
23
23
|
Make sure to have a `~/.rack/config` in your `$HOME` directory with these properties:
|
24
24
|
|
@@ -32,25 +32,75 @@ If you are already a [**Rackspace CLI**](https://developer.rackspace.com/docs/ra
|
|
32
32
|
|
33
33
|
## Usage
|
34
34
|
|
35
|
-
|
35
|
+
`capistrano-rack` recipe supports two Rackspace Cloud services:
|
36
|
+
|
37
|
+
### Next Generation Cloud Servers™
|
38
|
+
|
39
|
+
To deploy to your Next Gen Cloud servers:
|
36
40
|
|
37
41
|
```ruby
|
38
|
-
rackspace_servers(
|
42
|
+
rackspace_servers(roles=[], regex_str='^myservers-', addr_type=:private, config_file=nil, connection_options={})
|
39
43
|
```
|
40
44
|
|
41
|
-
|
45
|
+
Where:
|
46
|
+
* `roles`: your [Capistrano Roles](http://capistranorb.com/).
|
47
|
+
* `regex_str`: a regular expression to filter throught your Next Gen Cloud servers.
|
48
|
+
* `addr_type`: type of IP addresses (`:public` or `:private`).
|
49
|
+
* `config_file`: Rackspace configuration file.
|
50
|
+
* `connection_options`: Optional connection parameters.
|
51
|
+
|
52
|
+
### Auto Scale
|
42
53
|
|
43
|
-
|
54
|
+
To deploy to your Scaling Group:
|
44
55
|
|
45
56
|
```ruby
|
46
|
-
|
57
|
+
rackspace_autoscale(roles=[], group_name='', addr_type=:private, config_file=nil, connection_options={})
|
47
58
|
```
|
48
59
|
|
60
|
+
Where:
|
61
|
+
* `roles`: your [Capistrano Roles](http://capistranorb.com/).
|
62
|
+
* `group_name`: Name of your Scaling Group.
|
63
|
+
* `addr_type`: type of IP addresses (`:public` or `:private`).
|
64
|
+
* `config_file`: Rackspace configuration file.
|
65
|
+
* `connection_options`: Optional connection parameters.
|
66
|
+
|
67
|
+
### Optional Connection Parameters
|
68
|
+
|
69
|
+
<table>
|
70
|
+
<tr><th>Key</th><th>Description</th></tr>
|
71
|
+
<tr>
|
72
|
+
<td>:connect_timeout</td>
|
73
|
+
<td>Connection timeout (default: 60 seconds)</td>
|
74
|
+
</tr>
|
75
|
+
<tr>
|
76
|
+
<td>:read_timeout</td>
|
77
|
+
<td>Read timeout for connection (default: 60 seconds)</td> </tr>
|
78
|
+
<tr>
|
79
|
+
<td>:write_timeout</td>
|
80
|
+
<td>Write timeout for connection (default: 60 seconds)</td>
|
81
|
+
</tr>
|
82
|
+
<tr>
|
83
|
+
<td>:proxy</td>
|
84
|
+
<td>Proxy for HTTP and HTTPS connections</td>
|
85
|
+
</tr>
|
86
|
+
<tr>
|
87
|
+
<td>:ssl_ca_path</td>
|
88
|
+
<td>Path to SSL certificate authorities</td>
|
89
|
+
</tr>
|
90
|
+
<tr>
|
91
|
+
<td>:ssl_ca_file</td>
|
92
|
+
<td>SSL certificate authority file</td>
|
93
|
+
</tr>
|
94
|
+
<tr>
|
95
|
+
<td>:ssl_verify_peer</td>
|
96
|
+
<td>SSL verify peer (default: true)</td>
|
97
|
+
</tr>
|
98
|
+
</table>
|
99
|
+
|
49
100
|
## Contributing
|
50
101
|
|
51
102
|
Bug reports and pull requests are welcome. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
|
52
103
|
|
53
|
-
|
54
104
|
## License
|
55
105
|
|
56
|
-
|
106
|
+
This gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/lib/capistrano/rack.rb
CHANGED
@@ -3,9 +3,6 @@ require 'fog'
|
|
3
3
|
require 'capistrano'
|
4
4
|
require 'capistrano/rack/version'
|
5
5
|
|
6
|
-
#
|
7
|
-
# Properties Reader
|
8
|
-
#
|
9
6
|
class PropertiesReader
|
10
7
|
def initialize(file)
|
11
8
|
@file = file
|
@@ -27,35 +24,56 @@ class PropertiesReader
|
|
27
24
|
|
28
25
|
end
|
29
26
|
|
27
|
+
class RackspaceOptions
|
28
|
+
def self.get(config_file=nil)
|
29
|
+
props_reader = PropertiesReader.new(config_file || "#{ENV['HOME']}/.rack/config")
|
30
|
+
return {
|
31
|
+
:rackspace_api_key => props_reader.get("api-key"),
|
32
|
+
:rackspace_username => props_reader.get("username"),
|
33
|
+
:rackspace_region => props_reader.get("region")
|
34
|
+
}
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
30
38
|
module Capistrano
|
31
39
|
module Rack
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
{
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
# Iterate over the list of private IP addresses
|
54
|
-
rackspace_server['addresses']['private'].select do |private_addr|
|
55
|
-
server (private_addr['addr']), %w{role || :app}
|
56
|
-
end
|
57
|
-
end
|
40
|
+
def rackspace_servers(roles=[], regex_str='', addr_type=:private, config_file=nil, connection_options={})
|
41
|
+
@compute_service = Fog::Compute.new(RackspaceOptions.get(config_file)
|
42
|
+
.merge({
|
43
|
+
:provider => 'Rackspace',
|
44
|
+
:version => :v2,
|
45
|
+
:connection_options => connection_options
|
46
|
+
}))
|
47
|
+
# List all servers and filter them based on the passed 'regex_str' parameter
|
48
|
+
@compute_service.list_servers.body['servers']
|
49
|
+
.select { |server| !server['name'].match(/#{regex_str}/).nil? }
|
50
|
+
.flat_map { |s| s["addresses"][addr_type.to_s] }
|
51
|
+
.select { |iface| iface['version'] == 4 }
|
52
|
+
.map { |iface| iface['addr'] }
|
53
|
+
.each { |server_addr| server (server_addr), roles || %w{:app} }
|
54
|
+
end
|
55
|
+
|
56
|
+
def rackspace_autoscale(roles=[], group_name='', addr_type=:private, config_file=nil, connection_options={})
|
57
|
+
rackspace_options = RackspaceOptions.get(config_file)
|
58
|
+
|
59
|
+
if !connection_options.empty? then
|
60
|
+
rackspace_options.merge!({:connection_options => connection_options})
|
58
61
|
end
|
62
|
+
|
63
|
+
@compute_service = Fog::Compute.new(rackspace_options.merge({
|
64
|
+
:provider => 'Rackspace',
|
65
|
+
:version => :v2
|
66
|
+
}))
|
67
|
+
@autoscale_service = Fog::Rackspace::AutoScale.new(rackspace_options)
|
68
|
+
|
69
|
+
# Get the servers Ids inside the specified group name
|
70
|
+
@autoscale_service.groups.find { |g| g.group_config.name == group_name }.state['active']
|
71
|
+
.map { |server| server['id'] }
|
72
|
+
.map { |id| @compute_service.servers.get id }
|
73
|
+
.flat_map { |h| h.addresses[addr_type.to_s] }
|
74
|
+
.select { |iface| iface['version'] == 4 }
|
75
|
+
.map { |iface| iface['addr'] }
|
76
|
+
.each { |server_addr| server (server_addr), roles || %w{:app} }
|
59
77
|
end
|
60
78
|
|
61
79
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capistrano-rack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Faissal Elamraoui
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-11-
|
11
|
+
date: 2015-11-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capistrano
|