corl 0.5.3 → 0.5.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fc0f4119fb65c2e0bcc38762618961f514b467d2
4
- data.tar.gz: 806867a324bedab231f6aabea3afa2b0c6dde980
3
+ metadata.gz: 881f554ea8a48b043dcd9835c4cad50e4c2b51cb
4
+ data.tar.gz: 1d1f66df8ea0a33900f95727620e033b99037583
5
5
  SHA512:
6
- metadata.gz: 33a0ac51b370915ef9aa8fef62966b26c754db84ba6fe3d641a4187191ff592934fbf43f9e7586813735d39123a685aad552b7ab00f96b44ea61ffdb9912a078
7
- data.tar.gz: 99025a53c6d3b7d75fc722c97b5fc0ed3b0b500e43cb026b5566a42330b79b7ffbb136a4dc5b7378fd381511ad1f3afb4c89e4a9ac453f04e7ba0f46596e8a42
6
+ metadata.gz: 2ee65aa1433b07072305fd0e1a4d5d09e61255a59d013df507329681b01f8826084b65cb15edb097e0547278d151fa7129b9f1b3e6c5b2562e64cce309cd878d
7
+ data.tar.gz: e49913e5c758ee2402edbde41061f0b70c1f2692a92c068a891c6f82d4a8e0035a1382455a4d5b14b07662ad9a0d3ab603440286ef1a4e2d4a7695bf94567aa8
data/Gemfile CHANGED
@@ -2,8 +2,7 @@ source "http://rubygems.org"
2
2
 
3
3
  gem "nucleon", "~> 0.2", ">= 0.2.2", :github => 'coralnexus/nucleon', :branch => '0.2'
4
4
 
5
- gem "fog", "~> 1.25"
6
- gem "fog-rackspace", "~> 1.0"
5
+ gem "fog", "~> 1.23"
7
6
  gem "unf", "~> 0.1"
8
7
 
9
8
  gem "facter", "~> 2.3"
data/Gemfile.lock CHANGED
@@ -1,9 +1,9 @@
1
1
  GIT
2
2
  remote: git://github.com/coralnexus/nucleon.git
3
- revision: d6848f16f76b9cdd6fb6737bdac6b13f40d9e36e
3
+ revision: 49e01c377d42b1656181b34904f6d7927ecdace4
4
4
  branch: 0.2
5
5
  specs:
6
- nucleon (0.2.3)
6
+ nucleon (0.2.4)
7
7
  celluloid (~> 0.16)
8
8
  childprocess (~> 0.5)
9
9
  deep_merge (~> 1.0)
@@ -72,10 +72,6 @@ GEM
72
72
  fog-core
73
73
  fog-xml
74
74
  nokogiri
75
- fog-rackspace (1.0.4)
76
- addressable
77
- fog-core
78
- fog-json
79
75
  fog-radosgw (0.0.3)
80
76
  fog-core (>= 1.21.0)
81
77
  fog-json
@@ -146,7 +142,7 @@ GEM
146
142
  multi_json (~> 1.3)
147
143
  multi_xml (~> 0.5)
148
144
  rack (~> 1.2)
149
- octokit (3.6.0)
145
+ octokit (3.7.0)
150
146
  sawyer (~> 0.6.0, >= 0.5.3)
151
147
  opennebula (4.10.1)
152
148
  json
@@ -157,7 +153,7 @@ GEM
157
153
  hiera (~> 1.0)
158
154
  json_pure
159
155
  rack (1.5.2)
160
- rake (10.4.1)
156
+ rake (10.4.2)
161
157
  rbvmomi (1.8.2)
162
158
  builder
163
159
  nokogiri (>= 1.4.1)
@@ -195,8 +191,7 @@ PLATFORMS
195
191
  DEPENDENCIES
196
192
  bundler (~> 1.7)
197
193
  facter (~> 2.3)
198
- fog (~> 1.25)
199
- fog-rackspace (~> 1.0)
194
+ fog (~> 1.23)
200
195
  hiera (~> 1.3)
