knife-ec2 0.6.6.rc.0 → 0.6.6

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -78,7 +78,18 @@ This plugin provides the following Knife subcommands. Specific command options c
78
78
 
79
79
 
80
80
  #### `knife ec2 server create`
81
- Provisions a new server in the Amazon EC2 and then perform a Chef bootstrap (using the SSH protocol). The goal of the bootstrap is to get Chef installed on the target system so it can run Chef Client with a Chef Server. The main assumption is a baseline OS installation exists (provided by the provisioning). It is primarily intended for Chef Client systems that talk to a Chef server.
81
+ Provisions a new server in the Amazon EC2 and then perform a Chef bootstrap
82
+ (using the SSH or WinRM protocols). The goal of the bootstrap is to get Chef installed on the target system so it can run Chef Client with a Chef Server. The main assumption is a baseline OS installation exists (provided by the provisioning). It is primarily intended for Chef Client systems that talk to a Chef server. The examples below create Linux and Windows instances:
83
+
84
+ # Create some instances -- knife configuration contains the AWS credentials
85
+
86
+ # A Linux instance via ssh
87
+ knife ec2 server create -I ami-d0f89fb9 --ssh-key your-public-key-id -f m1.medium --ssh-user ubuntu --identity-file ~/.ssh/your-private-key
88
+
89
+ # A Windows instance via the WinRM protocol -- --ssh-key is still required due to EC2 API operations that need it to grant access to the Windows instance
90
+ knife ec2 server create -I ami-173d747e -G windows -f m1.medium --user-data ~/your-user-data-file -x '.\a_local_user' -P 'yourpassword' --ssh-key your-public-key-id
91
+
92
+ View additional information on configuring Windows images for bootstrap in the documentation for [knife-windows](http://docs.opscode.com/plugin_knife_windows.html).
82
93
 
83
94
  #### `knife ec2 server delete`
84
95
  Deletes an existing server in the currently configured AWS account. **By default, this does not delete the associated node and client objects from the Chef server. To do so, add the `--purge` flag**
@@ -398,7 +398,7 @@ class Chef
398
398
  begin
399
399
  create_tags(hashed_tags) unless hashed_tags.empty?
400
400
  associate_eip(elastic_ip) if config[:associate_eip]
401
- rescue Fog::Compute::AWS::NotFound => e
401
+ rescue Fog::Compute::AWS::NotFound, Fog::Errors::Error => e
402
402
  raise if (tries -= 1) <= 0
403
403
  ui.warn("server not ready, retrying tag application (retries left: #{tries})")
404
404
  sleep 5
@@ -437,10 +437,12 @@ class Chef
437
437
  sleep @initial_sleep_delay ||= (vpc_mode? ? 40 : 10)
438
438
  puts("done")
439
439
  }
440
+ ssh_override_winrm
440
441
  end
441
442
  bootstrap_for_windows_node(@server,ssh_connect_host).run
442
443
  else
443
444
  wait_for_sshd(ssh_connect_host)
445
+ ssh_override_winrm
444
446
  bootstrap_for_linux_node(@server,ssh_connect_host).run
445
447
  end
446
448
 
@@ -729,6 +731,29 @@ class Chef
729
731
  connection.associate_address(server.id, elastic_ip.public_ip, nil, elastic_ip.allocation_id)
730
732
  @server.wait_for { public_ip_address == elastic_ip.public_ip }
731
733
  end
734
+
735
+ def ssh_override_winrm
736
+ # unchanged ssh_user and changed winrm_user, override ssh_user
737
+ if locate_config_value(:ssh_user).eql?(options[:ssh_user][:default]) &&
738
+ !locate_config_value(:winrm_user).eql?(options[:winrm_user][:default])
739
+ config[:ssh_user] = locate_config_value(:winrm_user)
740
+ end
741
+ # unchanged ssh_port and changed winrm_port, override ssh_port
742
+ if locate_config_value(:ssh_port).eql?(options[:ssh_port][:default]) &&
743
+ !locate_config_value(:winrm_port).eql?(options[:winrm_port][:default])
744
+ config[:ssh_port] = locate_config_value(:winrm_port)
745
+ end
746
+ # unset ssh_password and set winrm_password, override ssh_password
747
+ if locate_config_value(:ssh_password).nil? &&
748
+ !locate_config_value(:winrm_password).nil?
749
+ config[:ssh_password] = locate_config_value(:winrm_password)
750
+ end
751
+ # unset identity_file and set kerberos_keytab_file, override identity_file
752
+ if locate_config_value(:identity_file).nil? &&
753
+ !locate_config_value(:kerberos_keytab_file).nil?
754
+ config[:identity_file] = locate_config_value(:kerberos_keytab_file)
755
+ end
756
+ end
732
757
  end
