【发布时间】:2021-02-20 15:40:13
【问题描述】:
我想在自动化测试期间使用 tmplate.json 和 parameters.json 文件部署带有自定义数据文件的 Azure Ubuntu 18.04-LTS VM。
虽然虚拟机部署成功,但是自定义数据执行好像失败了,不明白为什么……
根据这个link,cloud-init 在我使用的镜像中是可用的。
我的 template.json 文件包含:
"parameters": {
...
"customData": {
"type": "string"
}
...
},
"resources": [
...
{
"type": "Microsoft.Compute/virtualMachines",
"apiVersion": "2020-06-01",
"name": "[parameters('virtualMachineName')]",
"location": "[parameters('location')]",
"dependsOn": [
"[concat('Microsoft.Network/networkInterfaces/', parameters('networkInterfaceName'))]"
],
"properties": {
...
"osProfile": {
"computerName": "[parameters('virtualMachineComputerName')]",
"adminUsername": "[parameters('adminUsername')]",
"linuxConfiguration": {
"disablePasswordAuthentication": true,
"ssh": {
"publicKeys": [
{
"path": "[concat('/home/', parameters('adminUsername'), '/.ssh/authorized_keys')]",
"keyData": "[parameters('adminPublicKey')]"
}
]
}
},
"customData": "[parameters('customData')]"
},
...
}
]
另外,我有一个 parameters.json 文件,其中包含:
"parameters": {
...
"customData": {
"value": "I2Nsb3VkLWNvbmZpZ1xucGFja2FnZV91cGdyYWRlOiB0cnVlXG5wYWNrYWdlczpcbiAgLSBpcGVyZlxuICAtIHRjcHJlcGxheVxuICAtIG5ldHBlcmY="
}
}
该值是 YAML base64 编码的,它的解码文本是:
#cloud-config\npackage_upgrade: true\npackages:\n - iperf\n - tcpreplay\n - netperf
(*) 上面的 template.json 和 parameters.json 文件是部分文件 - 我省略了似乎与我的问题无关的内容。
我还检查了文件 /var/log/waagent.log,但没有发现任何可疑的东西..
但是,在我手动部署了 ubuntu VM 并将上述 YAML 粘贴到自定义数据部分(在高级设置页面中)之后,每个都运行良好('iperf'、'netperf' 和 'tcpreplay ' 命令已找到)
任何帮助将不胜感激!
【问题讨论】:
标签: linux azure custom-data-attribute cloud-init