201
196
  jeweler (~> 2.0)
202
197
  nucleon (~> 0.2, >= 0.2.2)!
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.3
1
+ 0.5.4
@@ -29,14 +29,11 @@ Systems initialized:
29
29
  * Ruby - Ruby 2.1.x packages installed
30
30
  - Execution alternative configuration (if applicable)
31
31
  - Ruby Gem options initialized
32
-
33
- * Puppet - PuppetLabs Apt source initialized (if applicable)
34
- - Puppet and dependencies installed
35
- - Hiera configured
36
32
 
37
33
  * Nucleon - Nucleon gem and dependencies installed
38
34
 
39
35
  * CORL - CORL gem and dependencies installed
36
+ - Hiera configured
40
37
 
41
38
  --------------------------------------------------------------------------------
42
39
  Tested under Ubuntu 12.04 and 14.04 LTS
@@ -18,6 +18,8 @@ function initialize_rvm_user()
18
18
 
19
19
  local PATH_ENTRY='PATH=${PATH}:/usr/local/rvm/bin'
20
20
  local RVMSUDO_SECURE_PATH="export rvmsudo_secure_path=1"
21
+ local SUDO_ALIAS="alias sudo=rvmsudo"
22
+
21
23
  local SCRIPT_INCLUDE="[[ -s '/usr/local/rvm/scripts/rvm' ]] && source '/usr/local/rvm/scripts/rvm'"
22
24
 
23
25
  echo "3. Initializing RVM user ${USER_NAME} group and environment settings"
@@ -30,7 +32,11 @@ function initialize_rvm_user()
30
32
  if ! grep -Fxq "$RVMSUDO_SECURE_PATH" "$PROFILE_FILE" >>/tmp/ruby.config.log 2>&1
31
33
  then
32
34
  echo "$RVMSUDO_SECURE_PATH" >> "$PROFILE_FILE"
33
- fi
35
+ fi
36
+ if ! grep -Fxq "$SUDO_ALIAS" "$PROFILE_FILE" >>/tmp/ruby.config.log 2>&1
37
+ then
38
+ echo "$SUDO_ALIAS" >> "$PROFILE_FILE"
39
+ fi
34
40
  if ! grep -Fxq "$SCRIPT_INCLUDE" "$BASHRC_FILE" >>/tmp/ruby.config.log 2>&1
35
41
  then
36
42
  echo "$SCRIPT_INCLUDE" >> "$BASHRC_FILE"
@@ -59,7 +65,7 @@ su - -c "rvm install rbx-2.3.0 --rubygems 2.4.2" root >>/tmp/ruby.config.log 2>&
59
65
  su - -c "rvm use rbx-2.3.0 --default" root >>/tmp/ruby.config.log 2>&1 || exit 54
60
66
 
61
67
 
62
- if [ ! -e "$HOME/.gemrc" ]
68
+ if [ ! -e "/root/.gemrc" ]
63
69
  then
64
70
  echo "5. Adding an initial .gemrc configuration"
65
71
 
@@ -67,5 +73,5 @@ echo "5. Adding an initial .gemrc configuration"
67
73
  ( cat <<'EOP'
68
74
  gem: --no-rdoc --no-ri
69
75
  EOP
70
- ) > "$HOME/.gemrc" || exit 55
76
+ ) > "/root/.gemrc" || exit 55
71
77
  fi
@@ -3,7 +3,7 @@
3
3
 
4
4
  # Uninstall the CORL gem
5
5
 
6
- echo "1. Removing old versions of corl gem"
6
+ echo "1. Removing old versions of CORL gem"
7
7
  su - -c "gem uninstall corl -x --force" root >/tmp/corl.uninstall.log 2>&1 || exit 101
8
8
 
9
9
  # Install the CORL gem
@@ -27,4 +27,28 @@ then
27
27
  else
28
28
  echo "2. Installing latest release of CORL"
29
29
  su - -c "gem install corl" root >/tmp/corl.install.log 2>&1 || exit 102
