cloud-init
在虚拟机启动后执行编排任务, nova boot时指定 user-data 参数
Nova USER DATA
数据获取方式:
- 169.254.169.254
- config drive(In Heat set config_drive: true)
常见使用方式如下:
#nova boot \
--image ubuntu-trusty-server-amd64
--key_name testkey \
--flavor m1.small \
--user-data userdata.txt \
--nic net-id=443434-dsx3-2323-dssx-43343434 \
test
And, userdata.txt
#!/bin/sh -e
#Frobincate a newly booted box
initialize_box
for foo in forbnications; do
frobincate_machine $foo || break
done
exit $?
But, stop doing this, and use cloud-config below which is better
cloud-config
Enables you to bootstrap a newly bootd VM. OpenStack’s most underrated feature, 100% YAML.
常用功能如下:
更新软件(apt-get update/yum update)
Update system on first boot
#cloud-config
package_update: true
package_upgrade: true
users
Configure users and groups
users:
- default
- name: foobar
gecos: ""
groups: users,adm
lock-passwd: false
passwd: 23lkjsflkas0923Da
shell: /bin/bash
sudo: "ALL=(ALL) NOPASSWD:ALL"
ssh_pwauth
Enable/disable SSH password authentication
ssh_pwauth: true
write_files
Write arbitrary files
write_files:
- path: /etc/demo
permissions: '0644'
content: |
This