Skip to content

Commit

Permalink
ssh.kttp_alive: Add option to add the ssh keep alive option
Browse files Browse the repository at this point in the history
We have an issue where sometimes the ssh connection is killed.  this
happens due to puppet changing the sshd keep alive settings while beaker
is still running.

This patch adds the ability for users to add ssh_keep_alive to the host
config to ensure we send keep alive packets every 5 seconds
  • Loading branch information
b4ldr committed Aug 28, 2024
1 parent 305eb59 commit 7fdf7b7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/beaker/hypervisor/vagrant.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ def make_vfile(hosts, options = {})
hosts.each do |host|
host.name.tr!('_', '-') # Rewrite Hostname with hyphens instead of underscores to get legal hostname
set_host_default_ip(host)
v_file << " c.ssh.keep_alive = true\n" if host['ssh_keep_alive'] == true
v_file << " c.vm.define '#{host.name}' do |v|\n"
v_file << " v.vm.hostname = '#{host.name}'\n"
v_file << " v.vm.box = '#{host['box']}'\n"
Expand Down
10 changes: 10 additions & 0 deletions spec/beaker/vagrant_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,16 @@ module Beaker
expect(vagrantfile).to match(/(ssh.forward_agent = true)/)
end

it 'can make a Vagrantfile with ssh timeout' do
path = vagrant.instance_variable_get(:@vagrant_path)

hosts = make_hosts({ssh_keep_alive: true}, 1)

Check failure on line 109 in spec/beaker/vagrant_spec.rb

View workflow job for this annotation

GitHub Actions / rubocop

Layout/SpaceInsideHashLiteralBraces: Space inside { missing. (https://rubystyle.guide#spaces-braces)

Check failure on line 109 in spec/beaker/vagrant_spec.rb

View workflow job for this annotation

GitHub Actions / rubocop

Layout/SpaceInsideHashLiteralBraces: Space inside } missing. (https://rubystyle.guide#spaces-braces)
vagrant.make_vfile(hosts, options)

vagrantfile = File.read(File.expand_path(File.join(path, 'Vagrantfile')))
expect(vagrantfile).to match(/(ssh.keep_alive = true)/)
end

it 'can replace underscores in host.name with hypens' do
path = vagrant.instance_variable_get(:@vagrant_path)

Expand Down

0 comments on commit 7fdf7b7

Please sign in to comment.