chef-sugar-rackspace 0.0.2

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 563b9a0e05fb281579b6a97efc1a8ac1ea7717b0
4
+ data.tar.gz: 200cc99a30ce1aa988f720285dc0f634fb777992
5
+ SHA512:
6
+ metadata.gz: cc2410790802709968608bacb103bc6f8e51c8ef835c6438b8fe14766108f1732f9b70bf79765063dd714fa44470b32c71ee3e0844663fa4f27e81abfc1cfc53
7
+ data.tar.gz: 3c234532b82e89fe2d931139ffb224c980dc7e3d16fd6a7c7bfc2c4898266e15c2faded2f09cfc2ad1328b60c48d55d0af7e18a67ed9759a6c05a82564c46226
data/.gitignore ADDED
@@ -0,0 +1,38 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /test/tmp/
9
+ /test/version_tmp/
10
+ /tmp/
11
+
12
+ ## Specific to RubyMotion:
13
+ .dat*
14
+ .repl_history
15
+ build/
16
+
17
+ ## Documentation cache and generated files:
18
+ /.yardoc/
19
+ /_yardoc/
20
+ /doc/
21
+ /rdoc/
22
+
23
+ ## Environment normalisation:
24
+ /.bundle/
25
+ /lib/bundler/man/
26
+
27
+ # for a library or gem, you might want to ignore these files since the code is
28
+ # intended to run in multiple environments; otherwise, check them in:
29
+ # Gemfile.lock
30
+ # .ruby-version
31
+ # .ruby-gemset
32
+
33
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
34
+ .rvmrc
35
+
36
+ ## Chef Ignores
37
+ .kitchen
38
+ Berksfile.lock
data/.kitchen.yml ADDED
@@ -0,0 +1,12 @@
1
+ ---
2
+ driver_plugin: vagrant
3
+
4
+ platforms:
5
+ - name: ubuntu-14.04
6
+ - name: centos-7.0
7
+
8
+ suites:
9
+ - name: default
10
+ run_list:
11
+ - recipe[chef-sugar-rackspace]
12
+ attributes: {}
data/Berksfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://supermarket.getchef.com'
2
+
3
+ metadata
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,125 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ chef-sugar-rackspace (0.0.1)
5
+ chef-sugar (~> 2.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ chef (12.0.3)
11
+ chef-zero (~> 3.2)
12
+ diff-lcs (~> 1.2, >= 1.2.4)
13
+ erubis (~> 2.7)
14
+ ffi-yajl (~> 1.2)
15
+ highline (~> 1.6, >= 1.6.9)
16
+ mixlib-authentication (~> 1.3)
17
+ mixlib-cli (~> 1.4)
18
+ mixlib-config (~> 2.0)
19
+ mixlib-log (~> 1.3)
20
+ mixlib-shellout (>= 2.0.0.rc.0, < 3.0)
21
+ net-ssh (~> 2.6)
22
+ net-ssh-multi (~> 1.1)
23
+ ohai (~> 8.0)
24
+ plist (~> 3.1.0)
25
+ pry (~> 0.9)
26
+ chef-sugar (2.5.0)
27
+ chef-zero (3.2.1)
28
+ ffi-yajl (~> 1.1)
29
+ hashie (~> 2.0)
30
+ mixlib-log (~> 1.3)
31
+ rack
32
+ uuidtools (~> 2.1)
33
+ chefspec (4.2.0)
34
+ chef (>= 11.14)
35
+ fauxhai (~> 2.0)
36
+ rspec (~> 3.0)
37
+ coderay (1.1.0)
38
+ diff-lcs (1.2.5)
39
+ erubis (2.7.0)
40
+ fauxhai (2.3.0)
41
+ net-ssh
42
+ ohai
43
+ ffi (1.9.6)
44
+ ffi-yajl (1.3.1)
45
+ ffi (~> 1.5)
46
+ libyajl2 (~> 1.2)
47
+ hashie (2.1.2)
48
+ highline (1.6.21)
49
+ ipaddress (0.8.0)
50
+ kitchen-vagrant (0.15.0)
51
+ test-kitchen (~> 1.0)
52
+ libyajl2 (1.2.0)
53
+ method_source (0.8.2)
54
+ mime-types (1.25.1)
55
+ mixlib-authentication (1.3.0)
56
+ mixlib-log
57
+ mixlib-cli (1.5.0)
58
+ mixlib-config (2.1.0)
59
+ mixlib-log (1.6.0)
60
+ mixlib-shellout (2.0.1)
61
+ net-dhcp (1.3.2)
62
+ net-scp (1.2.1)
63
+ net-ssh (>= 2.6.5)
64
+ net-ssh (2.9.2)
65
+ net-ssh-gateway (1.2.0)
66
+ net-ssh (>= 2.6.5)
67
+ net-ssh-multi (1.2.0)
68
+ net-ssh (>= 2.6.5)
69
+ net-ssh-gateway (>= 1.2.0)
70
+ ohai (8.0.1)
71
+ ffi (~> 1.9)
72
+ ffi-yajl (~> 1.1)
73
+ ipaddress
74
+ mime-types (~> 1.16)
75
+ mixlib-cli
76
+ mixlib-config (~> 2.0)
77
+ mixlib-log
78
+ mixlib-shellout (~> 2.0)
79
+ net-dhcp
80
+ rake (~> 10.1)
81
+ systemu (~> 2.6.4)
82
+ wmi-lite (~> 1.0)
83
+ plist (3.1.0)
84
+ pry (0.10.1)
85
+ coderay (~> 1.1.0)
86
+ method_source (~> 0.8.1)
87
+ slop (~> 3.4)
88
+ rack (1.6.0)
89
+ rake (10.4.2)
90
+ rspec (3.2.0)
91
+ rspec-core (~> 3.2.0)
92
+ rspec-expectations (~> 3.2.0)
93
+ rspec-mocks (~> 3.2.0)
94
+ rspec-core (3.2.0)
95
+ rspec-support (~> 3.2.0)
96
+ rspec-expectations (3.2.0)
97
+ diff-lcs (>= 1.2.0, < 2.0)
98
+ rspec-support (~> 3.2.0)
99
+ rspec-mocks (3.2.0)
100
+ diff-lcs (>= 1.2.0, < 2.0)
101
+ rspec-support (~> 3.2.0)
102
+ rspec-support (3.2.1)
103
+ safe_yaml (1.0.4)
104
+ slop (3.6.0)
105
+ systemu (2.6.4)
106
+ test-kitchen (1.3.1)
107
+ mixlib-shellout (>= 1.2, < 3.0)
108
+ net-scp (~> 1.1)
109
+ net-ssh (~> 2.7)
110
+ safe_yaml (~> 1.0)
111
+ thor (~> 0.18)
112
+ thor (0.19.1)
113
+ uuidtools (2.1.5)
114
+ wmi-lite (1.0.0)
115
+
116
+ PLATFORMS
117
+ ruby
118
+
119
+ DEPENDENCIES
120
+ bundler (~> 1.3)
121
+ chef-sugar-rackspace!
122
+ chefspec (~> 4.2)
123
+ kitchen-vagrant (~> 0.15)
124
+ rake
125
+ test-kitchen (~> 1.3)
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Jim Rosser
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
data/README.md ADDED
@@ -0,0 +1,3 @@
1
+ chef-sugar-rackspace
2
+ ====================
3
+ Chef Sugar Extensions useful if you use Rackspace as a provider
data/Rakefile ADDED
@@ -0,0 +1,11 @@
1
+ require 'bundler/gem_tasks'
2
+
3
+ require 'rspec/core/rake_task'
4
+ RSpec::Core::RakeTask.new do |t|
5
+ t.rspec_opts = [
6
+ '--color',
7
+ '--format progress',
8
+ ].join(' ')
9
+ end
10
+
11
+ task default: :spec
@@ -0,0 +1,32 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'chef/sugar/rackspace/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'chef-sugar-rackspace'
8
+ spec.version = Chef::Sugar::Rackspace::VERSION
9
+ spec.authors = ['Jim Rosser']
10
+ spec.email = ['jarosser06@gmail.com']
11
+ spec.description = 'An extension to the "chef-sugar" gem with rackspace' \
12
+ ' specific helpers.'
13
+ spec.summary = 'A collection of helper methods and modules, extending' \
14
+ ' the helper methods available in the "chef-sugar" gem' \
15
+ ' for Rackspace.'
16
+ spec.homepage = 'https://github.com/jarosser06/chef-sugar-rackspace'
17
+ spec.license = 'MIT'
18
+
19
+ spec.required_ruby_version = '>= 1.9'
20
+
21
+ spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
22
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
23
+ spec.require_paths = %w(lib)
24
+
25
+ spec.add_runtime_dependency 'chef-sugar', '~> 2.0'
26
+
27
+ spec.add_development_dependency 'rake'
28
+ spec.add_development_dependency 'bundler', '~> 1.3'
29
+ spec.add_development_dependency 'chefspec', '~> 4.2'
30
+ spec.add_development_dependency 'test-kitchen', '~> 1.3'
31
+ spec.add_development_dependency 'kitchen-vagrant', '~> 0.15'
32
+ end
@@ -0,0 +1,7 @@
1
+ class Chef
2
+ module Sugar
3
+ require_relative 'rackspace/ip'
4
+ end
5
+ end
6
+
7
+ require 'chef/sugar'
@@ -0,0 +1,71 @@
1
+ require 'chef/sugar'
2
+
3
+ class Chef
4
+ module Sugar
5
+ module IP
6
+ extend self
7
+
8
+ ## Returns the cloud network ip for the node,
9
+ ## if no label is passed and more than one cloud
10
+ ## network is attached it will pop the first off
11
+ ## the array
12
+ def cloud_network_ip(node, label=nil)
13
+ networks = cloud_networks(node)
14
+ return '' if networks.empty?
15
+
16
+ net = nil
17
+ if label.nil?
18
+ net = networks[networks.flatten.first]
19
+ else
20
+ net = networks[label]
21
+ end
22
+
23
+ ## Return the first ip address in ips
24
+ return net['ips'].pop['ip']
25
+ end
26
+
27
+ def best_rackspace_ip_for(node, other)
28
+ begin
29
+ ## Fail early if either node has no cloud networks
30
+ node_clnet = cloud_networks(node)
31
+ fail if node_clnet.empty?
32
+
33
+ other_clnet = cloud_networks(other)
34
+ fail if other_clnet.empty?
35
+
36
+ ip = nil
37
+ node_clnet.each_key do |node_label|
38
+ other_clnet.each_key do |other_label|
39
+ if node_label == other_label
40
+ ip = other_clnet[node_label]['ips'].pop['ip']
41
+ end
42
+ end
43
+ end
44
+
45
+ # Couldn't locate a matching cloud network, falling through
46
+ fail if ip.nil?
47
+
48
+ return ip
49
+ rescue
50
+ best_ip_for(node, other)
51
+ end
52
+ end
53
+
54
+ def cloud_networks(node)
55
+ networks = {}
56
+ return networks unless node.has_key? 'rackspace'
57
+ if node['rackspace'].has_key? 'private_networks'
58
+ private_networks = node['rackspace']['private_networks']
59
+
60
+ unless private_networks.nil? || private_networks.empty?
61
+ private_networks.each do |net|
62
+ networks[net['label']] = net
63
+ end
64
+ end
65
+ end
66
+
67
+ return networks
68
+ end
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,7 @@
1
+ class Chef
2
+ module Sugar
3
+ module Rackspace
4
+ VERSION = '0.0.2'
5
+ end
6
+ end
7
+ end
data/metadata.rb ADDED
@@ -0,0 +1,8 @@
1
+ name 'chef-sugar-rackspace'
2
+ maintainer 'Jim Rosser'
3
+ maintainer_email 'jarosser06@gmail.com'
4
+ license 'MIT'
5
+ description 'Installs the chef-sugar-rackspace gem'
6
+ long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
7
+ require File.expand_path('../lib/chef/sugar/rackspace/version', __FILE__)
8
+ version Chef::Sugar::Rackspace::VERSION
@@ -0,0 +1,15 @@
1
+ #
2
+ # Cookbook Name:: chef-sugar-rackspace
3
+ # Recipe:: default
4
+ #
5
+ # Copyright 2015, Jim Rosser <jarosser06@gmail.com>
6
+ #
7
+
8
+ gem_version = run_context.cookbook_collection[cookbook_name].metadata.version
9
+
10
+ chef_gem('chef-sugar-rackspace') do
11
+ version gem_version
12
+ action :nothing
13
+ end.run_action(:install)
14
+
15
+ require 'chef/sugar/rackspace'
@@ -0,0 +1,14 @@
1
+ require 'rspec'
2
+ require 'chefspec'
3
+ require 'chef/sugar/rackspace'
4
+
5
+ RSpec.configure do |config|
6
+ config.expect_with :rspec do |spec|
7
+ spec.syntax = :expect
8
+ end
9
+
10
+ config.filter_run(focus: true)
11
+ config.run_all_when_everything_filtered = true
12
+
13
+ config.log_level = :fatal
14
+ end
@@ -0,0 +1,75 @@
1
+ require 'spec_helper'
2
+
3
+ describe Chef::Sugar::IP do
4
+
5
+ fake_node = {
6
+ 'cloud' => {
7
+ 'public_ipv4' => '23.253.110.230',
8
+ 'local_ipv4' => '10.208.164.3',
9
+ 'provider' => 'rackspace'
10
+ },
11
+ 'rackspace' => {},
12
+ 'ipaddress' => '23.253.110.230'
13
+ }
14
+
15
+ fake_other = {
16
+ 'cloud' => {
17
+ 'public_ipv4' => '23.253.110.240',
18
+ 'local_ipv4' => '10.208.160.3',
19
+ 'provider' => 'rackspace'
20
+ },
21
+ 'rackspace' => {},
22
+ 'ipaddress' => '23.253.110.240'
23
+ }
24
+
25
+ let(:node) { fake_node }
26
+ let(:other) { fake_other }
27
+
28
+ context 'when not on a cloud network' do
29
+ it '#best_rackspace_ip_for returns the service net ip address' do
30
+ expect(described_class.best_rackspace_ip_for(node, other)).to eq(other['cloud']['local_ipv4'])
31
+ end
32
+
33
+ it '#cloud_network_ip returns empty string' do
34
+ expect(described_class.cloud_network_ip(node)).to eq('')
35
+ end
36
+ end
37
+
38
+ context 'when on different cloud networks' do
39
+ before do
40
+ node['rackspace']['private_networks'] = [{
41
+ 'ips' => [{ 'ip' => '192.168.10.2' }],
42
+ 'label' => 'myprivatenet1'
43
+ }]
44
+
45
+ other['rackspace']['private_networks'] = [{
46
+ 'ips' => [{ 'ip' => '192.168.12.4' }],
47
+ 'label' => 'myprivatenet2'
48
+ }]
49
+ end
50
+ it '#best_rackspace_ip_for returns the service net ip address' do
51
+ expect(described_class.best_rackspace_ip_for(node, other)).to eq(other['cloud']['local_ipv4'])
52
+ end
53
+
54
+ it '#cloud_network_ip returns the ip address from the cloud network' do
55
+ expect(described_class.cloud_network_ip(node)).to eq('192.168.10.2')
56
+ end
57
+ end
58
+
59
+ context 'when on the same cloud network' do
60
+ before do
61
+ node['rackspace']['private_networks'] = [{
62
+ 'ips' => [{ 'ip' => '192.168.10.2' }],
63
+ 'label' => 'myprivatenet1'
64
+ }]
65
+
66
+ other['rackspace']['private_networks'] = [{
67
+ 'ips' => [{ 'ip' => '192.168.10.4' }],
68
+ 'label' => 'myprivatenet1'
69
+ }]
70
+ end
71
+ it '#best_rackspace_ip_for returns other\'s cloud network ip address' do
72
+ expect(described_class.best_rackspace_ip_for(node, other)).to eq('192.168.10.4')
73
+ end
74
+ end
75
+ end
metadata ADDED
@@ -0,0 +1,148 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: chef-sugar-rackspace
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Jim Rosser
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-02-14 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: chef-sugar
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.3'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: chefspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '4.2'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '4.2'
69
+ - !ruby/object:Gem::Dependency
70
+ name: test-kitchen
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.3'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.3'
83
+ - !ruby/object:Gem::Dependency
84
+ name: kitchen-vagrant
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0.15'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0.15'
97
+ description: An extension to the "chef-sugar" gem with rackspace specific helpers.
98
+ email:
99
+ - jarosser06@gmail.com
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - ".gitignore"
105
+ - ".kitchen.yml"
106
+ - Berksfile
107
+ - Gemfile
108
+ - Gemfile.lock
109
+ - LICENSE
110
+ - README.md
111
+ - Rakefile
112
+ - chef-sugar-rackspace.gemspec
113
+ - lib/chef/sugar/rackspace.rb
114
+ - lib/chef/sugar/rackspace/ip.rb
115
+ - lib/chef/sugar/rackspace/version.rb
116
+ - metadata.rb
117
+ - recipes/default.rb
118
+ - spec/spec_helper.rb
119
+ - spec/unit/chef/sugar/rackspace/ip_spec.rb
120
+ homepage: https://github.com/jarosser06/chef-sugar-rackspace
121
+ licenses:
122
+ - MIT
123
+ metadata: {}
124
+ post_install_message:
125
+ rdoc_options: []
126
+ require_paths:
127
+ - lib
128
+ required_ruby_version: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - ">="
131
+ - !ruby/object:Gem::Version
132
+ version: '1.9'
133
+ required_rubygems_version: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - ">="
136
+ - !ruby/object:Gem::Version
137
+ version: '0'
138
+ requirements: []
139
+ rubyforge_project:
140
+ rubygems_version: 2.4.4
141
+ signing_key:
142
+ specification_version: 4
143
+ summary: A collection of helper methods and modules, extending the helper methods
144
+ available in the "chef-sugar" gem for Rackspace.
145
+ test_files:
146
+ - spec/spec_helper.rb
147
+ - spec/unit/chef/sugar/rackspace/ip_spec.rb
148
+ has_rdoc: