ironfan 3.2.2 → 4.0.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.
- data/CHANGELOG.md +5 -0
- data/VERSION +1 -1
- data/ironfan.gemspec +33 -20
- data/lib/chef/knife/cluster_kick.rb +17 -17
- data/lib/chef/knife/cluster_kill.rb +13 -7
- data/lib/chef/knife/cluster_launch.rb +60 -66
- data/lib/chef/knife/cluster_pry.rb +2 -2
- data/lib/chef/knife/cluster_show.rb +3 -6
- data/lib/chef/knife/cluster_ssh.rb +5 -11
- data/lib/chef/knife/cluster_start.rb +2 -4
- data/lib/chef/knife/cluster_stop.rb +1 -3
- data/lib/chef/knife/cluster_sync.rb +13 -21
- data/lib/chef/knife/ironfan_knife_common.rb +11 -9
- data/lib/chef/knife/ironfan_script.rb +2 -1
- data/lib/gorillib/resolution.rb +119 -0
- data/lib/ironfan/broker/computer.rb +316 -0
- data/lib/ironfan/broker/drive.rb +21 -0
- data/lib/ironfan/broker.rb +37 -0
- data/lib/ironfan/builder.rb +14 -0
- data/lib/ironfan/deprecated.rb +16 -58
- data/lib/ironfan/dsl/cloud.rb +21 -0
- data/lib/ironfan/dsl/cluster.rb +27 -0
- data/lib/ironfan/dsl/compute.rb +84 -0
- data/lib/ironfan/dsl/ec2.rb +260 -0
- data/lib/ironfan/dsl/facet.rb +25 -0
- data/lib/ironfan/dsl/role.rb +19 -0
- data/lib/ironfan/dsl/server.rb +31 -0
- data/lib/ironfan/dsl/virtualbox.rb +8 -0
- data/lib/ironfan/dsl/volume.rb +45 -0
- data/lib/ironfan/dsl.rb +7 -0
- data/lib/ironfan/headers.rb +58 -0
- data/lib/ironfan/provider/chef/client.rb +77 -0
- data/lib/ironfan/provider/chef/node.rb +133 -0
- data/lib/ironfan/provider/chef/role.rb +69 -0
- data/lib/ironfan/provider/chef.rb +28 -0
- data/lib/ironfan/provider/ec2/ebs_volume.rb +137 -0
- data/lib/ironfan/provider/ec2/elastic_ip.rb +10 -0
- data/lib/ironfan/provider/ec2/key_pair.rb +65 -0
- data/lib/ironfan/provider/ec2/machine.rb +258 -0
- data/lib/ironfan/provider/ec2/placement_group.rb +24 -0
- data/lib/ironfan/provider/ec2/security_group.rb +118 -0
- data/lib/ironfan/provider/ec2.rb +47 -0
- data/lib/ironfan/provider/virtualbox/machine.rb +10 -0
- data/lib/ironfan/provider/virtualbox.rb +8 -0
- data/lib/ironfan/provider.rb +139 -0
- data/lib/ironfan/requirements.rb +52 -0
- data/lib/ironfan.rb +44 -33
- metadata +34 -21
- data/lib/chef/knife/cluster_vagrant.rb +0 -144
- data/lib/chef/knife/vagrant/ironfan_environment.rb +0 -18
- data/lib/chef/knife/vagrant/ironfan_provisioners.rb +0 -27
- data/lib/chef/knife/vagrant/skeleton_vagrantfile.rb +0 -119
- data/lib/ironfan/chef_layer.rb +0 -300
- data/lib/ironfan/cloud.rb +0 -323
- data/lib/ironfan/cluster.rb +0 -118
- data/lib/ironfan/compute.rb +0 -139
- data/lib/ironfan/discovery.rb +0 -190
- data/lib/ironfan/dsl_builder.rb +0 -99
- data/lib/ironfan/facet.rb +0 -143
- data/lib/ironfan/fog_layer.rb +0 -196
- data/lib/ironfan/private_key.rb +0 -130
- data/lib/ironfan/role_implications.rb +0 -58
- data/lib/ironfan/security_group.rb +0 -133
- data/lib/ironfan/server.rb +0 -291
- data/lib/ironfan/server_slice.rb +0 -265
- data/lib/ironfan/volume.rb +0 -146
data/lib/ironfan.rb
CHANGED
@@ -1,32 +1,7 @@
|
|
1
|
-
require '
|
2
|
-
require 'chef/config'
|
3
|
-
#
|
4
|
-
require 'gorillib/metaprogramming/class_attribute'
|
5
|
-
require 'gorillib/hash/reverse_merge'
|
6
|
-
require 'gorillib/object/blank'
|
7
|
-
require 'gorillib/hash/compact'
|
8
|
-
require 'gorillib/builder'
|
9
|
-
require 'set'
|
10
|
-
|
11
|
-
require 'ironfan/dsl_builder'
|
12
|
-
require 'ironfan/security_group'
|
13
|
-
require 'ironfan/cloud'
|
14
|
-
require 'ironfan/compute' # base class for machine attributes
|
15
|
-
require 'ironfan/facet' # similar machines within a cluster
|
16
|
-
require 'ironfan/cluster' # group of machines with a common mission
|
17
|
-
require 'ironfan/server' # realization of a specific facet
|
18
|
-
require 'ironfan/discovery' # pair servers with Fog and Chef objects
|
19
|
-
require 'ironfan/server_slice' # collection of server objects
|
20
|
-
require 'ironfan/volume' # configure external and internal volumes
|
21
|
-
require 'ironfan/private_key' # coordinate chef keys, cloud keypairs, etc
|
22
|
-
require 'ironfan/role_implications' # make roles trigger other actions (security groups, etc)
|
23
|
-
#
|
24
|
-
require 'ironfan/chef_layer' # interface to chef for server actions
|
25
|
-
require 'ironfan/fog_layer' # interface to fog for server actions
|
26
|
-
#
|
27
|
-
require 'ironfan/deprecated' # stuff slated to go away
|
1
|
+
require 'ironfan/requirements'
|
28
2
|
|
29
3
|
module Ironfan
|
4
|
+
@@clusters ||= Hash.new
|
30
5
|
|
31
6
|
# path to search for cluster definition files
|
32
7
|
def self.cluster_path
|
@@ -40,7 +15,7 @@ module Ironfan
|
|
40
15
|
#
|
41
16
|
# Delegates
|
42
17
|
def self.clusters
|
43
|
-
Chef::Config[:clusters] ||=
|
18
|
+
Chef::Config[:clusters] ||= Hash.new
|
44
19
|
end
|
45
20
|
|
46
21
|
def self.ui=(ui) @ui = ui ; end
|
@@ -49,6 +24,11 @@ module Ironfan
|
|
49
24
|
def self.chef_config=(cc) @chef_config = cc ; end
|
50
25
|
def self.chef_config() @chef_config ; end
|
51
26
|
|
27
|
+
# simple delegation to multiple targets
|
28
|
+
def self.delegate_to(targets,options={},&block)
|
29
|
+
raise 'missing block' unless block_given?
|
30
|
+
[targets].flatten.each {|target| target.instance_eval &block }
|
31
|
+
end
|
52
32
|
#
|
53
33
|
# Defines a cluster with the given name.
|
54
34
|
#
|
@@ -71,9 +51,9 @@ module Ironfan
|
|
71
51
|
#
|
72
52
|
def self.cluster(name, attrs={}, &block)
|
73
53
|
name = name.to_sym
|
74
|
-
|
54
|
+
|
55
|
+
cl = ( @@clusters[name] ||= Ironfan::Dsl::Cluster.new({:name => name}) )
|
75
56
|
cl.receive!(attrs, &block)
|
76
|
-
cl
|
77
57
|
end
|
78
58
|
|
79
59
|
#
|
@@ -85,17 +65,21 @@ module Ironfan
|
|
85
65
|
#
|
86
66
|
# @return [Ironfan::Cluster] the requested cluster
|
87
67
|
def self.load_cluster(cluster_name)
|
68
|
+
cluster = cluster_name.to_sym
|
88
69
|
raise ArgumentError, "Please supply a cluster name" if cluster_name.to_s.empty?
|
89
|
-
return clusters[
|
70
|
+
return @@clusters[cluster] if @@clusters[cluster]
|
90
71
|
|
91
72
|
cluster_file = cluster_filenames[cluster_name] or die("Couldn't find a definition for #{cluster_name} in cluster_path: #{cluster_path.inspect}")
|
92
73
|
|
93
74
|
Chef::Log.info("Loading cluster #{cluster_file}")
|
94
75
|
|
95
76
|
require cluster_file
|
96
|
-
unless clusters[
|
77
|
+
unless @@clusters[cluster] then die("#{cluster_file} was supposed to have the definition for the #{cluster_name} cluster, but didn't") end
|
97
78
|
|
98
|
-
|
79
|
+
# Flesh out the expected servers listed in the facets
|
80
|
+
@@clusters[cluster].expand_servers!
|
81
|
+
|
82
|
+
@@clusters[cluster]
|
99
83
|
end
|
100
84
|
|
101
85
|
#
|
@@ -141,4 +125,31 @@ module Ironfan
|
|
141
125
|
Chef::Log.error( boom.backtrace.join("\n") )
|
142
126
|
end
|
143
127
|
end
|
128
|
+
|
129
|
+
#
|
130
|
+
# Utility to show a step of the overall process
|
131
|
+
#
|
132
|
+
def self.step(name, desc, *style)
|
133
|
+
ui.info(" #{"%-15s" % (name.to_s+":")}\t#{ui.color(desc.to_s, *style)}")
|
134
|
+
end
|
135
|
+
|
136
|
+
#
|
137
|
+
# Utility to do mock out a step during a dry-run
|
138
|
+
#
|
139
|
+
def self.unless_dry_run
|
140
|
+
if dry_run?
|
141
|
+
ui.info(" ... but not really")
|
142
|
+
return nil
|
143
|
+
else
|
144
|
+
yield
|
145
|
+
end
|
146
|
+
end
|
147
|
+
def self.dry_run?
|
148
|
+
chef_config[:dry_run]
|
149
|
+
end
|
150
|
+
|
151
|
+
# Intentionally skipping an implied step
|
152
|
+
def self.noop(source,method,*params)
|
153
|
+
Chef::Log.debug("Nothing to do for #{source}.#{method}(#{params.join(',')}), skipping")
|
154
|
+
end
|
144
155
|
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: ironfan
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version:
|
5
|
+
version: 4.0.0
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Infochimps
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2012-09-
|
13
|
+
date: 2012-09-06 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: chef
|
@@ -175,28 +175,41 @@ files:
|
|
175
175
|
- lib/chef/knife/cluster_start.rb
|
176
176
|
- lib/chef/knife/cluster_stop.rb
|
177
177
|
- lib/chef/knife/cluster_sync.rb
|
178
|
-
- lib/chef/knife/cluster_vagrant.rb
|
179
178
|
- lib/chef/knife/ironfan_knife_common.rb
|
180
179
|
- lib/chef/knife/ironfan_script.rb
|
181
|
-
- lib/
|
182
|
-
- lib/chef/knife/vagrant/ironfan_provisioners.rb
|
183
|
-
- lib/chef/knife/vagrant/skeleton_vagrantfile.rb
|
180
|
+
- lib/gorillib/resolution.rb
|
184
181
|
- lib/ironfan.rb
|
185
|
-
- lib/ironfan/
|
186
|
-
- lib/ironfan/
|
187
|
-
- lib/ironfan/
|
188
|
-
- lib/ironfan/
|
182
|
+
- lib/ironfan/broker.rb
|
183
|
+
- lib/ironfan/broker/computer.rb
|
184
|
+
- lib/ironfan/broker/drive.rb
|
185
|
+
- lib/ironfan/builder.rb
|
189
186
|
- lib/ironfan/deprecated.rb
|
190
|
-
- lib/ironfan/
|
191
|
-
- lib/ironfan/
|
192
|
-
- lib/ironfan/
|
193
|
-
- lib/ironfan/
|
194
|
-
- lib/ironfan/
|
195
|
-
- lib/ironfan/
|
196
|
-
- lib/ironfan/
|
197
|
-
- lib/ironfan/server.rb
|
198
|
-
- lib/ironfan/
|
199
|
-
- lib/ironfan/volume.rb
|
187
|
+
- lib/ironfan/dsl.rb
|
188
|
+
- lib/ironfan/dsl/cloud.rb
|
189
|
+
- lib/ironfan/dsl/cluster.rb
|
190
|
+
- lib/ironfan/dsl/compute.rb
|
191
|
+
- lib/ironfan/dsl/ec2.rb
|
192
|
+
- lib/ironfan/dsl/facet.rb
|
193
|
+
- lib/ironfan/dsl/role.rb
|
194
|
+
- lib/ironfan/dsl/server.rb
|
195
|
+
- lib/ironfan/dsl/virtualbox.rb
|
196
|
+
- lib/ironfan/dsl/volume.rb
|
197
|
+
- lib/ironfan/headers.rb
|
198
|
+
- lib/ironfan/provider.rb
|
199
|
+
- lib/ironfan/provider/chef.rb
|
200
|
+
- lib/ironfan/provider/chef/client.rb
|
201
|
+
- lib/ironfan/provider/chef/node.rb
|
202
|
+
- lib/ironfan/provider/chef/role.rb
|
203
|
+
- lib/ironfan/provider/ec2.rb
|
204
|
+
- lib/ironfan/provider/ec2/ebs_volume.rb
|
205
|
+
- lib/ironfan/provider/ec2/elastic_ip.rb
|
206
|
+
- lib/ironfan/provider/ec2/key_pair.rb
|
207
|
+
- lib/ironfan/provider/ec2/machine.rb
|
208
|
+
- lib/ironfan/provider/ec2/placement_group.rb
|
209
|
+
- lib/ironfan/provider/ec2/security_group.rb
|
210
|
+
- lib/ironfan/provider/virtualbox.rb
|
211
|
+
- lib/ironfan/provider/virtualbox/machine.rb
|
212
|
+
- lib/ironfan/requirements.rb
|
200
213
|
- spec/ironfan/cluster_spec.rb
|
201
214
|
- spec/ironfan/facet_spec.rb
|
202
215
|
- spec/ironfan/server_slice_spec.rb
|
@@ -219,7 +232,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
219
232
|
requirements:
|
220
233
|
- - ">="
|
221
234
|
- !ruby/object:Gem::Version
|
222
|
-
hash:
|
235
|
+
hash: -4005934554339854543
|
223
236
|
segments:
|
224
237
|
- 0
|
225
238
|
version: "0"
|
@@ -1,144 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Philip (flip) Kromer (<flip@infochimps.com>)
|
3
|
-
# Copyright:: Copyright (c) 2011 Infochimps, Inc
|
4
|
-
# License:: Apache License, Version 2.0
|
5
|
-
#
|
6
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
-
# you may not use this file except in compliance with the License.
|
8
|
-
# You may obtain a copy of the License at
|
9
|
-
#
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
12
|
-
# Unless required by applicable law or agreed to in writing, software
|
13
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
-
# See the License for the specific language governing permissions and
|
16
|
-
# limitations under the License.
|
17
|
-
#
|
18
|
-
|
19
|
-
class Chef
|
20
|
-
class Knife
|
21
|
-
|
22
|
-
#
|
23
|
-
# Vagrant support is VERY rough. It will
|
24
|
-
#
|
25
|
-
# * change the ui/commandline args, at the worst possible moment for you to adapt
|
26
|
-
# * show you info that is inaccurate, even beyond the obvious fact that it reports AWS properties.
|
27
|
-
# * translate your documents into swahili, make your TV record Gigli -- [tracker issue here](http://bit.ly/vrsalert)
|
28
|
-
#
|
29
|
-
# Vagrant has a really strong narcissistic streak, even more so than chef
|
30
|
-
# and ironfan already do. I don't want to fight (it's probably that way for
|
31
|
-
# good reasons), so the following oddball procedure may persist until it a)
|
32
|
-
# stops working well or b) someone recommends a better approach.
|
33
|
-
#
|
34
|
-
# when you run `knife cluster vagrant command cluster-[facet-[indexes]]` we:
|
35
|
-
#
|
36
|
-
# * identify all servers defined on that cluster
|
37
|
-
# * find (or make) the directory config.vagrant_path
|
38
|
-
# - if unset, will use `{homebase}/vagrants/{cluster_name}`
|
39
|
-
# * copy a special-purpose vagrantfile into that directory
|
40
|
-
# - it is called vagrantfile, but won't work in a standalone way.
|
41
|
-
#
|
42
|
-
#
|
43
|
-
class ClusterVagrant < Knife
|
44
|
-
IRONFAN_DIR = File.dirname(File.realdirpath(__FILE__))
|
45
|
-
require File.expand_path('ironfan_knife_common', IRONFAN_DIR)
|
46
|
-
include Ironfan::KnifeCommon
|
47
|
-
|
48
|
-
deps do
|
49
|
-
Ironfan::KnifeCommon.load_deps
|
50
|
-
require 'vagrant'
|
51
|
-
require File.expand_path('vagrant/ironfan_environment', IRONFAN_DIR)
|
52
|
-
require File.expand_path('vagrant/ironfan_provisioners', IRONFAN_DIR)
|
53
|
-
end
|
54
|
-
|
55
|
-
banner "knife cluster vagrant CMD CLUSTER[-FACET[-INDEXES]] (options) - runs the given command against a vagrant environment created from your cluster definition. EARLY, use at your own risk"
|
56
|
-
|
57
|
-
option :cloud,
|
58
|
-
:long => "--cloud PROVIDER",
|
59
|
-
:short => "-p",
|
60
|
-
:description => "cloud provider to target, or 'false' to skip cloud-targeted steps. (default false)",
|
61
|
-
:default => false,
|
62
|
-
:boolean => false
|
63
|
-
|
64
|
-
def run
|
65
|
-
# The subnet for this world
|
66
|
-
Chef::Config.host_network_base ||= '33.33.33'
|
67
|
-
# Location that cookbooks, roles, etc will be mounted on vm
|
68
|
-
# set to false to skip
|
69
|
-
Chef::Config.homebase_on_vm_dir "/homebase" if Chef::Config.homebase_on_vm_dir.nil?
|
70
|
-
# yuck. necessary until cloud agnosticism shows up
|
71
|
-
Chef::Config[:cloud] = config[:cloud] = false
|
72
|
-
# TODO: make this customizable
|
73
|
-
Chef::Config[:vagrant_path] = File.expand_path("vagrants", Chef::Config.homebase)
|
74
|
-
|
75
|
-
# standard ironfan knife preamble
|
76
|
-
load_ironfan
|
77
|
-
die("Missing command or slice:\n#{banner}") if @name_args.length < 2
|
78
|
-
die("Too many args:\n#{banner}") if @name_args.length > 2
|
79
|
-
configure_dry_run
|
80
|
-
ui.warn "Vagrant support is VERY rough: the ui will change, displays are inaccurate, may translate your documents into swahili"
|
81
|
-
|
82
|
-
#
|
83
|
-
# Load the servers. Note carefully: this is subtly different from all
|
84
|
-
# the other `knife cluster` commands. Vagrant provides idempotency, but
|
85
|
-
# we want the vagrant file to be invariant to the particular servers
|
86
|
-
# you're asking it to diddle.
|
87
|
-
#
|
88
|
-
# So we configure VMs for all servers in the cluster, but only issue the
|
89
|
-
# cli command against the ones given by the server slice.
|
90
|
-
#
|
91
|
-
vagrant_command, slice_string = @name_args
|
92
|
-
target = get_slice(slice_string)
|
93
|
-
all_servers = target.cluster.servers
|
94
|
-
display(target)
|
95
|
-
|
96
|
-
# Pre-populate information in chef
|
97
|
-
section("Sync'ing to chef and cloud")
|
98
|
-
target.sync_to_chef
|
99
|
-
|
100
|
-
# FIXME: I read somewhere that global variables are a smell for something
|
101
|
-
$ironfan_target = all_servers
|
102
|
-
|
103
|
-
#
|
104
|
-
# Prepare vagrant
|
105
|
-
#
|
106
|
-
section("Configuring vagrant", :green)
|
107
|
-
|
108
|
-
cluster_vagrant_dir = File.expand_path(target.cluster.name.to_s, Chef::Config.vagrant_path)
|
109
|
-
skeleton_vagrantfile = File.expand_path('vagrant/skeleton_vagrantfile.rb', IRONFAN_DIR)
|
110
|
-
|
111
|
-
# using ':vagrantfile_name => skeleton_vagrantfile' doesn't seem to work
|
112
|
-
# in vagrant - the VM comes out incompletely configured in a way I don't
|
113
|
-
# totally understand. Plus it wants its own directory anyhow. So, make a
|
114
|
-
# directory to hold vagrantfiles and push the skeleton in there
|
115
|
-
FileUtils.mkdir_p cluster_vagrant_dir
|
116
|
-
FileUtils.cp skeleton_vagrantfile, File.join(cluster_vagrant_dir, 'vagrantfile')
|
117
|
-
|
118
|
-
log_level = [0, (3 - config[:verbosity])].max
|
119
|
-
env = Vagrant::IronfanEnvironment.new(
|
120
|
-
:ui_class => Vagrant::UI::Colored,
|
121
|
-
:cwd => cluster_vagrant_dir,
|
122
|
-
:log_level => log_level,
|
123
|
-
)
|
124
|
-
|
125
|
-
#
|
126
|
-
# Run command
|
127
|
-
#
|
128
|
-
section("issuing command 'vagrant #{vagrant_command}'", :green)
|
129
|
-
|
130
|
-
target.servers.each do |server|
|
131
|
-
env.cli(vagrant_command, server.fullname)
|
132
|
-
end
|
133
|
-
end
|
134
|
-
|
135
|
-
def display(target)
|
136
|
-
super(target.cluster.servers,
|
137
|
-
["Name", "InstanceID", "State", "Flavor", "Image", "AZ", "Public IP", "Private IP", "Created At", 'Volumes', 'Elastic IP']) do |svr|
|
138
|
-
{ 'targeted?' => (target.include?(svr) ? "[blue]true[reset]" : '-' ), }
|
139
|
-
end
|
140
|
-
end
|
141
|
-
|
142
|
-
end
|
143
|
-
end
|
144
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
module Vagrant
|
2
|
-
class IronfanEnvironment < Vagrant::Environment
|
3
|
-
|
4
|
-
def initialize(opts={})
|
5
|
-
super(opts)
|
6
|
-
munge_logger(opts)
|
7
|
-
end
|
8
|
-
|
9
|
-
|
10
|
-
protected
|
11
|
-
def munge_logger(opts)
|
12
|
-
logger = Log4r::Logger.new("vagrant")
|
13
|
-
logger.outputters = Log4r::Outputter.stderr
|
14
|
-
logger.level = opts[:log_level] || 3
|
15
|
-
logger.info( "ironfan vagrant (#{self}) - cwd: #{cwd}")
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
module Vagrant
|
2
|
-
module Provisioners
|
3
|
-
class IronfanChefClient < Vagrant::Provisioners::ChefClient
|
4
|
-
class Config < Vagrant::Provisioners::ChefClient::Config
|
5
|
-
attr_accessor :upload_client_key
|
6
|
-
end
|
7
|
-
def self.config_class() Config ; end
|
8
|
-
|
9
|
-
def upload_validation_key
|
10
|
-
super()
|
11
|
-
if config.upload_client_key
|
12
|
-
# env[:ui].info I18n.t("vagrant.provisioners.chef.upload_client_key")
|
13
|
-
host_client_key = File.expand_path(config.upload_client_key)
|
14
|
-
env[:vm].channel.upload(host_client_key, tmp_client_key_path)
|
15
|
-
env[:vm].channel.sudo("mv #{tmp_client_key_path} #{config.client_key_path}")
|
16
|
-
env[:vm].channel.sudo("chown root #{config.client_key_path}")
|
17
|
-
env[:vm].channel.sudo("chmod 600 #{config.client_key_path}")
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
def tmp_client_key_path
|
22
|
-
File.join(config.provisioning_path, "client.pem")
|
23
|
-
end
|
24
|
-
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
@@ -1,119 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# ~~ DO NOT EDIT ~~
|
3
|
-
#
|
4
|
-
|
5
|
-
unless defined?(Chef::Config)
|
6
|
-
puts <<-EOL
|
7
|
-
Warning!
|
8
|
-
|
9
|
-
This might *look* like a vagrantfile. However it's only useful when you use
|
10
|
-
`knife cluster vm` to manipulate it. Any changes you put here will be
|
11
|
-
clobbered, and you can't edit the original if you install ironfan as a gem.
|
12
|
-
Annoying, but concentrate on the magic of the jetpack-powered ridiculous
|
13
|
-
cybernetic future magic that's going on here.
|
14
|
-
|
15
|
-
Instead, issue commands like
|
16
|
-
|
17
|
-
knife cluster vagrant COMMAND CLUSTER[-FACET-[INDEXES]]
|
18
|
-
|
19
|
-
Where command is something like
|
20
|
-
|
21
|
-
status up provision reload resume suspend ssh destroy or halt
|
22
|
-
|
23
|
-
EOL
|
24
|
-
exit(2)
|
25
|
-
end
|
26
|
-
|
27
|
-
|
28
|
-
Vagrant::Config.run do |config|
|
29
|
-
|
30
|
-
#
|
31
|
-
# FIXME: the things in this first section need to go somewhere else; need to
|
32
|
-
# learn more abt vagrant to figure out where.
|
33
|
-
#
|
34
|
-
|
35
|
-
# TODO: FIXME: WTF is this hoary horseshit? At *least* do it by cluster-facet,
|
36
|
-
# not just facet (especially since the examples given are all *clusters*)
|
37
|
-
def ip_for(svr)
|
38
|
-
"#{Chef::Config.host_network_base}.#{(Chef::Config.host_network_ip_mapping[svr.facet_name] || 30) + svr.facet_index}"
|
39
|
-
end
|
40
|
-
|
41
|
-
# FIXME: things like this should be imputed by the `cloud` statement
|
42
|
-
ram_mb = Chef::Config.vagrant_ram_mb || 640
|
43
|
-
video_ram_mb = 10
|
44
|
-
cores = Chef::Config.vagrant_cores || 2
|
45
|
-
|
46
|
-
# ===========================================================================
|
47
|
-
#
|
48
|
-
# Configure VM
|
49
|
-
#
|
50
|
-
|
51
|
-
# Boot with a GUI so you can see the screen. (Default is headless)
|
52
|
-
#config.vm.boot_mode = :gui
|
53
|
-
|
54
|
-
# Mount this to see all our chefs and stuff: [type, vm_path, host_path]
|
55
|
-
config.vm.share_folder "homebase", Chef::Config.homebase_on_vm_dir, Chef::Config.homebase
|
56
|
-
|
57
|
-
#
|
58
|
-
# Define a VM for all the targeted servers in the cluster.
|
59
|
-
#
|
60
|
-
# * vm name - server's fullname ('el_ridiculoso-gordo-2')
|
61
|
-
# * vm box - cloud.image_name
|
62
|
-
# * creates host network on the subnet defined in Chef::Config[:host_network_blk]
|
63
|
-
# * populates chef provisioner from the server's run_list
|
64
|
-
#
|
65
|
-
$ironfan_target.servers.each do |svr|
|
66
|
-
config.vm.define svr.fullname.to_sym do |cfg|
|
67
|
-
|
68
|
-
cfg.vm.box = svr.cloud.image_name
|
69
|
-
cfg.vm.network :hostonly, ip_for(svr)
|
70
|
-
# TODO: FIXME: Need to set the "private IP" for each vagrant to something distinct for each node
|
71
|
-
|
72
|
-
#
|
73
|
-
# See http://www.virtualbox.org/manual/ch08.html#idp12418752
|
74
|
-
# for the craziness
|
75
|
-
#
|
76
|
-
vm_customizations = {}
|
77
|
-
vm_customizations[:name] = svr.fullname.to_s
|
78
|
-
vm_customizations[:memory] = ram_mb.to_s if ram_mb
|
79
|
-
vm_customizations[:vram] = video_ram_mb.to_s if video_ram_mb
|
80
|
-
vm_customizations[:cpus] = cores.to_s if cores
|
81
|
-
# Use the host resolver for DNS so that VPN continues to work within the VM
|
82
|
-
vm_customizations[:natdnshostresolver1] = "on"
|
83
|
-
#
|
84
|
-
cfg.vm.customize ["modifyvm", :id, vm_customizations.map{|k,v| ["--#{k}", v]} ].flatten
|
85
|
-
|
86
|
-
# Assign this VM to a bridged network, allowing you to connect directly to a
|
87
|
-
# network using the host's network device. This makes the VM appear as another
|
88
|
-
# physical device on your network.
|
89
|
-
# cfg.vm.network :bridged
|
90
|
-
|
91
|
-
# Forward a port from the guest to the host, which allows for outside
|
92
|
-
# computers to access the VM, whereas host only networking does not.
|
93
|
-
# cfg.vm.forward_port 80, 8080
|
94
|
-
|
95
|
-
cfg.vm.provision Vagrant::Provisioners::IronfanChefClient do |chef|
|
96
|
-
#
|
97
|
-
chef.node_name = svr.fullname
|
98
|
-
|
99
|
-
chef.chef_server_url = svr.chef_server_url
|
100
|
-
chef.validation_client_name = svr.validation_client_name
|
101
|
-
chef.validation_key_path = svr.validation_key
|
102
|
-
chef.upload_client_key = svr.client_key.filename if svr.client_key
|
103
|
-
|
104
|
-
chef.environment = svr.environment
|
105
|
-
chef.json = svr.cloud.user_data
|
106
|
-
|
107
|
-
svr.combined_run_list.each do |run_list_entry|
|
108
|
-
case run_list_entry
|
109
|
-
when /^role\[(\w+)\]$/ then chef.add_role($1) # role[foo]
|
110
|
-
when /^recipe\[(\w+)\]$/ then chef.add_recipe($1) # recipe[foo]
|
111
|
-
else chef.add_recipe(run_list_entry) # foo
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
|
-
end
|
116
|
-
end
|
117
|
-
end
|
118
|
-
|
119
|
-
end
|