Skip to content

Commit 7fb5637

Browse files
committed
## 0.10.2
* Update the README * Fix some spec tests * Fix bug in `config` that did not allow `HostName` directive * support group ownership
1 parent 1d55b25 commit 7fb5637

8 files changed

Lines changed: 30 additions & 34 deletions

File tree

.kitchen.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ driver:
33
name: vagrant
44

55
driver_config:
6-
require_chef_omnibus: true
6+
require_chef_omnibus: '11.16.4'
77
box: opscode-ubuntu-12.04
88
box_url: https://opscode-vm-bento.s3.amazonaws.com/vagrant/opscode_ubuntu-12.04_provisionerless.box
99

Berksfile.lock

Lines changed: 0 additions & 13 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
# CHANGELOG for ssh
2+
## 0.10.2
3+
* Update the README
4+
* Fix some spec tests
5+
* Fix bug in `config` that did not allow `HostName` directive
6+
7+
## 0.10.0
8+
* MAJOR rewrite, but no breaking changes known of.
29

310
## 0.6.5
411

libraries/ssh_config_helpers.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,8 @@ def parse_name(line)
4747

4848
def parse_line(line)
4949
matchdata = line.match(/^\s*(\w+)(.*$)/)
50-
if matchdata
51-
return matchdata.captures[0], matchdata.captures[1].strip
52-
end
50+
return matchdata.captures[0], matchdata.captures[1].strip if matchdata
51+
5352
Chef::Log.error("Line |#{line}| does not parse correctly")
5453
return nil, nil
5554
end

metadata.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
license 'Apache 2.0'
55
description 'LWRPs for managing SSH known_hosts and config files'
66
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
7-
version '0.10.0'
7+
version '0.10.2'

providers/known_hosts.rb

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,12 @@ def whyrun_supported?
3434
end
3535

3636
action :remove do
37-
execute "remove known_host entry for #{new_resource.host}" do
38-
command "ssh-keygen -R #{Shellwords.escape(new_resource.host)} -f #{new_resource.path}"
39-
user new_resource.user if new_resource.user
40-
umask new_resource.user ? 0077 : 0022
41-
only_if @current_resource.exists?
37+
if @current_resource.exists?
38+
execute "remove known_host entry for #{new_resource.host}" do
39+
command "ssh-keygen -R #{Shellwords.escape(new_resource.host)} -f #{new_resource.path}"
40+
user new_resource.user if new_resource.user
41+
umask new_resource.user ? 0077 : 0022
42+
end
4243
end
4344
end
4445

@@ -66,7 +67,8 @@ def load_key_if_needed
6667
return if new_resource.action.is_a?(Array) ? new_resource.action.include?(:remove) : new_resource.action == :remove
6768

6869
keyscan = Mixlib::ShellOut.new(
69-
"ssh-keyscan #{new_resource.hashed ? '-H ' : ''} -p #{new_resource.port.to_i} #{Shellwords.escape(new_resource.host)}"
70+
"ssh-keyscan #{new_resource.hashed ? '-H ' : ''} "\
71+
"-p #{new_resource.port.to_i} #{Shellwords.escape(new_resource.host)}"
7072
)
7173
keyscan.run_command
7274
keyscan.error! # this will raise an error if the command failed for any reason.

spec/provider_tests/config_spec.rb

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
require 'spec_helper'
22

33
describe 'ssh_config resource' do
4-
54
let(:chef_run) do
65
runner = ChefSpec::SoloRunner.new(:step_into => :ssh_config)
76
runner.converge('ssh_test::config')
@@ -81,7 +80,12 @@
8180
allow(IO).to partial_start.reduce(receive(:foreach).with(default_config), :and_yield)
8281
allow(IO).to partial_start.reduce(receive(:foreach).with(test_config), :and_yield)
8382

84-
allow(Etc).to receive(:getpwnam).and_return("error")
83+
allow(Etc).to receive(:getgrgid).and_raise(Exception.new('This should not happen'))
84+
allow(Etc).to receive(:getgrgid).with(200).and_return(Struct.new(:name).new('vagrant'))
85+
allow(Etc).to receive(:getgrgid).with(100).and_return(Struct.new(:name).new('someone'))
86+
allow(Etc).to receive(:getgrgid).with(0).and_return(Struct.new(:name).new('root'))
87+
88+
allow(Etc).to receive(:getpwnam).and_raise(Exception.new('This should not happen'))
8589
allow(Etc).to receive(:getpwnam).with('vagrant').and_return(
8690
Struct.new(:gid, :dir).new(200, '/home/vagrant')
8791
)
@@ -169,7 +173,7 @@
169173
it 'can create user ssh configs' do
170174
expect(chef_run).to create_file(vagrant_config).with(
171175
:owner => 'vagrant',
172-
:group => 200,
176+
:group => 'vagrant',
173177
:mode => 00600
174178
).with_content(
175179
(common_end + github_and_partial_end).join("\n")
@@ -179,7 +183,7 @@
179183
it 'can create the global ssh config' do
180184
expect(chef_run).to create_file(default_config).with(
181185
:owner => 'root',
182-
:group => 0,
186+
:group => 'root',
183187
:mode => 00644
184188
).with_content(
185189
(common_end + github_and_partial_end).join("\n")
@@ -189,15 +193,15 @@
189193
it 'creates the /etc/ssh directory if it is missing' do
190194
expect(chef_run).to create_directory(::File.dirname(default_config)).with(
191195
:owner => 'root',
192-
:group => 0,
196+
:group => 'root',
193197
:mode => 00755
194198
)
195199
end
196200

197201
it "creates vagrant's ~/.ssh/config file" do
198202
expect(chef_run).to create_directory(::File.dirname(vagrant_config)).with(
199203
:owner => 'vagrant',
200-
:group => 200,
204+
:group => 'vagrant',
201205
:mode => 00700
202206
)
203207
end

spec/provider_tests/known_hosts_spec.rb

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
require 'spec_helper'
22

33
describe 'ssh_config resource' do
4-
54
let(:chef_run) do
65
runner = ChefSpec::SoloRunner.new(:step_into => :ssh_config)
76
runner.converge('ssh_test::known_hosts')
@@ -24,7 +23,5 @@
2423
)
2524
end
2625

27-
it 'works' do
28-
pending 'I can not think of any spec tests that make sense'
29-
end
26+
pending 'I can not think of any spec tests that make sense'
3027
end

0 commit comments

Comments
 (0)