outscale / packer-plugin-outscale

Packer plugin for Outscale OMI Builder
https://www.packer.io/docs/builders/outscale
Mozilla Public License 2.0
7 stars 13 forks source link

Cannot Connect via Private Interface with Outscale Key #175

Open cvedia-mdsol opened 10 months ago

cvedia-mdsol commented 10 months ago

Overview of the Issue

Packer is able to connect fine via SSH when using our loaded key in Outscale however, this stopped working when switching the 'ssh_interface' to "private". We are using the 'outscale-bsusurrogate' builder for this.

Reproduction Steps

1.) Use the 'outscale-bsusurrogate' and outscale plugin '1.1.3' 2.) Add in SSH configuration using the following added parameters (this should connect fine)

    ssh_interface = "public_ip"
    ssh_username = "outscale"
    communicator = "ssh"

    ssh_private_key_file = "~/.ssh/outscale-private.rsa"
    ssh_keypair_name = "loaded-key-in-outscale"

3.) Switch the 'ssh_interface' with all other parameters the same (this should fail to connect and timeout)

    ssh_interface = "private_ip"
    ssh_username = "outscale"
    communicator = "ssh"

    ssh_private_key_file = "~/.ssh/outscale-private.rsa"
    ssh_keypair_name = "loaded-key-in-outscale"

Plugin and Packer version

# plugin config
packer {
    required_plugins {
        outscale = {
            version = "1.1.3"
            source  = "github.com/outscale/outscale"
        }
    }
}

# packer version
Packer v1.9.1

Simplified Packer Buildfile

For the build, extracted the SSH parameters and provided them below. Was able to confirm that by only switch the 'ssh_interface', packer was no longer able to connect via SSH.

-Working Config-

source "outscale-bsusurrogate" "linux" {
    ...
    ssh_interface = "public_ip"
    ssh_username = "outscale"
    communicator = "ssh"

    ssh_private_key_file = "~/.ssh/outscale-infrastructure.rsa"
    ssh_keypair_name = "outscale-infrastructure"
}

build {
    sources = [ 
        "source.outscale-bsusurrogate.linux" 
    ]
}

-Not Working Config-

source "outscale-bsusurrogate" "linux" {
    ...
    ssh_interface = "private_ip"
    ssh_username = "outscale"
    communicator = "ssh"

    ssh_private_key_file = "~/.ssh/outscale-infrastructure.rsa"
    ssh_keypair_name = "outscale-infrastructure"
}

build {
    sources = [ 
        "source.outscale-bsusurrogate.linux" 
    ]
}

Operating system and Environment details

Executing Packer on Windows Server 2019 hosted in Outscale.

Log Fragments and crash.log files