733
758
  end
734
759
  end
@@ -1,6 +1,6 @@
1
1
  module Knife
2
2
  module Ec2
3
- VERSION = "0.6.6.rc.0"
3
+ VERSION = "0.6.6"
4
4
  MAJOR, MINOR, TINY = VERSION.split('.')
5
5
  end
6
6
  end
@@ -96,10 +96,59 @@ describe Chef::Knife::Ec2ServerCreate do
96
96
 
97
97
  it "creates an EC2 instance and bootstraps it" do
98
98
  @new_ec2_server.should_receive(:wait_for).and_return(true)
99
+ @knife_ec2_create.should_receive(:ssh_override_winrm)
99
100
  @knife_ec2_create.run
100
101
  @knife_ec2_create.server.should_not == nil
101
102
  end
102
103
 
104
+ it "set ssh_user value by using -x option for ssh bootstrap protocol or linux image" do
105
+ # Currently -x option set config[:winrm_user]
106
+ # default value of config[:ssh_user] is root
107
+ @knife_ec2_create.config[:winrm_user] = "ubuntu"
108
+ @knife_ec2_create.config[:ssh_user] = "root"
109
+
110
+ @new_ec2_server.should_receive(:wait_for).and_return(true)
111
+ @knife_ec2_create.run
112
+ @knife_ec2_create.config[:ssh_user].should == "ubuntu"
113
+ @knife_ec2_create.server.should_not == nil
114
+ end
115
+
116
+ it "set ssh_password value by using -P option for ssh bootstrap protocol or linux image" do
117
+ # Currently -P option set config[:winrm_password]
118
+ # default value of config[:ssh_password] is nil
119
+ @knife_ec2_create.config[:winrm_password] = "winrm_password"
120
+ @knife_ec2_create.config[:ssh_password] = nil
121
+
122
+ @new_ec2_server.should_receive(:wait_for).and_return(true)
123
+ @knife_ec2_create.run
124
+ @knife_ec2_create.config[:ssh_password].should == "winrm_password"
125
+ @knife_ec2_create.server.should_not == nil
126
+ end
127
+
128
+ it "set ssh_port value by using -p option for ssh bootstrap protocol or linux image" do
129
+ # Currently -p option set config[:winrm_port]
130
+ # default value of config[:ssh_port] is 22
131
+ @knife_ec2_create.config[:winrm_port] = "1234"
132
+ @knife_ec2_create.config[:ssh_port] = "22"
133
+
134
+ @new_ec2_server.should_receive(:wait_for).and_return(true)
135
+ @knife_ec2_create.run
136
+ @knife_ec2_create.config[:ssh_port].should == "1234"
137
+ @knife_ec2_create.server.should_not == nil
138
+ end
139
+
140
+ it "set identity_file value by using -i option for ssh bootstrap protocol or linux image" do
141
+ # Currently -i option set config[:kerberos_keytab_file]
142
+ # default value of config[:identity_file] is nil
143
+ @knife_ec2_create.config[:kerberos_keytab_file] = "kerberos_keytab_file"
144
+ @knife_ec2_create.config[:identity_file] = nil
145
+
146
+ @new_ec2_server.should_receive(:wait_for).and_return(true)
147
+ @knife_ec2_create.run
148
+ @knife_ec2_create.config[:identity_file].should == "kerberos_keytab_file"
149
+ @knife_ec2_create.server.should_not == nil
150
+ end
151
+
103
152
  it "should never invoke windows bootstrap for linux instance" do
104
153
  @new_ec2_server.should_receive(:wait_for).and_return(true)
105
154
  @knife_ec2_create.should_not_receive(:bootstrap_for_windows_node)
@@ -149,6 +198,7 @@ describe Chef::Knife::Ec2ServerCreate do
149
198
  @bootstrap_winrm = Chef::Knife::BootstrapWindowsWinrm.new
150
199
  Chef::Knife::BootstrapWindowsWinrm.stub(:new).and_return(@bootstrap_winrm)
151
200
  @bootstrap_winrm.should_receive(:run)