30
- fi
30
+ fi
31
+
32
+ # Set up Hiera configuration
33
+ mkdir -p /var/corl/config || exit 108
34
+
35
+ if [ ! -e /etc/hiera.yaml ]
36
+ then
37
+ echo "5. Configuring Hiera"
38
+
39
+ ( cat <<'EOP'
40
+ ---
41
+ :merge_behavior: deeper
42
+ :backends:
43
+ - yaml
44
+ - json
45
+ :yaml:
46
+ :datadir: /var/corl/config
47
+ :json:
48
+ :datadir: /var/corl/config
49
+ :hierarchy:
50
+ - common
51
+ EOP
52
+ ) > /etc/hiera.yaml || exit 109
53
+ chmod 0440 /etc/hiera.yaml || exit 110
54
+ fi
data/corl.gemspec CHANGED
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: corl 0.5.3 ruby lib
5
+ # stub: corl 0.5.4 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "corl"
9
- s.version = "0.5.3"
9
+ s.version = "0.5.4"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib"]
13
13
  s.authors = ["Adrian Webb"]
14
- s.date = "2014-12-03"
14
+ s.date = "2014-12-04"
15
15
  s.description = "Framework that provides a simple foundation for growing organically in the cloud"
16
16
  s.email = "adrian.webb@coralnexus.com"
17
17
  s.executables = ["corl"]
@@ -43,7 +43,6 @@ Gem::Specification.new do |s|
43
43
  "bootstrap/os/ubuntu/01_git.sh",
44
44
  "bootstrap/os/ubuntu/02_editor.sh",
45
45
  "bootstrap/os/ubuntu/05_ruby.sh",
46
- "bootstrap/os/ubuntu/06_puppet.sh",
47
46
  "bootstrap/os/ubuntu/09_nucleon.sh",
48
47
  "bootstrap/os/ubuntu/10_corl.sh",
49
48
  "corl.gemspec",
@@ -70,6 +69,7 @@ Gem::Specification.new do |s|
70
69
  "lib/core/mixin/machine/ssh.rb",
71
70
  "lib/core/mixin/macro/network_settings.rb",
72
71
  "lib/core/mod/fog_aws_server.rb",
72
+ "lib/core/mod/fog_rackspace_server.rb",
73
73
  "lib/core/mod/hiera_backend.rb",
74
74
  "lib/core/plugin/agent.rb",
75
75
  "lib/core/plugin/builder.rb",
@@ -177,8 +177,7 @@ Gem::Specification.new do |s|
177
177
 
178
178
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
179
179
  s.add_runtime_dependency(%q<nucleon>, [">= 0.2.2", "~> 0.2"])
180
- s.add_runtime_dependency(%q<fog>, ["~> 1.25"])
181
- s.add_runtime_dependency(%q<fog-rackspace>, ["~> 1.0"])
180
+ s.add_runtime_dependency(%q<fog>, ["~> 1.23"])
182
181
  s.add_runtime_dependency(%q<unf>, ["~> 0.1"])
183
182
  s.add_runtime_dependency(%q<facter>, ["~> 2.3"])
184
183
  s.add_runtime_dependency(%q<hiera>, ["~> 1.3"])
@@ -189,8 +188,7 @@ Gem::Specification.new do |s|
189
188
  s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
190
189
  else
191
190
  s.add_dependency(%q<nucleon>, [">= 0.2.2", "~> 0.2"])
192
- s.add_dependency(%q<fog>, ["~> 1.25"])
193
- s.add_dependency(%q<fog-rackspace>, ["~> 1.0"])
191
+ s.add_dependency(%q<fog>, ["~> 1.23"])
194
192
  s.add_dependency(%q<unf>, ["~> 0.1"])
195
193
  s.add_dependency(%q<facter>, ["~> 2.3"])
196
194
  s.add_dependency(%q<hiera>, ["~> 1.3"])
@@ -202,8 +200,7 @@ Gem::Specification.new do |s|
202
200
  end
