'ssh_agent_auth' and 'ssh_keypair_name' params doesnt work w/o 'ssh_private_key_file'

未关闭
#49 1 条评论 10 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
go
领域
cloud

调研方向

未指定源文件、测试或入口点。首先复现包含 ssh_keypair_name 和 ssh_agent_auth 但不包含 ssh_private_key_file 的简化 OpenStack 构建配置,然后跟踪插件的 keypair 和 SSH 设置;当现有 keypair 已附加且无需私钥路径即可成功进行 SSH 身份验证时,即完成此项工作。

由索引模型根据 Issue 内容生成。

描述

bug
'ssh_agent_auth' and 'ssh_keypair_name' parameters not working as expected

The folowing param set

ssh_username = "<image user name>"
ssh_keypair_name = "<existing keypair name>"
ssh_agent_auth = true

creates VM without any keypair. As a result SSH-auth falls.
Adding the path to a completely random private key to the ssh_private_key_file parameter fixes this as a workaround (although it doesn't make sense)

Reproduction Steps

see above

Plugin and Packer version

Packer v1.7.8
packer-plugin-openstack_v1.0.0_x5.0_linux_amd64

Simplified Packer Buildfile
packer {
  required_plugins {
    openstack = {
      version = "1.0.0"
      source  = "github.com/hashicorp/openstack"
    }
  }
}
source "openstack" "centos8" {
  identity_endpoint =  "https://some.domain:13000"
  application_credential_id = var.openstack_app_credid
  application_credential_secret = var.openstack_app_secret
  
  source_image_name = "centos_8.4"
  image_name  = "centos_8.4_new"
  flavor = "Standard-2-4"
  networks = ["42692968-11a7-4010-b958-a03ee9f2431e"]
  use_blockstorage_volume = true

  # # Provision
  communicator = "ssh"
  ssh_username = "centos"
  ssh_keypair_name = "existed_key"
  # Uncomment following line for workaround fix
  #ssh_private_key_file = "/root/.ssh/id_rsa" 
  ssh_agent_auth = true
}

build {
  sources = ["source.vsphere-iso.centos8","source.openstack.centos8"]
  provisioner "shell" {
    environment_vars = var.shell_envs[*]
    use_env_var_file = true
    scripts          = fileset(".", "${path.root}/.build/scripts/*")
  }
}
Operating system and Environment details

docker.io/hashicorp/packer
x86_64

Log Fragments and crash.log files
2021/11/16 14:18:33 packer-provisioner-shell plugin: [INFO] Packer version: 1.7.8 [go1.17.2 linux amd64]
2021/11/16 14:18:33 packer-provisioner-shell plugin: [INFO] PACKER_CONFIG env var not set; checking the default config file path
2021/11/16 14:18:33 packer-provisioner-shell plugin: [INFO] PACKER_CONFIG env var set; attempting to open config file: /root/.packerconfig
2021/11/16 14:18:33 packer-provisioner-shell plugin: [WARN] Config file doesn't exist: /root/.packerconfig
2021/11/16 14:18:33 packer-provisioner-shell plugin: [INFO] Setting cache directory: /root/.cache/packer
2021/11/16 14:18:33 packer-provisioner-shell plugin: args: []string{"packer-provisioner-shell"}
2021/11/16 14:18:33 packer-provisioner-shell plugin: Plugin address: unix /tmp/packer-plugin3998114135
2021/11/16 14:18:33 packer-provisioner-shell plugin: Waiting for connection...
2021/11/16 14:18:33 Received unix RPC address for /usr/bin/packer: addr is /tmp/packer-plugin3998114135
2021/11/16 14:18:33 packer-provisioner-shell plugin: Serving a plugin connection...
2021/11/16 14:18:33 Build debug mode: false
2021/11/16 14:18:33 Force build: true
openstack.centos8: output will be in this color.
2021/11/16 14:18:33 On error:

2021/11/16 14:18:33 Waiting on builds to complete...
2021/11/16 14:18:33 Starting build run: openstack.centos8
2021/11/16 14:18:33 Running builder:
2021-11-16T14:18:33+03:00: ==> openstack.centos8: Loading flavor: Standard-2-4
2021/11/16 14:18:33 packer-plugin-openstack_v1.0.0_x5.0_linux_amd64 plugin: 2021/11/16 14:18:33 [INFO] Loading flavor by ID: Standard-2-4
2021/11/16 14:18:34 packer-plugin-openstack_v1.0.0_x5.0_linux_amd64 plugin: 2021/11/16 14:18:34 [ERROR] Failed to find flavor by ID: Resource not found
2021/11/16 14:18:34 packer-plugin-openstack_v1.0.0_x5.0_linux_amd64 plugin: 2021/11/16 14:18:34 [INFO] Loading flavor by name: Standard-2-4
2021-11-16T14:18:34+03:00:     openstack.centos8: Verified flavor. ID: 2a1f1c8a-32f4-498d-8594-a7146ac167bf
2021/11/16 14:18:34 packer-plugin-openstack_v1.0.0_x5.0_linux_amd64 plugin: 2021/11/16 14:18:34 Using Image Filters {ID: Limit:0 Marker: Name:centos_8.4 Visibility: MemberStatus: Owner: Status: SizeMin:0 SizeMax:0 Sort: SortKey: SortDir: Tags:[] CreatedAtQuery:<nil> UpdatedAtQuery:<nil> ContainerFormat: DiskFormat:}
2021-11-16T14:18:34+03:00: ==> openstack.centos8: Using SSH Agent for existing key pair existed_key
2021-11-16T14:18:34+03:00:     openstack.centos8: Found Image ID: ea5e0e16-809b-4faf-b96f-601804a79a78
2021-11-16T14:18:34+03:00: ==> openstack.centos8: Creating volume...
2021-11-16T14:18:35+03:00: ==> openstack.centos8: Waiting for volume packer_61939389-0b00-9f71-91bb-e06facfc4644 (volume id: 595ca0de-1b48-49d9-a46a-fc0e427f70a6) to become available...
2021/11/16 14:18:35 packer-plugin-openstack_v1.0.0_x5.0_linux_amd64 plugin: 2021/11/16 14:18:35 Waiting for volume creation status: creating
2021-11-16T14:18:37+03:00:     openstack.centos8: Volume ID: 595ca0de-1b48-49d9-a46a-fc0e427f70a6
2021-11-16T14:18:37+03:00: ==> openstack.centos8: Launching server...
2021-11-16T14:18:37+03:00: ==> openstack.centos8: Launching server...
2021-11-16T14:18:39+03:00:     openstack.centos8: Server ID: daae0e0f-0aa5-4043-ba88-0ef8d8989d7c
2021/11/16 14:18:39 packer-plugin-openstack_v1.0.0_x5.0_linux_amd64 plugin: 2021/11/16 14:18:39 server id: daae0e0f-0aa5-4043-ba88-0ef8d8989d7c
2021-11-16T14:18:39+03:00: ==> openstack.centos8: Waiting for server to become ready...
....
2021/11/16 14:20:56 packer-plugin-openstack_v1.0.0_x5.0_linux_amd64 plugin: 2021/11/16 14:20:56 [DEBUG] SSH handshake err: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain
2021/11/16 14:20:56 packer-plugin-openstack_v1.0.0_x5.0_linux_amd64 plugin: 2021/11/16 14:20:56 [DEBUG] Detected authentication error. Increasing handshake attempts.
2021-11-16T14:20:56+03:00: ==> openstack.centos8: Error waiting for SSH: Packer experienced an authentication error when trying to connect via SSH. This can happen if your username/password are wrong. You may want to double-check your credentials as part of your debugging process. original error: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain
主要语言
Go
星标
29
派生
27
PR 合并指标
30 天内没有已合并 PR

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

hashicorp/packer-plugin-openstack 的其他 Issue

查看 hashicorp/packer-plugin-openstack 的全部 Issue

相似的 Issue

更多 Go Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。