capistrano-rackspace 0.0.6
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 +7 -0
- data/.gitignore +1 -0
- data/Gemfile +4 -0
- data/README.md +37 -0
- data/Rakefile +1 -0
- data/capistrano-rackspace.gemspec +20 -0
- data/lib/capistrano/rackspace/version.rb +5 -0
- data/lib/capistrano/rackspace.rb +77 -0
- data/lib/capistrano-rackspace.rb +0 -0
- metadata +68 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: ee2cd1ae05e10a3d1bf9f027fcadf914516debbb
|
|
4
|
+
data.tar.gz: 2402a776b739faaa87ee5d3adf4120457d29cb60
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 6cc984a3e93bee29f2d11b6fbafd8445ee9bee0c4dce2fcb2991cb7cc4b3562340353ff1c7f51319d6bd3efecd5e27c7fa5e3fa939a28aa9f52dc4960a57dae6
|
|
7
|
+
data.tar.gz: ed55e5e23234604ac748115c7299e66a67e7c18224c38000a441298e2d9fe10b3fd669d8bfa796f0b62e1cb3c3194ea54d14cee003108631a01e6005591ade38
|
data/.gitignore
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Gemfile.lock
|
data/Gemfile
ADDED
data/README.md
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Capistrano::Rackspace
|
|
2
|
+
|
|
3
|
+
A Capistrano 3.x plugin that provides dynamic configuration via the Rackspace API
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
gem 'capistrano-rackspace'
|
|
8
|
+
gem 'capistrano'
|
|
9
|
+
|
|
10
|
+
And then execute
|
|
11
|
+
|
|
12
|
+
bundle install
|
|
13
|
+
|
|
14
|
+
## Usage
|
|
15
|
+
|
|
16
|
+
Require in `Capfile` to use
|
|
17
|
+
|
|
18
|
+
```ruby
|
|
19
|
+
require 'capistrano/rackspace'
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
You can then use the Rackspace functionality in the deploy/environment files
|
|
23
|
+
|
|
24
|
+
```ruby
|
|
25
|
+
Rackspace::Configuration.username = 'substitute.rackspace.username'
|
|
26
|
+
Rackspace::Configuration.api_key = 'substitute.rackspace.api.key'
|
|
27
|
+
Rackspace::Configuration.region = :ord
|
|
28
|
+
Rackspace::Configuration.autoscale_group = "AUTOSCALE-GROUP-NAME"
|
|
29
|
+
|
|
30
|
+
autoscale = Rackspace::AutoScale.new
|
|
31
|
+
|
|
32
|
+
role :app, %w{deploy@standalone-server} + autoscale.addresses
|
|
33
|
+
role :web, %w{deploy@standalone-server} + autoscale.addresses
|
|
34
|
+
role :db, %w{deploy@standalone-server}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
alternatively you can use `autoscale.private_addresses`, if you need the internal addresses.
|
data/Rakefile
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require 'bundler/gem_tasks'
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |gem|
|
|
6
|
+
gem.name = 'capistrano-rackspace'
|
|
7
|
+
gem.version = '0.0.6'
|
|
8
|
+
gem.date = '2015-03-09'
|
|
9
|
+
gem.summary = 'Capistrano Rackspace Autoscale Helper'
|
|
10
|
+
gem.description = 'If you use Rackspace Autoscale and want to find out which server'
|
|
11
|
+
gem.authors = ['Chris Kruger', 'Damien Dormal']
|
|
12
|
+
gem.email = ['chris.kruger+gemname@krugerheavyindustries.com', 'dormal.damien@gmail.com']
|
|
13
|
+
gem.homepage = 'https://github.com/damsonn/capistrano-rackspace'
|
|
14
|
+
gem.license = 'MIT'
|
|
15
|
+
|
|
16
|
+
gem.files = `git ls-files`.split($/)
|
|
17
|
+
gem.require_paths = ['lib']
|
|
18
|
+
|
|
19
|
+
gem.add_dependency 'fog', '~> 1.32'
|
|
20
|
+
end
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
require 'fog'
|
|
2
|
+
|
|
3
|
+
class Rackspace
|
|
4
|
+
|
|
5
|
+
class Configuration
|
|
6
|
+
|
|
7
|
+
class << self
|
|
8
|
+
attr_accessor :username
|
|
9
|
+
attr_accessor :api_key
|
|
10
|
+
attr_accessor :region
|
|
11
|
+
attr_accessor :autoscale_group
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
attr_reader :autoscale_group
|
|
15
|
+
|
|
16
|
+
def self.instantiate
|
|
17
|
+
new(
|
|
18
|
+
:username => username,
|
|
19
|
+
:api_key => api_key,
|
|
20
|
+
:region => region,
|
|
21
|
+
:autoscale_group => autoscale_group
|
|
22
|
+
)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def initialize(options = {})
|
|
26
|
+
[ :username, :api_key, :region, :autoscale_group ].each do |attr|
|
|
27
|
+
instance_variable_set "@#{attr}", options[attr]
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def common
|
|
32
|
+
{
|
|
33
|
+
:rackspace_username => @username,
|
|
34
|
+
:rackspace_api_key => @api_key,
|
|
35
|
+
:rackspace_region => @region
|
|
36
|
+
}
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def compute
|
|
40
|
+
common.merge(:provider => 'Rackspace', :version => :v2)
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
class AutoScale
|
|
45
|
+
|
|
46
|
+
def initialize
|
|
47
|
+
@config = Configuration.instantiate
|
|
48
|
+
@autoscale_service = Fog::Rackspace::AutoScale.new(@config.common)
|
|
49
|
+
@compute_service = Fog::Compute.new(@config.compute)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def addresses
|
|
53
|
+
@server_addresses_public ||= addresses_by_type('public')
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def private_addresses
|
|
57
|
+
@server_addresses_private ||= addresses_by_type('private')
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
private
|
|
61
|
+
|
|
62
|
+
def addresses_by_type(type)
|
|
63
|
+
server_ids.map { |id| @compute_service.servers.get id }
|
|
64
|
+
.flat_map { |h| h.addresses[type] } # only the type we want (private|public)
|
|
65
|
+
.select { |iface| iface['version'] == 4 }
|
|
66
|
+
.map { |iface| iface["addr"] }
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def server_ids
|
|
70
|
+
@autoscale_service.groups
|
|
71
|
+
.find { |g| g.group_config.name == @config.autoscale_group }
|
|
72
|
+
.state['active']
|
|
73
|
+
.map { |h| h['id'] }
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
end
|
|
File without changes
|
metadata
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: capistrano-rackspace
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.6
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Chris Kruger
|
|
8
|
+
- Damien Dormal
|
|
9
|
+
autorequire:
|
|
10
|
+
bindir: bin
|
|
11
|
+
cert_chain: []
|
|
12
|
+
date: 2015-03-09 00:00:00.000000000 Z
|
|
13
|
+
dependencies:
|
|
14
|
+
- !ruby/object:Gem::Dependency
|
|
15
|
+
name: fog
|
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
|
17
|
+
requirements:
|
|
18
|
+
- - "~>"
|
|
19
|
+
- !ruby/object:Gem::Version
|
|
20
|
+
version: '1.32'
|
|
21
|
+
type: :runtime
|
|
22
|
+
prerelease: false
|
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
24
|
+
requirements:
|
|
25
|
+
- - "~>"
|
|
26
|
+
- !ruby/object:Gem::Version
|
|
27
|
+
version: '1.32'
|
|
28
|
+
description: If you use Rackspace Autoscale and want to find out which server
|
|
29
|
+
email:
|
|
30
|
+
- chris.kruger+gemname@krugerheavyindustries.com
|
|
31
|
+
- dormal.damien@gmail.com
|
|
32
|
+
executables: []
|
|
33
|
+
extensions: []
|
|
34
|
+
extra_rdoc_files: []
|
|
35
|
+
files:
|
|
36
|
+
- ".gitignore"
|
|
37
|
+
- Gemfile
|
|
38
|
+
- README.md
|
|
39
|
+
- Rakefile
|
|
40
|
+
- capistrano-rackspace.gemspec
|
|
41
|
+
- lib/capistrano-rackspace.rb
|
|
42
|
+
- lib/capistrano/rackspace.rb
|
|
43
|
+
- lib/capistrano/rackspace/version.rb
|
|
44
|
+
homepage: https://github.com/damsonn/capistrano-rackspace
|
|
45
|
+
licenses:
|
|
46
|
+
- MIT
|
|
47
|
+
metadata: {}
|
|
48
|
+
post_install_message:
|
|
49
|
+
rdoc_options: []
|
|
50
|
+
require_paths:
|
|
51
|
+
- lib
|
|
52
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
53
|
+
requirements:
|
|
54
|
+
- - ">="
|
|
55
|
+
- !ruby/object:Gem::Version
|
|
56
|
+
version: '0'
|
|
57
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - ">="
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '0'
|
|
62
|
+
requirements: []
|
|
63
|
+
rubyforge_project:
|
|
64
|
+
rubygems_version: 2.4.6
|
|
65
|
+
signing_key:
|
|
66
|
+
specification_version: 4
|
|
67
|
+
summary: Capistrano Rackspace Autoscale Helper
|
|
68
|
+
test_files: []
|