203
201
  else
204
202
  s.add_dependency(%q<nucleon>, [">= 0.2.2", "~> 0.2"])
205
- s.add_dependency(%q<fog>, ["~> 1.25"])
206
- s.add_dependency(%q<fog-rackspace>, ["~> 1.0"])
203
+ s.add_dependency(%q<fog>, ["~> 1.23"])
207
204
  s.add_dependency(%q<unf>, ["~> 0.1"])
208
205
  s.add_dependency(%q<facter>, ["~> 2.3"])
209
206
  s.add_dependency(%q<hiera>, ["~> 1.3"])
@@ -1,49 +1,49 @@
1
1
 
2
2
  module CORL
3
3
  module Machine
4
- class AWS < Fog
5
-
4
+ class AWS < FogBase
5
+
6
6
  #-----------------------------------------------------------------------------
7
7
  # Checks
8
-
8
+
9
9
  #-----------------------------------------------------------------------------
10
10
  # Property accessors / modifiers
11
-
11
+
12
12
  def set_connection
13
13
  require 'unf'
14
14
  super
15
15
  Kernel.load File.join(File.dirname(__FILE__), '..', '..', 'core', 'mod', 'fog_aws_server.rb')
16
16
  end
17
-
17
+
18
18
  #-----------------------------------------------------------------------------
19
19
  # Management
20
20
 
21
21
  def init_server
22
22
  super do
23
23
  myself.plugin_name = @server.id
24
-
24
+
25
25
  node[:id] = plugin_name
26
26
  node[:public_ip] = @server.public_ip_address
27
- node[:private_ip] = @server.private_ip_address
27
+ node[:private_ip] = @server.private_ip_address
28
28
  node[:machine_type] = @server.flavor_id
29
- node[:image] = @server.image_id
29
+ node[:image] = @server.image_id
30
30
  node.user = @server.username unless node.user
31
-
31
+
32
32
  @server.private_key_path = node.private_key if node.private_key
33
33
  @server.public_key_path = node.public_key if node.public_key
34
- end
34
+ end
35
35
  end
36
-
36
+
37
37
  #---
38
-
38
+
39
39
  def init_ssh(ssh_port)
40
40
  # Security group initialization
41
41
  if compute && ssh_port != 22
42
42
  ensure_security_group("CORL_SSH_#{ssh_port}", ssh_port)
43
43
  end
44
44
  end
45
-
46
- #---
45
+
46
+ #---
47
47
 
48
48
  def create(options = {})
49
49
  super do |config|
@@ -54,36 +54,36 @@ class AWS < Fog
54
54
  compute.key_pairs.create(
55
55
  :name => keypair_name,
56
56
  :public_key => Util::Disk.read(node.public_key)
57
- )
57
+ )
58
58
  config[:key_name] = keypair_name
59
59
  end
60
60
  end
61
-
61
+
62
62
  #---
63
-
63
+
64
64
  def reload(options = {})
65
65
  super do |config|
66
66
  success = server.reboot
67
-
67
+
68
68
  server.wait_for { ready? } if success
69
69
  success
70
70
  end
71
71
  end
72
-
72
+
73
73
  #---
74
-
74
+
75
75
  def create_image(options = {})
76
76
  super do |image_name, config, success|
77
77
  image_name = image_name.gsub(/[^A-Za-z0-9\(\)\.\-\_\/]+/, '_')
78
78
  image_description = config.get(:description, "CORL backup image")
79
-
79
+
80
80
  data = compute.create_image(server.identity, image_name, image_description)
81
81
  image_id = data.body['imageId']
82
-
83
- ::Fog.wait_for do
82
+
83
+ Fog.wait_for do
84
84
  compute.describe_images('ImageId' => image_id).body['imagesSet'].first['imageState'] == 'available'
85
85
  end
86
-
86
+
87
87
  if image_id
88
88
  node[:image] = image_id
89
89
  success = true
@@ -91,7 +91,7 @@ class AWS < Fog
91
91
  success
