Packer 似乎无法通过 Amazon Scripts 来对机器进行系统准备。我尝试了很多不同的方法。将脚本放入自己的脚本中,运行它们,像许多人展示的那样“内联”,但似乎没有任何效果。我不断收到以下错误:
构建“amazon-ebs”错误:错误处理命令:可重试错误:上传包含环境变量的 ps 脚本时出错:上传文件到 $env:TEMP\winrmcp-10fca0b1-a0ac-47d2-7462-77d91b066859.tmp 时出错:无法创建 shell:http 响应错误:401 - 内容类型无效
任何帮助将不胜感激。
打包程序版本:Packer v1.3.3
以下是我的打包 JSON:
{
"builders": [
{
"type": "amazon-ebs",
"ami_description": "Base Win2016 with encrypted root",
"ami_name": "examsoft-win2016-{{timestamp}}",
"ami_regions": [
"us-east-2",
"ap-southeast-1",
"us-east-1",
"us-west-2"
],
"encrypt_boot": true,
"instance_type": "t2.micro",
"region": "us-east-2",
"user_data_file": "./bootstrap_win.txt",
"communicator": "winrm",
"winrm_username": "Administrator",
"winrm_password": "{{user `winrm_password` }}",
"region_kms_key_ids": {
"ap-southeast-1": "alias/aws/ebs",
"us-east-1": "alias/aws/ebs",
"us-east-2": "alias/aws/ebs",
"us-west-2": "alias/aws/ebs"
},
"source_ami_filter": {
"filters": {
"virtualization-type": "hvm",
"name": "*Windows_Server-2016-English-Full-Base*",
"root-device-type": "ebs"
},
"owners": "amazon",
"most_recent": true
}
}
],
"description": "Base Windows 2016 image with manager credentials and encrypted root",
"provisioners": [
{
"type": "powershell",
"script": "./scripts/ConfigureRemotingforAnsible.ps1"
},
{
"type": "powershell",
"script": "./scripts/ConfigurePackerImage.ps1"
},
{
"type": "powershell",
"inline": [
"C:\\ProgramData\\Amazon\\EC2-Windows\\Launch\\Scripts\\InitializeInstance.ps1 -Schedule",
"C:\\ProgramData\\Amazon\\EC2-Windows\\Launch\\Scripts\\SysprepInstance.ps1 -NoShutdown"
]
}
]
}
答案1
我遇到了这个确切的错误,我的问题是我在运行 sysprep 之前在配置程序中执行的脚本中更改了管理员密码。
您要更改管理员密码吗./scripts/ConfigurePackageImage.ps1
?
如果是这样,我删除了更改管理员帐户密码的代码,现在我在 sysprep 之后在配置程序中执行的单独脚本中运行它。