你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
CycleCloud 支持 cloud-init,在 VM 上任何其他 CycleCloud 特定配置之前,先在首次启动上配置虚拟机。 使用 cloud-init 是在安装 CycleCloud(HPC 计划程序)管理的任何软件之前配置 VM 的各个方面(例如网络、yum/apt 镜像等)的有效方法。
以下示例演示如何使用 CloudInit 群集模板中的属性指定要在启动时运行的 bash 脚本:
[node scheduler]
CloudInit = '''#!/bin/bash
echo "cloud-init works" > /tmp/cloud-init.txt
'''
注释
使用群集模板中的三引号字符串来指定多行字符串,例如 bash 或 YAML 脚本。
警告
并非 Azure 中的所有操作系统映像都支持 cloud-init。 有关哪些映像支持 cloud-init 和更广泛支持的时间线的详细信息,请参阅 Azure 中虚拟机的 cloud-init 支持。
使用 UI 设置 cloud-init
CycleCloud UI 支持 cloud-init 编辑。 创建或编辑任何群集时,可以使用 Cloud-Init 选项卡编辑群集中每个节点的 cloud-init 脚本。 CycleCloud UI 中的编辑器接受任何文本输入。 它为 Python、shell 脚本或 YAML 提供语法突出显示。

Cloud-init 排序和错误处理
对于指定 CloudInit 的 CycleCloud 节点,CycleCloud 会预配置 VM,并在启动任何其他配置之前,等待 cloud-init 运行完成。 如果在节点上指定 CloudInit ,但 CycleCloud 未检测到 OS 的 cloud-init 支持,则节点进入错误状态,并将原因中继到 CycleCloud。 CloudInit如果脚本无法执行(例如,由于脚本错误或语法错误),则节点进入错误状态,并将 cloud-init 报告的错误中继到 CycleCloud。
cloud-init 运行到完成且无错误后,CycleCloud 将继续像往常一样配置 VM。
重要
CycleCloud 不会自动合并 cloud-init 脚本。 如果在 [node defaults] 中指定了 cloud-init 脚本,并且有节点继承了这些默认值,那么 [node defaults] 中的 cloud-init 脚本将被覆盖。 若要共享代码,建议手动合并脚本。 或者,可以使用 include 文件用户数据格式来包含要处理的 cloud-init 的 URL 列表。