201
+ @knife_ec2_create.should_not_receive(:ssh_override_winrm)
152
202
  @new_ec2_server.should_receive(:wait_for).and_return(true)
153
203
  @knife_ec2_create.run
154
204
  end
@@ -169,6 +219,7 @@ describe Chef::Knife::Ec2ServerCreate do
169
219
  bootstrap_win_ssh = Chef::Knife::BootstrapWindowsSsh.new
170
220
  Chef::Knife::BootstrapWindowsSsh.stub(:new).and_return(bootstrap_win_ssh)
171
221
  bootstrap_win_ssh.should_receive(:run)
222
+ @knife_ec2_create.should_receive(:ssh_override_winrm)
172
223
  @new_ec2_server.should_receive(:wait_for).and_return(true)
173
224
  @knife_ec2_create.run
174
225
  end
metadata CHANGED
@@ -1,129 +1,121 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: knife-ec2
3
- version: !ruby/object:Gem::Version
4
- hash: 1549375601
5
- prerelease: 6
6
- segments:
7
- - 0
8
- - 6
9
- - 6
10
- - rc
11
- - 0
12
- version: 0.6.6.rc.0
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.6.6
5
+ prerelease:
13
6
  platform: ruby
14
- authors:
7
+ authors:
15
8
  - Adam Jacob
16
9
  - Seth Chisamore
17
10
  autorequire:
18
11
  bindir: bin
19
12
  cert_chain: []
20
-
21
- date: 2013-10-28 00:00:00 Z
22
- dependencies:
23
- - !ruby/object:Gem::Dependency
13
+ date: 2013-10-31 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
24
16
  name: fog
25
- prerelease: false
26
- requirement: &id001 !ruby/object:Gem::Requirement
17
+ requirement: !ruby/object:Gem::Requirement
27
18
  none: false
28
- requirements:
19
+ requirements:
29
20
  - - ~>
30
- - !ruby/object:Gem::Version
31
- hash: 43
32
- segments:
33
- - 1
34
- - 15
35
- - 0
21
+ - !ruby/object:Gem::Version
36
22
  version: 1.15.0
37
23
  type: :runtime
38
- version_requirements: *id001
39
- - !ruby/object:Gem::Dependency
40
- name: chef
41
24
  prerelease: false
42
- requirement: &id002 !ruby/object:Gem::Requirement
25
+ version_requirements: !ruby/object:Gem::Requirement
43
26
  none: false
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- hash: 35
48
- segments:
49
- - 0
50
- - 10
51
- - 10
27
+ requirements:
28
+ - - ~>
29
+ - !ruby/object:Gem::Version
30
+ version: 1.15.0
31
+ - !ruby/object:Gem::Dependency
32
+ name: chef
33
+ requirement: !ruby/object:Gem::Requirement
34
+ none: false
35
+ requirements:
36
+ - - ! '>='
37
+ - !ruby/object:Gem::Version
52
38
  version: 0.10.10
53
39
  type: :runtime
54
- version_requirements: *id002
55
- - !ruby/object:Gem::Dependency
56
- name: knife-windows
57
40
  prerelease: false
58
- requirement: &id003 !ruby/object:Gem::Requirement
41
+ version_requirements: !ruby/object:Gem::Requirement
59
42
  none: false
60
- requirements:
61
- - - ">="
62
- - !ruby/object:Gem::Version
63
- hash: 19
64
- segments:
65
- - 0
66
- - 5
67
- - 12
43
+ requirements:
44
+ - - ! '>='
45
+ - !ruby/object:Gem::Version
46
+ version: 0.10.10
47
+ - !ruby/object:Gem::Dependency
48
+ name: knife-windows
49
+ requirement: !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
68
54
  version: 0.5.12
69
55
  type: :runtime
70
- version_requirements: *id003
71
- - !ruby/object:Gem::Dependency
72
- name: rspec
73
56
  prerelease: false
74
- requirement: &id004 !ruby/object:Gem::Requirement
57
+ version_requirements: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ! '>='
61
+ - !ruby/object:Gem::Version
62
+ version: 0.5.12
63
+ - !ruby/object:Gem::Dependency
64
+ name: rspec
65
+ requirement: !ruby/object:Gem::Requirement
75
66
  none: false
76
- requirements:
67
+ requirements:
77
68
  - - ~>
78
- - !ruby/object:Gem::Version
79
- hash: 31
80
- segments:
81
- - 2
82
- - 14
83
- version: "2.14"
69
+ - !ruby/object:Gem::Version
70
+ version: '2.14'
84
71
  type: :development
