chef-workflow 0.1.1 → 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.
@@ -1,95 +1,111 @@
1
- require 'chef-workflow/support/vagrant'
2
- require 'chef-workflow/support/ip'
3
1
  require 'vagrant/prison'
4
2
 
5
- class VM
6
- #
7
- # Provisions a server group with vagrant and virtualbox.
8
- #
9
- # All vagrant machines share the same IP address on eth0, which is typically
10
- # 10.0.2.15. To compensate for that, a host-only network address will be
11
- # auto-generated for each server in the group and lives on eth1. It is strongly
12
- # recommended that you deal with this problem in your chef cookbooks, as
13
- # node["ipaddress"] will typically be wrong and we cannot compensate for it.
14
- #
15
- # Groups provisioned in this manner are done so with Vagrant::Prison.
16
- #
17
- class VagrantProvisioner
18
- # Vagrant::Prison object
19
- attr_reader :prison
20
- # number of servers to provision
21
- attr_reader :number_of_servers
22
- # name of server group
23
- attr_accessor :name
24
-
3
+ module ChefWorkflow
4
+ class VM
25
5
  #
26
- # Constructor. Expects a server group name and a number of servers to provision.
6
+ # Provisions a server group with vagrant and virtualbox.
27
7
  #
28
- def initialize(name, number_of_servers)
29
- @prison = nil
30
- @name = name
31
- @number_of_servers = number_of_servers
32
- end
33
-
8
+ # All vagrant machines share the same IP address on eth0, which is typically
9
+ # 10.0.2.15. To compensate for that, a host-only network address will be
10
+ # auto-generated for each server in the group and lives on eth1. It is strongly
11
+ # recommended that you deal with this problem in your chef cookbooks, as
12
+ # node["ipaddress"] will typically be wrong and we cannot compensate for it.
34
13
  #
35
- # Get the ips associated with this server group.
14
+ # Groups provisioned in this manner are done so with Vagrant::Prison.
36
15
  #
37
- def ips
38
- IPSupport.singleton.get_role_ips(name)
39
- end
16
+ class VagrantProvisioner
17
+ require 'chef-workflow/support/vagrant'
18
+ require 'chef-workflow/support/ip'
19
+ require 'chef-workflow/support/db/basic'
40
20
 
41
- #
42
- # Get the appropriate Vagrant UI class, depending on debugging settings.
43
- #
44
- def ui_class
45
- $CHEF_WORKFLOW_DEBUG >= 2 ? Vagrant::UI::Basic : Vagrant::UI::Silent
46
- end
21
+ # Vagrant::Prison object
22
+ attr_reader :prison
23
+ # number of servers to provision
24
+ attr_reader :number_of_servers
25
+ # name of server group
26
+ attr_accessor :name
47
27
 
48
- #
49
- # helper to bootstrap vagrant requirements.
50
- #
51
- def bootstrap_vagrant_ipsupport
52
- IPSupport.singleton.seed_vagrant_ips
53
- end
28
+ #
29
+ # Constructor. Expects a server group name and a number of servers to provision.
30
+ #
31
+ def initialize(name, number_of_servers)
32
+ @db = ChefWorkflow::DatabaseSupport::Object.new("vm_prisons")
33
+ @name = name
34
+ @number_of_servers = number_of_servers
35
+ @prison = @db[name]
36
+ end
54
37
 
55
- #
56
- # Provision a group of servers. If successful, returns an array of the ips
57
- # allocated for the group. Ignores incoming arguments.
58
- #
59
- def startup(*args)
60
- bootstrap_vagrant_ipsupport
38
+ #
39
+ # Get the ips associated with this server group.
40
+ #
41
+ def ips
42
+ ChefWorkflow::IPSupport.get_role_ips(name)
43
+ end
44
+
45
+ #
46
+ # Get the appropriate Vagrant UI class, depending on debugging settings.
47
+ #
48
+ def ui_class
49
+ $CHEF_WORKFLOW_DEBUG >= 2 ? Vagrant::UI::Basic : Vagrant::UI::Silent
50
+ end
61
51
 
62
- IPSupport.singleton.delete_role(name)
52
+ #
53
+ # helper to bootstrap vagrant requirements.
54
+ #
55
+ def bootstrap_vagrant_ipsupport
56
+ ChefWorkflow::IPSupport.seed_vagrant_ips
57
+ end
63
58
 
64
- @prison = Vagrant::Prison.new(Dir.mktmpdir, false)
65
- prison.name = name
66
- prison.configure do |config|
67
- config.vm.box_url = VagrantSupport.singleton.box_url
68
- config.vm.box = VagrantSupport.singleton.box
69
- number_of_servers.times do |x|
70
- ip = IPSupport.singleton.unused_ip
71
- IPSupport.singleton.assign_role_ip(name, ip)
72
- config.vm.define "#{name}-#{x}" do |this_config|
73
- this_config.vm.network :hostonly, ip
59
+ #
60
+ # Provision a group of servers. If successful, returns an array of the ips
61
+ # allocated for the group. Ignores incoming arguments.
62
+ #
63
+ def startup(*args)
64
+ bootstrap_vagrant_ipsupport
65
+
66
+ ChefWorkflow::IPSupport.delete_role(name)
67
+
68
+ @prison = Vagrant::Prison.new(Dir.mktmpdir, false)
69
+ prison.name = name
70
+ prison.configure do |config|
71
+ config.vm.box_url = ChefWorkflow::VagrantSupport.box_url
72
+ config.vm.box = ChefWorkflow::VagrantSupport.box
73
+ number_of_servers.times do |x|
74
+ ip = ChefWorkflow::IPSupport.unused_ip
75
+ ChefWorkflow::IPSupport.assign_role_ip(name, ip)
76
+ config.vm.define "#{name}-#{x}" do |this_config|
77
+ this_config.vm.network :hostonly, ip
78
+ end
74
79
  end
