使用时cloud init's #cloud-config 创建配置文件,我将如何使用变量来填充值?
在我的特定情况下,我想自动启动 EC2 实例作为预配置的 salt minions。 Example of salt minion cloud config
假设我想获取特定的 EC2 实例 ID 并将其设置为 salt minion 的 ID。
我将如何着手为每个实例动态设置值?
最佳答案
在引导命令中 bootcmd
可以有环境变量 $INSTANCE_ID
,您可以将其保存以备后用。见 http://cloudinit.readthedocs.org/en/latest/topics/examples.html#run-commands-on-first-boot
例如,我喜欢下面
#cloud-config
bootcmd:
- echo $INSTANCE_ID > /hello.txt
关于amazon-ec2 - 是否可以在 cloud-config 中使用变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16540730/