85
- version_requirements: *id004
86
- - !ruby/object:Gem::Dependency
87
- name: rake
88
72
  prerelease: false
89
- requirement: &id005 !ruby/object:Gem::Requirement
73
+ version_requirements: !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ~>
77
+ - !ruby/object:Gem::Version
78
+ version: '2.14'
79
+ - !ruby/object:Gem::Dependency
80
+ name: rake
81
+ requirement: !ruby/object:Gem::Requirement
90
82
  none: false
91
- requirements:
83
+ requirements:
92
84
  - - ~>
93
- - !ruby/object:Gem::Version
94
- hash: 33
95
- segments:
96
- - 10
97
- - 1
98
- version: "10.1"
85
+ - !ruby/object:Gem::Version
86
+ version: '10.1'
99
87
  type: :development
100
- version_requirements: *id005
101
- - !ruby/object:Gem::Dependency
102
- name: sdoc
103
88
  prerelease: false
104
- requirement: &id006 !ruby/object:Gem::Requirement
89
+ version_requirements: !ruby/object:Gem::Requirement
90
+ none: false
91
+ requirements:
92
+ - - ~>
93
+ - !ruby/object:Gem::Version
94
+ version: '10.1'
95
+ - !ruby/object:Gem::Dependency
96
+ name: sdoc
97
+ requirement: !ruby/object:Gem::Requirement
105
98
  none: false
106
- requirements:
99
+ requirements:
107
100
  - - ~>
108
- - !ruby/object:Gem::Version
109
- hash: 13
110
- segments:
111
- - 0
112
- - 3
113
- version: "0.3"
101
+ - !ruby/object:Gem::Version
102
+ version: '0.3'
114
103
  type: :development
115
- version_requirements: *id006
104
+ prerelease: false
105
+ version_requirements: !ruby/object:Gem::Requirement
106
+ none: false
107
+ requirements:
108
+ - - ~>
109
+ - !ruby/object:Gem::Version
110
+ version: '0.3'
116
111
  description: EC2 Support for Chef\'s Knife Command
117
- email:
112
+ email:
118
113
  - adam@opscode.com
119
114
  - schisamo@opscode.com
120
115
  executables: []
121
-
122
116
  extensions: []
123
-
124
117
  extra_rdoc_files: []
125
-
126
- files:
118
+ files:
127
119
  - .gitignore
128
120
  - .travis.yml
129
121
  - Gemfile
@@ -142,40 +134,32 @@ files:
142
134
  - spec/unit/ec2_server_create_spec.rb
143
135
  - spec/unit/ec2_server_delete_spec.rb
144
136
  homepage: https://github.com/opscode/knife-ec2
145
- licenses:
137
+ licenses:
146
138
  - Apache 2.0
147
139
  post_install_message:
148
140
  rdoc_options: []
149
-
150
- require_paths:
141
+ require_paths:
151
142
  - lib
152
- required_ruby_version: !ruby/object:Gem::Requirement
143
+ required_ruby_version: !ruby/object:Gem::Requirement
153
144
  none: false
154
- requirements:
155
- - - ">="
156
- - !ruby/object:Gem::Version
157
- hash: 3
158
- segments:
159
- - 0
160
- version: "0"
161
- required_rubygems_version: !ruby/object:Gem::Requirement
145
+ requirements:
146
+ - - ! '>='
147
+ - !ruby/object:Gem::Version
148
+ version: '0'
149
+ required_rubygems_version: !ruby/object:Gem::Requirement
162
150
  none: false
163
- requirements:
164
- - - ">"
165
- - !ruby/object:Gem::Version
166
- hash: 25
167
- segments:
168
- - 1
169
- - 3
170
- - 1
171
- version: 1.3.1
151
+ requirements:
152
+ - - ! '>='
153
+ - !ruby/object:Gem::Version
154
+ version: '0'
172
155
  requirements: []
173
-
174
156
  rubyforge_project:
175
- rubygems_version: 1.8.10
157
+ rubygems_version: 1.8.23
176
158
  signing_key:
177
159
  specification_version: 3
178
160
  summary: EC2 Support for Chef\'s Knife Command
179
- test_files: []
180
-
161
+ test_files:
162
+ - spec/spec_helper.rb
163
+ - spec/unit/ec2_server_create_spec.rb
164
+ - spec/unit/ec2_server_delete_spec.rb
181
165
  has_rdoc: