声明:本站文章皆基于公开来源信息,仅代表作者个人观点,与作者所在公司无关!

cloud-init 执行分析

      cloud-init主要用于处理instance的初始化配置,如网络、ssh,yum源等。支持多种类型的datasource,如NoCloud, ConfigDrive, OpenNebula, Azure, AltCloud, OVF, MAAS, GCE, OpenStack, CloudSigma, Ec2, CloudStack, SmartOS等,openstack用metadata,config driver配置instance。

执行操作

1.cloud-init提供三个配置Instance的操作命令cloud-init/cloud-module/cloud-single

2.Instance启动时依次执行命令行配置Instance

       a.  cloud-init init --local

       b.  cloud-init init

       c.  cloud-init modules --mode=config

       d.  cloud-init modules --mode=final

3.文件/etc/cloud/cloud.conf分别配置init,config,final阶段执行操作,如下所示:

 1 # The modules that run in the 'init' stage
 2 cloud_init_modules:
 3  - migrator
 4  - seed_random
 5  - bootcmd
 6  - write-files
 7  - growpart
 8  - resizefs
 9  - set_hostname
10  - update_hostname
11  - update_etc_hosts
12  - ca-certs
13  - rsyslog
14  - users-groups
15  - ssh
16 # The modules that run in the 'config' stage
17 cloud_config_modules:
18 # Emit the cloud config ready event
19 # this can be used by upstart jobs for 'start on cloud-config'.
20  - emit_upstart
21  - disk_setup
22  - mounts
23  - ssh-import-id
24  - locale
25  - set-passwords
26  - grub-dpkg
27  - apt-pipelining
28  - apt-configure
29  - package-update-upgrade-install
30  - landscape
31  - timezone
32  - puppet
33  - chef
34  - salt-minion
35  - mcollective
36  - disable-ec2-metadata
37  - runcmd
38  - byobu
39 # The modules that run in the 'final' stage
40 cloud_final_modules:
41  - rightscale_userdata
42  - scripts-vendor
43  - scripts-per-once
44  - scripts-per-boot
45  - scripts-per-instance
46  - scripts-user
47  - ssh-authkey-fingerprints
48  - keys-to-console
49  - phone-home
50  - final-message
51  - power-state-change
View Code

代码

 1.根据/etc/cloud/cloud.conf的配置,初始化cloud-init执行环境,如初始化datasource、生成seed /var/lib/cloud。注根据/etc/cloud/cloud.conf指定的datasource_list初始化datasource

 2.初始化过程中完成Instance network配置    注 configDriverNet 利用 openstack/content/0000提供的参数,配置各种系统的network,网络配置优先利用openstack/version/network_data.json

 3.执行modules对脚本配置Instance,如cc_set_hostname.py

版本

当前社区打包cloud-init的最新版本是0.7.6(2014-10-10),configDrive 利用openstack/content/0000配置网络。

Openstack Mitaka支持利用configDrive的openstack/version/network_data.json,同时支持配置网卡的mtu,建议升级cloud-init到0.7.7

 

参考文档:

    http://cloudinit.readthedocs.io/en/latest/index.html

    https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux_OpenStack_Platform/5/html/End_User_Guide/config-drive.html

    http://blog.sina.com.cn/s/blog_959491260101m2dd.html

    http://cloudinit.readthedocs.io/en/latest/topics/examples.html

posted @ 2017-06-30 10:40  Hi,云计算!  阅读(930)  评论(0编辑  收藏  举报