92
92
  end
93
93
  end
94
-
94
+
95
95
  #---
96
96
 
97
97
  def destroy(options = {})
@@ -102,36 +102,36 @@ class AWS < Fog
102
102
  key_pair.destroy
103
103
  end
104
104
  end
105
- true
105
+ true
106
106
  end
107
107
  end
108
-
108
+
109
109
  #-----------------------------------------------------------------------------
110
110
  # Utilities
111
-
111
+
112
112
  def keypair_name
113
- "CORL_#{node.plugin_name}"
113
+ "CORL_#{node.plugin_name}"
114
114
  end
115
-
115
+
116
116
  #---
117
-
117
+
118
118
  def ensure_security_group(group_name, from_port, to_port = nil, options = {})
119
119
  config = Config.ensure(options)
120
120
  security_group = compute.security_groups.get(group_name)
121
121
  cidrip = config.get(:cidrip, '0.0.0.0/0')
122
122
  protocol = config.get(:protocol, 'tcp')
123
123
  to_port = from_port if to_port.nil?
124
-
124
+
125
125
  if security_group.nil?
126
126
  security_group = compute.security_groups.create(
127
127
  :name => group_name,
128
- :description => config.get(:description, "Opening port range: #{from_port} to #{to_port}")
129
- )
130
- raise unless security_group # TODO: Better error class
128
+ :description => config.get(:description, "Opening port range: #{from_port} to #{to_port}")
129
+ )
130
+ raise unless security_group # TODO: Better error class
131
131
  end
132
-
132
+
133
133
  authorized = false
134
- if security_group.ip_permissions
134
+ if security_group.ip_permissions
135
135
  authorized = security_group.ip_permissions.detect do |ip_permission|
136
136
  ip_permission['ipRanges'].first && ip_permission['ipRanges'].first['cidrIp'] == cidrip &&
137
137
  ip_permission['fromPort'] == from_port &&
@@ -142,7 +142,7 @@ class AWS < Fog
142
142
  unless authorized
143
143
  security_group.authorize_port_range(Range.new(from_port, to_port))
144
144
  end
145
-
145
+
146
146
  if server
147
147
  server.groups = [ group_name ] | server.groups
148
148
  server.save
@@ -1,7 +1,7 @@
1
1
 
2
2
  module CORL
3
3
  module Machine
4
- class Rackspace < Fog
4
+ class Rackspace < FogBase
5
5
 
6
6
  #-----------------------------------------------------------------------------
7
7
  # Checks
@@ -10,9 +10,8 @@ class Rackspace < Fog
10
10
  # Property accessors / modifiers
11
11
 
12
12
  def set_connection
13
- require 'fog-rackspace'
14
13
  super
15
- #Kernel.load File.join(File.dirname(__FILE__), '..', '..', 'core', 'mod', 'fog_rackspace_server.rb')
14
+ Kernel.load File.join(File.dirname(__FILE__), '..', '..', 'core', 'mod', 'fog_rackspace_server.rb')
16
15
  end
17
16
 
18
17
  #-----------------------------------------------------------------------------
data/lib/CORL/node/AWS.rb CHANGED
@@ -1,63 +1,63 @@
1
1
 
2
2
  module CORL
3
3
  module Node
4
- class AWS < Fog
5
-
4
+ class AWS < FogBase
5
+
6
6
  #-----------------------------------------------------------------------------
7
7
  # Node plugin interface
8
-
8
+
9
9
  def normalize(reload)
10
10
  super do
11
11
  region_info.import({
12
- 'us-east-1' => 'US East -- North Virginia',
13
- 'us-west-1' => 'US West -- North California',
12
+ 'us-east-1' => 'US East -- North Virginia',
13
+ 'us-west-1' => 'US West -- North California',
14
14
  'us-west-2' => 'US West -- Oregon',
15
15
  'eu-west-1' => 'EU -- Ireland',
16
- 'ap-northeast-1' => 'Asia Pacific -- Tokyo',
17
- 'ap-southeast-1' => 'Asia Pacific -- Singapore',
18
- 'ap-southeast-2' => 'Asia Pacific -- Sydney',
16
+ 'ap-northeast-1' => 'Asia Pacific -- Tokyo',
17
+ 'ap-southeast-1' => 'Asia Pacific -- Singapore',
18
+ 'ap-southeast-2' => 'Asia Pacific -- Sydney',
19
19
  'sa-east-1' => 'South America -- Sao Paulo'
20
20
  })
