Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ssh.keep_alive: Add option to add the ssh keep alive option #92

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh that's neat. I'm wondering if we should enable it by default/always?

Copy link
Member Author

@b4ldr b4ldr Aug 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally i think it would be a safe enough change to make this the default but will wait to see if others have a view

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)
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
Loading