Skip to content

Commit

Permalink
Handle GlobalKnownHostsFile like other entries with multiple values (#32
Browse files Browse the repository at this point in the history
)
  • Loading branch information
TheKPLD authored and trevor-vaughan committed May 11, 2017
1 parent df2b662 commit 3e84d50
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/puppet/provider/ssh_config/augeas.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def self.get_value(aug, pathx)
end

def self.set_value(aug, base, path, label, value)
if label =~ /Ciphers|SendEnv|MACs/i
if label =~ /Ciphers|SendEnv|MACs|GlobalKnownHostsFile/i
aug.rm("#{path}/*")
# In case there is more than one entry, keep only the first one
aug.rm("#{path}[position() != 1]")
Expand Down
14 changes: 14 additions & 0 deletions spec/unit/puppet/provider/ssh_config/augeas_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,20 @@
end
end

it "should create an array entry" do
apply!(Puppet::Type.type(:ssh_config).new(
:name => "GlobalKnownHostsFile",
:value => ["/etc/ssh/ssh_known_hosts", "/etc/ssh/ssh_known_hosts2"],
:target => target,
:provider => "augeas"
))

aug_open(target, "Ssh.lns") do |aug|
expect(aug.get("Host/GlobalKnownHostsFile/1")).to eq("/etc/ssh/ssh_known_hosts")
expect(aug.get("Host/GlobalKnownHostsFile/2")).to eq("/etc/ssh/ssh_known_hosts2")
end
end

it "should create an array entry" do
apply!(Puppet::Type.type(:ssh_config).new(
:name => "SendEnv",
Expand Down

0 comments on commit 3e84d50

Please sign in to comment.