【问题标题】:AWS AMI cannot retrieve password after packer creation using private keyAWS AMI 在使用私钥创建打包程序后无法检索密码
【发布时间】:2019-01-14 08:03:44
【问题描述】:

我正在使用打包程序构建 Windows 服务器 AMI。它适用于硬编码密码,但我正在尝试创建 AMI 以便自动生成密码。我尝试了下面的建议,打包程序日志看起来不错,它有密码。

How to create windows image in packer using the keypair

但是,当我在 terraform 中从 AMI 创建 EC2 实例时,与 Windows 密码的连接丢失并且无法检索。这里缺少什么?

打包器 json

{  
  "builders": [
    {
      "profile" : "blah",
      "type": "amazon-ebs",
      "region": "eu-west-1",
      "instance_type": "t2.micro",
      "source_ami_filter": {
        "filters": {
          "virtualization-type": "hvm",
          "name": "*Windows_Server-2012-R2*English-64Bit-Base*",
          "root-device-type": "ebs"
        },
        "most_recent": true,
        "owners": "amazon"
      },
      "ssh_keypair_name" : "shared.key",
      "ssh_private_key_file" : "./common/sharedkey.pem",
      "ssh_agent_auth" : "true",
      "ami_name": "test-{{timestamp}}",
      "user_data_file": "./common/bootstrap_win.txt",
      "communicator": "winrm",
      "winrm_username": "Administrator"      
    }
  ]
}

【问题讨论】:

    标签: passwords windows-server-2012-r2 private-key amazon-ami packer


    【解决方案1】:

    最后添加 Ec2Config.exe -sysprep 有效。

    {
          "type": "windows-shell",
          "inline": ["C:\\progra~1\\Amazon\\Ec2ConfigService\\Ec2Config.exe -sysprep"]
    }
    

    但请注意,我的 IIS 配置在 sysprep 之后似乎不起作用。

    【讨论】:

    • 我很惊讶这不在示例文档中。我闻到了一个拉取请求来了
    猜你喜欢
    • 2022-11-25
    • 2022-01-23
    • 2017-07-07
    • 2018-07-14
    • 1970-01-01
    • 2019-11-26
    • 2017-09-30
    • 1970-01-01
    • 2022-11-12
    相关资源
    最近更新 更多