{"ResponseContext":{"RequestId":"2d802836-cf2e-4797-b779-d39a7d94a12d"},"Vms":[{"VmType":"tinav5.c4r8p1","VmInitiatedShutdownBehavior":"stop","State":"running","StateReason":"","RootDeviceType":"ebs","RootDeviceName":"/dev/sda1","IsSourceDestChecked":true,"KeypairName":"outscale-infrastructure","PublicIp":"216.168.194.46","ImageId":"ami-66ff5bda","PublicDnsName":"ows-216-168-194-46.us-east-2.compute.outscale.com","DeletionProtection":false,"Architecture":"x86_64","NestedVirtualization":false,"BlockDeviceMappings":[{"DeviceName":"/dev/sda1","Bsu":{"VolumeId":"vol-2f714b45","State":"attached","LinkDate":"2024-02-02T16:08:18.132Z","DeleteOnVmDeletion":true}},{"DeviceName":"/dev/xvdf","Bsu":{"VolumeId":"vol-504e73d2","State":"attached","LinkDate":"2024-02-02T16:08:18.132Z","DeleteOnVmDeletion":true}}],"VmId":"i-219f55b1","ReservationId":"r-0f89df03","Hypervisor":"xen","Placement":{"Tenancy":"default","SubregionName":"us-east-2a"},"ProductCodes":["0001"],"CreationDate":"2024-02-02T16:08:18.132Z","UserData":"","PrivateIp":"10.17.8.113","SecurityGroups":[{"SecurityGroupName":"packer_osc_65bd136f-7d27-7000-ac93-6a2fc2e55883","SecurityGroupId":"sg-498f8efc"}],"BsuOptimized":false,"LaunchNumber":0,"Performance":"highest","Tags":[{"Value":"Packer Builder","Key":"Name"}],"PrivateDnsName":"ip-10-17-8-113.us-east-2.compute.internal"}]}
2024/02/02 16:08:33 ui:     outscale-bsusurrogate.linux: Public DNS: ows-216-168-194-46.us-east-2.compute.outscale.com
2024/02/02 16:08:33 ui:     outscale-bsusurrogate.linux: Public IP: 216.168.194.46
2024/02/02 16:08:33 ui:     outscale-bsusurrogate.linux: Private IP: 10.17.8.113
2024/02/02 16:08:37 packer-plugin-outscale_v1.1.3_x5.0_windows_amd64.exe plugin: 2024/02/02 16:08:37 [INFO] Not using winrm communicator, skipping get password...
2024/02/02 16:08:39 ui: ==> outscale-bsusurrogate.linux: Using SSH communicator to connect: 10.17.8.113
2024/02/02 16:08:39 packer-plugin-outscale_v1.1.3_x5.0_windows_amd64.exe plugin: 2024/02/02 16:08:39 [INFO] Waiting for SSH, up to timeout: 5m0s
2024/02/02 16:08:39 ui: ==> outscale-bsusurrogate.linux: Waiting for SSH to become available...
2024/02/02 16:08:54 packer-plugin-outscale_v1.1.3_x5.0_windows_amd64.exe plugin: 2024/02/02 16:08:54 [DEBUG] TCP connection to SSH ip/port failed: dial tcp 10.17.8.113:22: i/o timeout
2024/02/02 16:09:14 packer-plugin-outscale_v1.1.3_x5.0_windows_amd64.exe plugin: 2024/02/02 16:09:14 [DEBUG] TCP connection to SSH ip/port failed: dial tcp 10.17.8.113:22: i/o timeout
2024/02/02 16:09:34 packer-plugin-outscale_v1.1.3_x5.0_windows_amd64.exe plugin: 2024/02/02 16:09:34 [DEBUG] TCP connection to SSH ip/port failed: dial tcp 10.17.8.113:22: i/o timeout
2024/02/02 16:09:54 packer-plugin-outscale_v1.1.3_x5.0_windows_amd64.exe plugin: 2024/02/02 16:09:54 [DEBUG] TCP connection to SSH ip/port failed: dial tcp 10.17.8.113:22: i/o timeout
2024/02/02 16:10:14 packer-plugin-outscale_v1.1.3_x5.0_windows_amd64.exe plugin: 2024/02/02 16:10:14 [DEBUG] TCP connection to SSH ip/port failed: dial tcp 10.17.8.113:22: i/o timeout
2024/02/02 16:10:34 packer-plugin-outscale_v1.1.3_x5.0_windows_amd64.exe plugin: 2024/02/02 16:10:34 [DEBUG] TCP connection to SSH ip/port failed: dial tcp 10.17.8.113:22: i/o timeout
2024/02/02 16:10:54 packer-plugin-outscale_v1.1.3_x5.0_windows_amd64.exe plugin: 2024/02/02 16:10:54 [DEBUG] TCP connection to SSH ip/port failed: dial tcp 10.17.8.113:22: i/o timeout
2024/02/02 16:11:14 packer-plugin-outscale_v1.1.3_x5.0_windows_amd64.exe plugin: 2024/02/02 16:11:14 [DEBUG] TCP connection to SSH ip/port failed: dial tcp 10.17.8.113:22: i/o timeout
2024/02/02 16:11:34 packer-plugin-outscale_v1.1.3_x5.0_windows_amd64.exe plugin: 2024/02/02 16:11:34 [DEBUG] TCP connection to SSH ip/port failed: dial tcp 10.17.8.113:22: i/o timeout
2024/02/02 16:11:54 packer-plugin-outscale_v1.1.3_x5.0_windows_amd64.exe plugin: 2024/02/02 16:11:54 [DEBUG] TCP connection to SSH ip/port failed: dial tcp 10.17.8.113:22: i/o timeout
2024/02/02 16:12:14 packer-plugin-outscale_v1.1.3_x5.0_windows_amd64.exe plugin: 2024/02/02 16:12:14 [DEBUG] TCP connection to SSH ip/port failed: dial tcp 10.17.8.113:22: i/o timeout
2024/02/02 16:12:34 packer-plugin-outscale_v1.1.3_x5.0_windows_amd64.exe plugin: 2024/02/02 16:12:34 [DEBUG] TCP connection to SSH ip/port failed: dial tcp 10.17.8.113:22: i/o timeout
2024/02/02 16:12:54 packer-plugin-outscale_v1.1.3_x5.0_windows_amd64.exe plugin: 2024/02/02 16:12:54 [DEBUG] TCP connection to SSH ip/port failed: dial tcp 10.17.8.113:22: i/o timeout
2024/02/02 16:13:14 packer-plugin-outscale_v1.1.3_x5.0_windows_amd64.exe plugin: 2024/02/02 16:13:14 [DEBUG] TCP connection to SSH ip/port failed: dial tcp 10.17.8.113:22: i/o timeout
2024/02/02 16:13:34 packer-plugin-outscale_v1.1.3_x5.0_windows_amd64.exe plugin: 2024/02/02 16:13:34 [DEBUG] TCP connection to SSH ip/port failed: dial tcp 10.17.8.113:22: i/o timeout
2024/02/02 16:13:39 ui error: ==> outscale-bsusurrogate.linux: Timeout waiting for SSH.
2024/02/02 16:13:39 packer-plugin-outscale_v1.1.3_x5.0_windows_amd64.exe plugin: 2024/02/02 16:13:39 [DEBUG] SSH wait cancelled. Exiting loop.
outscale-toa commented 10 months ago

Hi @cvedia-mdsol,

Thanks for reaching us, we are looking at your issue Best regards,

cvedia-mdsol commented 9 months ago

@outscale-toa is there a particular version of the plugin I can attempt to use as an alternative? I've tried a few of the recent ones by just changing the 'ssh_interface' to "private_ip" but it times out. Ran test to confirm that during initial creation I can connect fine to the public but not the private IP. We have the SSH port allowed in the referenced Security Group.

outscale-toa commented 9 months ago

Hello @cvedia-mdsol, We are presently trying to reproduise this issue, we did not manage to reproduce the bug yet. In the meantime, could you please try to increase ssh_timeout, ex: ssh_timeout: "25m"

source "outscale-bsusurrogate" "linux" {
    ...
    ssh_interface = "private_ip"
    ssh_username = "outscale"
    communicator = "ssh"
    ssh_timeout = "15m"

    ssh_private_key_file = "~/.ssh/outscale-infrastructure.rsa"
    ssh_keypair_name = "outscale-infrastructure"
}

build {
    sources = [ 
        "source.outscale-bsusurrogate.linux" 
    ]
}

Thanks