cloud-init 典型应用 - 每天5分钟玩转 OpenStack(174)
本节介绍几个 cloud-init 的典型应用:设置 hostanme,设置用户初始密码,安装软件。 设置 hostname cloud-init 默认会将 instance 的名字设置为 hostname。但这样不太方便,有时希望能够将二者分开,可利用 cloud-init 的set_hostname模块实现。set_hostname它会查询 metadata 中 hostname 信息,默认值就是 instance 的名字。我们可以指定自己的 hostname,方法是将下面的内容传给 cloud-init: #cloud-config hostname: my1.cloudman.cc manage_etc_hosts: true 说明如下: cloud-init 只会读取以#cloud-config开头的数据,所以这一行一定要写对。 hostname: my1.cloudman.cc告诉 cloud-init 将 hostname 设置为 my1.cloudman.cc。 manage_etc_hosts: true告诉 cloud-init 更新 /etc/hosts 文件。...