capistrano / sshkit

A toolkit for deploying code and assets to servers in a repeatable, testable, reliable way.
MIT License
1.13k stars 253 forks source link

Unbracketed IPv6 addresses don't work #537

Closed jeromedalbert closed 3 weeks ago

jeromedalbert commented 1 month ago

Problem

I can use SSHKit with a bracketed IPv6 address like so:

on ['[1fff:0:a88:85a3::ac1f]'] do |host|

But if I try to use an unbracketed IPv6 address

on ['1fff:0:a88:85a3::ac1f'] do |host|

I get the following error:

/Users/jerome/.asdf/installs/ruby/3.3.1/lib/ruby/gems/3.3.0/gems/sshkit-1.22.2/lib/sshkit/runners/parallel.rb:15:in `rescue in block (2 levels) in execute': Exception while executing on host 1fff: getaddrinfo: nodename nor servname provided, or not known (SSHKit::Runner::ExecuteError)

Additional information

Ubracketed IPv6 addresses are valid IPv6 addresses, so I think SSHKit should be able to parse them.

In my particular case, I am encountering this issue when using Kamal. Supplying an unbracketed IPv6 address in the Kamal config/deploy.yml configuration doesn't work because Kamal then passes that IP to SSHKit, as explained in this open issue: https://github.com/basecamp/kamal/issues/588. As mentioned in that issue, using brackets as a workaround doesn't work out of the box and requires further hacks overriding SSHKit's behavior, but these hacks all stem from SSHKit not properly parsing unbracketed IPv6 in the first place. Parsing unbracketed IPv6 addresses correctly in SSHKit would naturally solve those issues and allow Kamal to support unbracketed IPv6 addresses (and maybe bracketed too).

Related issues

mattbrictson commented 3 weeks ago

Closed via #538