[英]Why does Azure VM not run cloud-init script specified in userData parameter?
Using the ARM template https://pastebin.com/ShjazbpR with the cloud-init script:使用 ARM 模板https://pastebin.com/ShjazbpR和 cloud-init 脚本:
#cloud-config
# Install additional packages on first boot
#
# Default: none
#
# if packages are specified, this apt_update will be set to true
#
# packages may be supplied as a single package name or as a list
# with the format [<package>, <version>] wherein the specifc
# package version will be installed.
packages:
- pwgen
Does not install pwgen package nor does it update package list, as documentation https://cloudinit.readthedocs.io/en/latest/topics/examples.html#install-arbitrary-packages states it should update package list: # if packages are specified, this apt_update will be set to true
不安装 pwgen package 也不更新 package 列表,因为文档https://cloudinit.readthedocs.io/en/latest/topics/examples.html#install-arbitrary-packages指出它应该更新 package 列表: # if packages are specified, this apt_update will be set to true
If I use the customData
property under osProfile
in this template https://pastebin.com/27s4pgiD everything works as expected, pwgen is installed and package list is updated at first boot.如果我在此模板https://pastebin.com/27s4pgiD osProfile
使用 osProfile 下的customData
属性,一切都按预期工作,安装 pwgen 并在首次启动时更新 package 列表。
Does anyone know why userData is not working?有谁知道为什么 userData 不工作? Azure documentation https://learn.microsoft.com/azure/virtual-machines/user-data states userData is supported in Azure. Azure 文档https://learn.microsoft.com/azure/virtual-machines/user-data指出 Azure 支持 userData。
Automatic cloud init is only supported for custom data.仅自定义数据支持自动云初始化。 If you use user data then it is seen as raw data, and you have to fetch it and handle it yourself.如果您使用用户数据,那么它会被视为原始数据,您必须自己获取并处理它。 For example you can have a script in your image that runs on startup (only first time, or restarts too), that fetches and processes this data.例如,你可以在你的图像中有一个在启动时运行的脚本(只有第一次,或者也重新启动),用于获取和处理这些数据。
For example:例如:
curl -H Metadata:true --noproxy "*" "http://169.254.169.254/metadata/instance/compute/userData?api-version=2021-01-01&format=text" | base64 --decode >> somefile
#process somefile...
https://learn.microsoft.com/en-us/azure/virtual-machines/linux/instance-metadata-service?tabs=linux#get-user-data https://learn.microsoft.com/en-us/azure/virtual-machines/linux/instance-metadata-service?tabs=linux#get-user-data
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.