- 安装cloud-init
- 配置合适的数据源,配置文件位于/etc/cloud/cloud.cfg.d/90_dpkg.cfg,一般配置为[ConfigDrive, Ec2],也就是通过ConfigDrive盘或者Ec2(nova metadata api或者说169.254.169.254接口)数据源来获取云主机配置信息
- 根据需要修改cloud-init的配置文件,位于/etc/cloud/cloud.cfg,一般是为了打开root用户的用户名密码登录功能,比如如下配置:
-
1234567891011121314151617181920212223242526272829303132333435363738394041users:- defaultdisable_root: 0apt_preserve_sources_list: truessh_pwauth: 0preserve_hostname: False# datasource_list: ["NoCloud", "ConfigDrive", "OVF", "MAAS", "Ec2", "CloudStack"]cloud_init_modules:- bootcmd- resizefs- write-files- set_hostname- update_hostname- update_etc_hosts- ca-certs- rsyslog- sshsystem_info:distro: ubuntudefault_user:name: rootlock_passwd: 0paths:cloud_dir: /var/lib/cloudtemplates_dir: /etc/cloud/templatespackage_mirrors:- arches: [i386, amd64]failsafe:primary: http://archive.ubuntu.com/ubuntusecurity: http://security.ubuntu.com/ubuntusearch:primary:- http://%(ec2_region)s.ec2.archive.ubuntu.com/ubuntu/- http://%(availability_zone)s.clouds.archive.ubuntu.com/ubuntu/security: []- arches: [armhf, armel, default]failsafe:primary: http://ports.ubuntu.com/ubuntu-portssecurity: http://ports.ubuntu.com/ubuntu-ports
- 修改cloud-init服务启动依赖,这一步是为了防止/etc/network/interfaces里面有多张网卡的dhcp配置,而启动networking服务的时候如果只有一张网卡,就会报服务启动Failed,导致依赖networking服务的cloud-init服务无法启动,修改方式为:注释掉/lib/systemd/system/cloud-init.service文件中的Requires=networking.service这行,也即改为:#Requires=networking.service
- /etc/default/grub中GRUB_CMDLINE_LINUX_DEFAULT加上console=tty0 console=ttyS0,115200,用来生成console.log(nova console-log可以获取到)
- 网卡名称ensX重置为老版本ethX方法是在上面的配置中继续增加net.ifnames=0 biosdevname=0