75
80
  end
81
+
82
+ prison.construct(:ui_class => ui_class)
83
+ @db[name] = prison # eager save in case start has issues
84
+
85
+ return prison.start ? ips : false
86
+ ensure
87
+ @db[name] = prison
76
88
  end
77
89
 
78
- prison.construct(:ui_class => ui_class)
90
+ #
91
+ # Deprovisions the servers for this group, and cleans up the prison and
92
+ # allocated IP addresses.
93
+ #
94
+ def shutdown
95
+ @prison ||= @db[name]
79
96
 
80
- return prison.start ? ips : false
81
- end
97
+ if prison
98
+ prison.configure_environment(:ui_class => ui_class)
99
+ prison.cleanup
100
+ end
101
+ ChefWorkflow::IPSupport.delete_role(name)
102
+ @db.delete(name)
103
+ return true
104
+ end
82
105
 
83
- #
84
- # Deprovisions the servers for this group, and cleans up the prison and
85
- # allocated IP addresses.
86
- #
87
- def shutdown
88
- if prison
89
- prison.configure_environment(:ui_class => ui_class)
90
- prison.cleanup
106
+ def report
107
+ ["#{@number_of_servers} servers; prison dir: #{@prison.dir}"]
91
108
  end
92
- IPSupport.singleton.delete_role(name)
93
109
  end
94
110
  end
95
111
  end
@@ -1,6 +1,4 @@
1
- class Chef
2
- module Workflow
3
- # The gem version.
4
- VERSION = "0.1.1"
5
- end
1
+ module ChefWorkflow
2
+ # The gem version.
3
+ VERSION = "0.2.0"
6
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chef-workflow
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-12-21 00:00:00.000000000 Z
12
+ date: 2013-02-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: vagrant-prison
@@ -75,6 +75,54 @@ dependencies:
75
75
  - - ~>
76
76
  - !ruby/object:Gem::Version
77
77
  version: 2.2.2
78
+ - !ruby/object:Gem::Dependency
79
+ name: knife-server
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ~>
84
+ - !ruby/object:Gem::Version
85
+ version: 0.3.3
86
+ type: :runtime
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ version: 0.3.3
94
+ - !ruby/object:Gem::Dependency
95
+ name: sqlite3
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ~>
100
+ - !ruby/object:Gem::Version
101
+ version: 1.3.6
102
+ type: :runtime
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ~>
108
+ - !ruby/object:Gem::Version
109
+ version: 1.3.6
110
+ - !ruby/object:Gem::Dependency
111
+ name: deprecated
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ~>
116
+ - !ruby/object:Gem::Version
117
+ version: 3.0.1
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ~>
124
+ - !ruby/object:Gem::Version
125
+ version: 3.0.1
78
126
  - !ruby/object:Gem::Dependency
79
127
  name: rdoc
80
128
  requirement: !ruby/object:Gem::Requirement
@@ -116,6 +164,7 @@ extensions: []
116
164
  extra_rdoc_files: []
117
165
  files:
118
166
  - .gitignore
167
+ - CHANGELOG.md
119
168
  - Gemfile
120
169
  - LICENSE.txt
121
170
  - README.md
@@ -124,6 +173,9 @@ files:
124
173
  - chef-workflow.gemspec
125
174
  - lib/chef-workflow.rb
126
175
  - lib/chef-workflow/support/attr.rb
176
+ - lib/chef-workflow/support/db.rb
177
+ - lib/chef-workflow/support/db/basic.rb
178
+ - lib/chef-workflow/support/db/group.rb
127
179
  - lib/chef-workflow/support/debug.rb
128
180
  - lib/chef-workflow/support/ec2.rb
129
181
  - lib/chef-workflow/support/general.rb
@@ -132,10 +184,12 @@ files:
132
184
  - lib/chef-workflow/support/knife-plugin.rb
133
185
  - lib/chef-workflow/support/knife.rb
134
186
  - lib/chef-workflow/support/scheduler.rb
187
+ - lib/chef-workflow/support/ssh.rb
135
188
  - lib/chef-workflow/support/vagrant.rb
136
189
  - lib/chef-workflow/support/vm.rb
137
190
  - lib/chef-workflow/support/vm/chef_server.rb
138
191
  - lib/chef-workflow/support/vm/ec2.rb
192
+ - lib/chef-workflow/support/vm/helpers/knife.rb
139
193
  - lib/chef-workflow/support/vm/knife.rb
140
194
  - lib/chef-workflow/support/vm/vagrant.rb
141
195
  - lib/chef-workflow/version.rb
@@ -159,9 +213,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
159
213
  version: '0'
160
214
  requirements: []
161
215
  rubyforge_project:
162
- rubygems_version: 1.8.24
216
+ rubygems_version: 1.8.25
163
217
  signing_key:
164
218
  specification_version: 3
165
219
  summary: A comprehensive rake-based workflow for chef
166
220
  test_files: []
167
- has_rdoc: