ironfan 4.4.1 → 4.4.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.
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ # v4.4.2:
2
+ * Support for intra-cluster ICMP and specs to prove it (thanks @nickmarden)
3
+ * Knife bash completion script: see config/knife.bash.README.md for installation (thanks @schade)
4
+
1
5
  # v4.4.1:
2
6
  * Re-enables integration specs, explicitly excluding them from "rake spec" (@nickmarden)
3
7
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 4.4.1
1
+ 4.4.2
data/config/knife.bash ADDED
@@ -0,0 +1,153 @@
1
+ # Original Author: Avishai Ish-Shalom <avishai@fewbytes.com>
2
+ # Minor Ironfan-esque additions: Jerry Jackson <jerry.w.jackson@gmail.com>
3
+
4
+ # first argument set the command level
5
+ _get_knife_completions() {
6
+ n=$1
7
+ shift
8
+ # first argument is knife, so shift it
9
+ #[ "$1" == "knife" ] && shift
10
+ local opts
11
+ opts="$($@ --help | grep -E '^knife' | cut -f$n -d" " | grep -v -E '[][[:upper:].]+' |grep -v '(options)' | sort -u)"
12
+ _upvar opts "$opts"
13
+ return 0
14
+ }
15
+
16
+ _flatten_knife_command() {
17
+ echo ${words[*]:0:$(( ${#words[*]} -1 ))} | tr ' ' '_'
18
+ }
19
+ # Check cache file for category in file ( passed as $1 ) and run command if cache is empty
20
+ # Designed to be used with _get_knife_completions() and use the opts variables for options
21
+ _completion_cache() {
22
+ local flag COMMAND
23
+ local OPTIND=1
24
+ while getopts "c" flag "$@"; do
25
+ case $flag in
26
+ c)
27
+ COMMAND=yes
28
+ ;;
29
+ *)
30
+ ;;
31
+ esac
32
+ done
33
+ shift $(( $OPTIND - 1 ))
34
+
35
+ local CACHE_FILE="$1"
36
+ shift
37
+ if [ ! -f "$CACHE_FILE" ]; then
38
+ if [[ "$COMMAND" == "yes" ]]; then
39
+ opts=$( eval $@ 2>/dev/null )
40
+ RET=$?
41
+ else
42
+ $@ 2>/dev/null
43
+ RET=$?
44
+ fi
45
+ if [[ $RET -eq 0 ]]; then
46
+ [ -d "$(dirname "$CACHE_FILE")" ] && echo $opts >"$CACHE_FILE"
47
+ else
48
+ unset opts
49
+ fi
50
+ else
51
+ opts=$(cat "$CACHE_FILE")
52
+ fi
53
+ _upvar opts "$opts"
54
+ }
55
+
56
+ _chef_completion_cache() {
57
+ local CACHE_DIR=${CHEF_HOME:-"$HOME/.chef"}/.completion_cache
58
+ unset C
59
+ local C
60
+ if [[ "$1" == "-c" ]]; then
61
+ C="-c"
62
+ shift
63
+ fi
64
+ CACHE_FILE="$CACHE_DIR/$1"; shift
65
+ _completion_cache $C "$CACHE_FILE" "$@"
66
+ _upvar opts "$opts"
67
+ }
68
+
69
+ _knife() {
70
+ if [[ ${cur} =~ /^-/ ]]; then
71
+ return 0
72
+ fi
73
+ local opts cur prev cword words flattened_knife_command
74
+ _chef_completion_cache knife_commands _get_knife_completions 2 knife
75
+ _get_comp_words_by_ref cur prev cword words
76
+ flattened_knife_command=$(_flatten_knife_command)
77
+ COMPREPLY=()
78
+ case $flattened_knife_command in
79
+ *from_file|from_file_*)
80
+ COMPREPLY=( $(compgen -f -- ${cur} ) )
81
+ return 0
82
+ ;;
83
+ *knife_cookbook_upload|*knife_cookbook_test)
84
+ local chef_repos
85
+ if [[ -z $CHEF_REPOS ]]; then
86
+ CHEF_CONFIG="${CHEF_HOME:-$HOME/.chef}/knife.rb"
87
+ chef_repos=( $( ruby -e "def cookbook_path(*args); args.each{|a| puts a }; end; eval(File.open('$CHEF_CONFIG','r').lines.select{|l| l =~ /cookbook_path/}.first)" ) )
88
+ else
89
+ chef_repos=( ${CHEF_REPOS[@]} )
90
+ fi
91
+ if [[ -n "$chef_repos" ]]; then
92
+ opts=$( ls -1p ${chef_repos[@]} | sort -u | ${SED} -n 's/\/$//p' )
93
+ COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
94
+ fi
95
+ ;;
96
+ *knife_data)
97
+ opts="bag"
98
+ COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
99
+ return 0
100
+ ;;
101
+ *knife_search)
102
+ _chef_completion_cache -c ${words[0]}_data_bags "${words[0]} data bag list|${SED} -r -e 's/[\"\ ,]//g' -e '/[^0-9A-Za-z._-]+/d'"
103
+ OPTS="node ${opts}"
104
+ COMPREPLY=( $(compgen -W "${OPTS}" -- ${cur}) )
105
+ return 0
106
+ ;;
107
+ *knife_node_show|*knife_node_edit|*knife_node_delete|*knife_tag_*)
108
+ _chef_completion_cache -c ${words[0]}_nodes "${words[0]} node list|${SED} -r -e 's/[\"\ ,]//g' -e '/[^0-9A-Za-z._-]+/d'"
109
+ COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
110
+ return 0
111
+ ;;
112
+ *knife_role_edit|*knife_role_show|*knife_role_delete)
113
+ _chef_completion_cache -c ${words[0]}_roles "${words[0]} role list|${SED} -r -e 's/[\"\ ,]//g' -e '/[^0-9A-Za-z._-]+/d'"
114
+ COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
115
+ return 0
116
+ ;;
117
+ *knife_data_bag_delete|*knife_data_bag_show|*knife_data_bag_edit)
118
+ _chef_completion_cache -c ${words[0]}_data_bags "${words[0]} data bag list|${SED} -r -e 's/[\"\ ,]//g' -e '/[^0-9A-Za-z._-]+/d'"
119
+ COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
120
+ return 0
121
+ ;;
122
+ *knife_data_bag_delete_*|*knife_data_bag_show_*|*knife_data_bag_edit_*)
123
+ _chef_completion_cache -c ${words[0]}_data_bag_$prev "${words[0]} data bag show $prev 2>/dev/null|${SED} -r -e 's/[\"\ ,]//g' -e '/^[^0-9A-Za-z._-]+/d'"
124
+ COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
125
+ return 0
126
+ ;;
127
+ *knife_client_list|*knife_client_show|*knife_client_edit)
128
+ _chef_completion_cache -c ${words[0]}_clients "${words[0]} client list|${SED} -r -e 's/[\"\ ,]//g' -e '/[^0-9A-Za-z._-]+/d'"
129
+ COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
130
+ return 0
131
+ ;;
132
+ *knife_environment_show|*knife_environment_edit|*knife_environment_delete)
133
+ _chef_completion_cache -c ${words[0]}_environments "${words[0]} environment list|${SED} -r -e 's/[\"\ ,]//g' -e '/[^0-9A-Za-z._-]+/d'"
134
+ COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
135
+ return 0
136
+ ;;
137
+ *)
138
+ case $cword in
139
+ 1)
140
+ COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
141
+ return 0
142
+ ;;
143
+ *)
144
+ _chef_completion_cache $flattened_knife_command _get_knife_completions $(( $cword + 1 )) ${words[*]}
145
+ COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
146
+ return 0
147
+ ;;
148
+ esac
149
+ ;;
150
+ esac
151
+ [[ ${#COMPREPLY[@]} -ge 1 ]] && return 0
152
+ }
153
+ complete -F _knife knife
@@ -0,0 +1,13 @@
1
+ # knife bash completion
2
+
3
+ ## Installation
4
+ =================
5
+ 1) Place the file knife.bash where bash expects to find it's autocompletion scripts.
6
+ On most modern unices this would equate to '/etc/bash_completion.d/'. This has
7
+ been verified in, at least, Ubuntu and Gentoo.
8
+ 2) Restart your shell.
9
+ 3) Enjoy tab-completion of your knife commands.
10
+
11
+ ## Overview
12
+ =================
13
+ Credit goes to the original author; Avishai Ish-Shalom <avishai@fewbytes.com>. I have made and will continue to make needed changes; eg. things present in Ironfan but not in vanilla Chef.
data/ironfan.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "ironfan"
8
- s.version = "4.4.1"
8
+ s.version = "4.4.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Infochimps"]
12
- s.date = "2012-10-23"
12
+ s.date = "2012-10-24"
13
13
  s.description = "Ironfan allows you to orchestrate not just systems but clusters of machines. It includes a powerful layer on top of knife and a collection of cloud cookbooks."
14
14
  s.email = "coders@infochimps.com"
15
15
  s.extra_rdoc_files = [
@@ -31,6 +31,8 @@ Gem::Specification.new do |s|
31
31
  "VERSION",
32
32
  "chefignore",
33
33
  "config/client.rb",
34
+ "config/knife.bash",
35
+ "config/knife.bash.README.md",
34
36
  "config/proxy.pac",
35
37
  "config/ubuntu10.04-ironfan.erb",
36
38
  "config/ubuntu11.10-ironfan.erb",
@@ -129,6 +131,7 @@ Gem::Specification.new do |s|
129
131
  "spec/integration/minimal-chef-repo/knife/knife.rb",
130
132
  "spec/integration/minimal-chef-repo/roles/systemwide.rb",
131
133
  "spec/integration/spec/elb_build_spec.rb",
134
+ "spec/integration/spec/simple_cluster_spec.rb",
132
135
  "spec/integration/spec_helper.rb",
133
136
  "spec/integration/spec_helper/launch_cluster.rb",
134
137
  "spec/ironfan/cluster_spec.rb",
@@ -145,7 +148,7 @@ Gem::Specification.new do |s|
145
148
  s.require_paths = ["lib"]
146
149
  s.rubygems_version = "1.8.24"
147
150
  s.summary = "Ironfan allows you to orchestrate not just systems but clusters of machines. It includes a powerful layer on top of knife and a collection of cloud cookbooks."
148
- s.test_files = ["spec/spec_helper/dummy_chef.rb", "spec/integration/spec_helper/launch_cluster.rb", "spec/integration/minimal-chef-repo/roles/systemwide.rb", "spec/integration/minimal-chef-repo/environments/_default.json", "spec/integration/minimal-chef-repo/chefignore", "spec/integration/minimal-chef-repo/knife/knife.rb", "spec/integration/minimal-chef-repo/knife/credentials/knife-user-ironfantester.rb", "spec/integration/minimal-chef-repo/knife/credentials/knife-org.rb", "spec/integration/spec/elb_build_spec.rb", "spec/integration/spec_helper.rb", "spec/ironfan/cluster_spec.rb", "spec/ironfan/ec2/cloud_provider_spec.rb", "spec/ironfan/ec2/elb_spec.rb", "spec/ironfan/ec2/security_group_spec.rb", "spec/chef/cluster_bootstrap_spec.rb", "spec/fixtures/gunbai_slice.json", "spec/fixtures/ec2/elb/snakeoil.key", "spec/fixtures/ec2/elb/snakeoil.crt", "spec/fixtures/gunbai.rb", "spec/spec_helper.rb", "spec/test_config.rb"]
151
+ s.test_files = ["spec/spec_helper/dummy_chef.rb", "spec/integration/spec_helper/launch_cluster.rb", "spec/integration/minimal-chef-repo/roles/systemwide.rb", "spec/integration/minimal-chef-repo/environments/_default.json", "spec/integration/minimal-chef-repo/chefignore", "spec/integration/minimal-chef-repo/knife/knife.rb", "spec/integration/minimal-chef-repo/knife/credentials/knife-user-ironfantester.rb", "spec/integration/minimal-chef-repo/knife/credentials/knife-org.rb", "spec/integration/spec/simple_cluster_spec.rb", "spec/integration/spec/elb_build_spec.rb", "spec/integration/spec_helper.rb", "spec/ironfan/cluster_spec.rb", "spec/ironfan/ec2/cloud_provider_spec.rb", "spec/ironfan/ec2/elb_spec.rb", "spec/ironfan/ec2/security_group_spec.rb", "spec/chef/cluster_bootstrap_spec.rb", "spec/fixtures/gunbai_slice.json", "spec/fixtures/ec2/elb/snakeoil.key", "spec/fixtures/ec2/elb/snakeoil.crt", "spec/fixtures/gunbai.rb", "spec/spec_helper.rb", "spec/test_config.rb"]
149
152
 
150
153
  if s.respond_to? :specification_version then
151
154
  s.specification_version = 3
@@ -3,6 +3,9 @@ module Ironfan
3
3
  class Ec2
4
4
 
5
5
  class SecurityGroup < Ironfan::Provider::Resource
6
+
7
+ WIDE_OPEN = Range.new(1,65535)
8
+
6
9
  delegate :_dump, :authorize_group_and_owner, :authorize_port_range,
7
10
  :collection, :collection=, :connection, :connection=, :description,
8
11
  :description=, :destroy, :group_id, :group_id=, :identity,
@@ -114,14 +117,14 @@ module Ironfan
114
117
  other_group_fog = recall_with_vpc(other_group,cloud.vpc)
115
118
  Ironfan.step(dsl_group.name, " ensuring access from #{other_group}", :blue)
116
119
  options = {:group => other_group_fog.group_id}
117
- safely_authorize(dsl_group_fog, 1..65535, options)
120
+ safely_authorize(dsl_group_fog, WIDE_OPEN, options)
118
121
  end
119
122
 
120
123
  dsl_group.group_authorized_by.each do |other_group|
121
124
  other_group_fog = recall_with_vpc(other_group,cloud.vpc)
122
125
  Ironfan.step(dsl_group.name, " ensuring access to #{other_group}", :blue)
123
126
  options = {:group => dsl_group_fog.group_id}
124
- safely_authorize(other_group_fog, 1..65535, options)
127
+ safely_authorize(other_group_fog, WIDE_OPEN, options)
125
128
  end
126
129
 
127
130
  dsl_group.range_authorizations.each do |range_auth|
@@ -156,6 +159,7 @@ module Ironfan
156
159
  unless options[:ip_protocol]
157
160
  safely_authorize(fog_group,range,options.merge(:ip_protocol => 'tcp'))
158
161
  safely_authorize(fog_group,range,options.merge(:ip_protocol => 'udp'))
162
+ safely_authorize(fog_group,Range.new(-1,-1),options.merge(:ip_protocol => 'icmp')) if(range == WIDE_OPEN)
159
163
  return
160
164
  end
161
165
 
@@ -0,0 +1,82 @@
1
+ require_relative '../spec_helper'
2
+
3
+ Ironfan.cluster "simple" do
4
+
5
+ cloud(:ec2) do
6
+ availability_zones ('b'..'d').map { |z| "us-east-1#{z}" }
7
+ flavor 't1.micro'
8
+ backing 'ebs'
9
+ image_name 'alestic-precise'
10
+ chef_client_script 'client.rb'
11
+ security_group :systemwide
12
+ security_group :ssh do
13
+ authorize_port_range(22..22)
14
+ end
15
+ mount_ephemerals
16
+ end
17
+
18
+ facet :web do
19
+ instances 1
20
+ end
21
+
22
+ facet :db do
23
+ instances 1
24
+ end
25
+ end
26
+
27
+
28
+ launch_cluster 'simple' do |cluster, computers|
29
+ describe "the simple cluster" do
30
+
31
+ it "should have the correct number of running computers" do
32
+ computers.size.should == cluster.facets.keys.inject(0) { |size, facet| size + cluster.facets[facet].instances }
33
+ computers.values.reject { |c| c.running? }.should be_empty
34
+ end
35
+
36
+ describe "the web facet security groups" do
37
+ subject { cluster.facets[:web].server(0).cloud(:ec2).security_groups.keys.map(&:to_s).sort }
38
+ it { should == %w[ simple simple-web ssh systemwide ] }
39
+ end
40
+
41
+ describe "the db facet security groups" do
42
+ subject { cluster.facets[:db].server(0).cloud(:ec2).security_groups.keys.map(&:to_s).sort }
43
+ it { should == %w[ simple simple-db ssh systemwide ] }
44
+ end
45
+
46
+ describe "the cluster-wide security group" do
47
+ before :each do
48
+ @sg = Ironfan::Provider::Ec2::SecurityGroup.recall('simple')
49
+ @ordered_ipp = Hash[ @sg.ip_permissions.map { |s| [ s['ipProtocol'], s ] } ]
50
+ end
51
+
52
+ it "has the right number of inbound security rules" do
53
+ @ordered_ipp.keys.size == 3
54
+ end
55
+
56
+ it "allows TCP connections on all ports between all servers in the security group" do
57
+ @ordered_ipp['tcp']['groups'].size.should == 1
58
+ @ordered_ipp['tcp']['groups'][0]['groupId'].should == @sg.group_id
59
+ @ordered_ipp['tcp']['groups'][0]['groupName'].should == 'simple'
60
+ @ordered_ipp['tcp']['fromPort'].to_i.should == 1
61
+ @ordered_ipp['tcp']['toPort'].to_i.should == 65535
62
+ end
63
+
64
+ it "allows UDP connections on all ports between all servers in the security group" do
65
+ @ordered_ipp['udp']['groups'].size.should == 1
66
+ @ordered_ipp['udp']['groups'][0]['groupId'].should == @sg.group_id
67
+ @ordered_ipp['udp']['groups'][0]['groupName'].should == 'simple'
68
+ @ordered_ipp['udp']['fromPort'].to_i.should == 1
69
+ @ordered_ipp['udp']['toPort'].to_i.should == 65535
70
+ end
71
+
72
+ it "allows ICMP connections between all servers in the security group" do
73
+ @ordered_ipp['icmp']['groups'].size.should == 1
74
+ @ordered_ipp['icmp']['groups'][0]['groupId'].should == @sg.group_id
75
+ @ordered_ipp['icmp']['groups'][0]['groupName'].should == 'simple'
76
+ @ordered_ipp['icmp']['fromPort'].to_i.should == -1
77
+ @ordered_ipp['icmp']['toPort'].to_i.should == -1
78
+ end
79
+
80
+ end
81
+ end
82
+ end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: ironfan
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 4.4.1
5
+ version: 4.4.2
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-10-23 00:00:00 Z
13
+ date: 2012-10-24 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: chef
@@ -157,6 +157,8 @@ files:
157
157
  - VERSION
158
158
  - chefignore
159
159
  - config/client.rb
160
+ - config/knife.bash
161
+ - config/knife.bash.README.md
160
162
  - config/proxy.pac
161
163
  - config/ubuntu10.04-ironfan.erb
162
164
  - config/ubuntu11.10-ironfan.erb
@@ -255,6 +257,7 @@ files:
255
257
  - spec/integration/minimal-chef-repo/knife/knife.rb
256
258
  - spec/integration/minimal-chef-repo/roles/systemwide.rb
257
259
  - spec/integration/spec/elb_build_spec.rb
260
+ - spec/integration/spec/simple_cluster_spec.rb
258
261
  - spec/integration/spec_helper.rb
259
262
  - spec/integration/spec_helper/launch_cluster.rb
260
263
  - spec/ironfan/cluster_spec.rb
@@ -278,7 +281,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
278
281
  requirements:
279
282
  - - ">="
280
283
  - !ruby/object:Gem::Version
281
- hash: 688283162375062517
284
+ hash: -2266640739538756460
282
285
  segments:
283
286
  - 0
284
287
  version: "0"
@@ -304,6 +307,7 @@ test_files:
304
307
  - spec/integration/minimal-chef-repo/knife/knife.rb
305
308
  - spec/integration/minimal-chef-repo/knife/credentials/knife-user-ironfantester.rb
306
309
  - spec/integration/minimal-chef-repo/knife/credentials/knife-org.rb
310
+ - spec/integration/spec/simple_cluster_spec.rb
307
311
  - spec/integration/spec/elb_build_spec.rb
308
312
  - spec/integration/spec_helper.rb
309
313
  - spec/ironfan/cluster_spec.rb