我可以将web-packer.json模板中定义的变量用于user_data_file中的文件。
我正在使用user_data_file来设置wimrm并将用户添加到管理员组。在安装网络服务器之前。
一些web-packer.json模板
"builders": [
{
"type": "amazon-ebs",
"vpc_id": "{{user `vpc_id`}}",
"subnet_id": "{{user `subnet_id`}}",
"associate_public_ip_address": true,
"access_key": "{{user `aws_access_key`}}",
"secret_key": "{{user `aws_secret_key`}}",
"region": "eu-west-1",
"source_ami": "ami-40003a26",
"instance_type": "c4.xlarge",
"ami_name": "cms-sitecore",
"communicator": "winrm",
"winrm_username": "{{user `winrm_username`}}",
"winrm_timeout": "30m",
"user_data_file": "./bootstrap-aws.ps1"
}
],
"provisioners": [
{
"type": "file",
"source": "./install/",
"destination": "C:/install"
},
{
"type": "powershell",
"inline": [
"Install-WindowsFeature -Name Web-Asp-Net45,Web-Static-Content,Web-Mgmt-Console,Web-Http-Errors,Web-Http-Logging,Web-Stat-Compression"
]
}
]
答案 0 :(得分:1)
不,你不能。 user_data_file
不是模板,因此不进行插值。您必须使用user_data
或在Packer之外预处理user_data_file
。