File tree 3 files changed +23
-4
lines changed
3 files changed +23
-4
lines changed Original file line number Diff line number Diff line change 65
65
default [ 'ssh' ] [ 'allow_groups' ] = [ ] # sshd
66
66
default [ 'ssh' ] [ 'print_motd' ] = false # sshd
67
67
default [ 'ssh' ] [ 'print_last_log' ] = false # sshd
68
- default [ 'ssh' ] [ 'use_dns' ] = true # sshd
68
+ # set this to nil to let us use the default OpenSSH in case it's not set by the user
69
+ default [ 'ssh' ] [ 'use_dns' ] = nil # sshd
69
70
# set this to nil to let us detect the attribute based on the node platform
70
71
default [ 'ssh' ] [ 'use_privilege_separation' ] = nil
Original file line number Diff line number Diff line change 473
473
end
474
474
475
475
context 'without attribute use_dns' do
476
- it 'sets UseDNS to the default ' do
476
+ it 'leaves UseDNS commented ' do
477
477
expect ( chef_run ) . to render_file ( '/etc/ssh/sshd_config' )
478
- . with_content ( /UseDNS yes / )
478
+ . with_content ( /# UseDNS no / )
479
479
end
480
480
end
481
481
482
- context 'with attribute use_dns' do
482
+ context 'with attribute use_dns set to false ' do
483
483
cached ( :chef_run ) do
484
484
ChefSpec ::ServerRunner . new do |node |
485
485
node . set [ 'ssh' ] [ 'use_dns' ] = false
491
491
. with_content ( /UseDNS no/ )
492
492
end
493
493
end
494
+
495
+ context 'with attribute use_dns set to true' do
496
+ cached ( :chef_run ) do
497
+ ChefSpec ::ServerRunner . new do |node |
498
+ node . set [ 'ssh' ] [ 'use_dns' ] = true
499
+ end . converge ( described_recipe )
500
+ end
501
+
502
+ it 'sets UseDNS correctly' do
503
+ expect ( chef_run ) . to render_file ( '/etc/ssh/sshd_config' )
504
+ . with_content ( /UseDNS yes/ )
505
+ end
506
+ end
494
507
end
Original file line number Diff line number Diff line change @@ -185,7 +185,12 @@ X11UseLocalhost yes
185
185
PrintMotd <%= ((@node['ssh']['print_motd']) ? 'yes' : 'no' ) %>
186
186
PrintLastLog <%= ((@node['ssh']['print_last_log']) ? 'yes' : 'no' ) %>
187
187
#Banner /etc/ssh/banner.txt
188
+ <% if @node['ssh']['use_dns'].nil? %>
189
+ # Since OpenSSH 6.8, this value defaults to 'no'
190
+ #UseDNS no
191
+ <% else %>
188
192
UseDNS <%= ((@node['ssh']['use_dns']) ? 'yes' : 'no' ) %>
193
+ <% end %>
189
194
#PidFile /var/run/sshd.pid
190
195
#MaxStartups 10
191
196
#ChrootDirectory none
You can’t perform that action at this time.
0 commit comments