21
-
22
- # Return machine provider
21
+
22
+ # Return machine provider
23
23
  :aws
24
24
  end
25
25
  end
26
-
26
+
27
27
  #-----------------------------------------------------------------------------
28
28
  # Checks
29
-
29
+
30
30
  def usable_image?(image)
31
31
  image.state == 'available' && image.name
32
32
  end
33
-
33
+
34
34
  #-----------------------------------------------------------------------------
35
35
  # Property accessors / modifiers
36
-
36
+
37
37
  #-----------------------------------------------------------------------------
38
38
  # Settings groups
39
-
39
+
40
40
  def machine_config
41
41
  super do |config|
42
- config.import({
42
+ config.import({
43
43
  :provider => 'AWS',
44
44
  :region => region.to_s
45
45
  })
46
-
46
+
47
47
  config[:aws_access_key_id] = api_user if api_user
48
48
  config[:aws_secret_access_key] = api_key if api_key
49
49
  end
50
50
  end
51
-
51
+
52
52
  #---
53
-
53
+
54
54
  def create_config
55
- { :flavor_id => machine_type, :image_id => image, :username => user }
55
+ { :flavor_id => machine_type, :image_id => image, :username => user }
56
56
  end
57
-
57
+
58
58
  #-----------------------------------------------------------------------------
59
59
  # Node operations
60
-
60
+
61
61
  def create(options = {})
62
62
  super do |op, config|
63
63
  if op == :config
@@ -65,9 +65,9 @@ class AWS < Fog
65
65
  end
66
66
  end
67
67
  end
68
-
68
+
69
69
  #---
70
-
70
+
71
71
  def start(options = {})
72
72
  super do |op, config|
73
73
  if op == :config
@@ -75,33 +75,33 @@ class AWS < Fog
75
75
  end
76
76
  end
77
77
  end
78
-
78
+
79
79
  #-----------------------------------------------------------------------------
80
80
  # Utilities
81
-
81
+
82
82
  def render_machine_type(machine_type)
83
- sprintf("%-25s %-50s [ VCPUS: %-5s ] ( RAM: %6sMB | DISK: %8sGB ) ( BITS: %5s )",
83
+ sprintf("%-25s %-50s [ VCPUS: %-5s ] ( RAM: %6sMB | DISK: %8sGB ) ( BITS: %5s )",
84
84
  purple(machine_type_id(machine_type)),
85
- yellow(machine_type.name),
86
- blue(machine_type.cores.to_s),
87
- blue(machine_type.ram.to_s),
88
- blue(machine_type.disk.to_s),
85
+ yellow(machine_type.name),
86
+ blue(machine_type.cores.to_s),
87
+ blue(machine_type.ram.to_s),
88
+ blue(machine_type.disk.to_s),
89
89
  blue(machine_type.bits.to_s)
90
90
  )
91
91
  end
92
-
92
+
93
93
  #---
94
-
94
+
95
95
  def render_image(image)
96
96
  description = image.name
97
97
  description = image.description if image.description && ! image.description.empty?
98
-
98
+
99
99
  location = image.location.split('/').first
100
100
  sprintf("%-23s [ %-10s | %-6s ] %s ( %s )", purple(image_id(image)), blue(image.state), image.architecture, yellow(description), cyan(location))
101
101
  end
102
-
102
+
103
103
  #---
104
-
104
+
105
105
  def image_search_text(image)
106
106
  location = image.location.split('/').first
107
107
  location = location.match(/^\d+$/) ? '' : location