首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >cloud-init: cloud-config指令的执行顺序是什么?

cloud-init: cloud-config指令的执行顺序是什么?
EN

Stack Overflow用户
提问于 2015-12-05 03:16:44
回答 1查看 23.4K关注 0票数 35

cloud-init user-data对象的cloud-config部分中指令的顺序是什么。这对于避免竞争类型条件很重要。

我知道bootcmd在runcmd之前运行,但是所有方法的顺序有没有一个很好的列表?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-05-12 23:06:18

来自https://git.launchpad.net/cloud-init/tree/config/cloud.cfg (感谢garbelini)

(截至2017年9月,上面的链接是不正确的,现在是https://git.launchpad.net/cloud-init/tree/config/cloud.cfg.tmpl,请参阅下面的注释)

代码语言:javascript
复制
# The modules that run in the 'init' stage
cloud_init_modules:
 - migrator
 - ubuntu-init-switch
 - seed_random
 - bootcmd
 - write-files
 - growpart
 - resizefs
 - set_hostname
 - update_hostname
 - update_etc_hosts
 - ca-certs
 - rsyslog
 - users-groups
 - ssh

# The modules that run in the 'config' stage
cloud_config_modules:
# Emit the cloud config ready event
# this can be used by upstart jobs for 'start on cloud-config'.
 - emit_upstart
 - disk_setup
 - mounts
 - ssh-import-id
 - locale
 - set-passwords
 - snappy
 - grub-dpkg
 - apt-pipelining
 - apt-configure
 - package-update-upgrade-install
 - fan
 - landscape
 - timezone
 - lxd
 - puppet
 - chef
 - salt-minion
 - mcollective
 - disable-ec2-metadata
 - runcmd
 - byobu

# The modules that run in the 'final' stage
cloud_final_modules:
 - rightscale_userdata
 - scripts-vendor
 - scripts-per-once
 - scripts-per-boot
 - scripts-per-instance
 - scripts-user
 - ssh-authkey-fingerprints
 - keys-to-console
 - phone-home
 - final-message
 - power-state-change

此外:

存在配置合并,顺序如下:- cli配置文件覆盖环境配置文件,环境配置文件覆盖实例配置,实例配置覆盖数据源配置,数据源配置覆盖基本配置,基本配置覆盖默认配置。(请参阅Changelog)

在各个生成的脚本目录中,脚本按照python "sorted()“内置给出的顺序运行

注意:尽管在回答时这是正确的,但查看上面提到的存储库(截至2017年9月),现在有一个cloud.cfg.tmpl模板文件,它对不同的发行版具有略有不同的设置

代码语言:javascript
复制
# The modules that run in the 'init' stage
cloud_init_modules:
 - migrator
 - seed_random
 - bootcmd
 - write-files
 - growpart
 - resizefs
{% if variant not in ["freebsd"] %}
 - disk_setup
 - mounts
{% endif %}
 - set_hostname
 - update_hostname
{% if variant not in ["freebsd"] %}
 - update_etc_hosts
 - ca-certs
 - rsyslog
{% endif %}
 - users-groups
 - ssh

# The modules that run in the 'config' stage
cloud_config_modules:
{% if variant in ["ubuntu", "unknown", "debian"] %}
# Emit the cloud config ready event
# this can be used by upstart jobs for 'start on cloud-config'.
 - emit_upstart
 - snap_config
{% endif %}
 - ssh-import-id
 - locale
 - set-passwords
{% if variant in ["rhel", "fedora"] %}
 - spacewalk
 - yum-add-repo
{% endif %}
{% if variant in ["ubuntu", "unknown", "debian"] %}
 - grub-dpkg
 - apt-pipelining
 - apt-configure
{% endif %}
{% if variant not in ["freebsd"] %}
 - ntp
{% endif %}
 - timezone
 - disable-ec2-metadata
 - runcmd
{% if variant in ["ubuntu", "unknown", "debian"] %}
 - byobu
{% endif %}

# The modules that run in the 'final' stage
cloud_final_modules:
{% if variant in ["ubuntu", "unknown", "debian"] %}
 - snappy
{% endif %}
 - package-update-upgrade-install
{% if variant in ["ubuntu", "unknown", "debian"] %}
 - fan
 - landscape
 - lxd
{% endif %}
{% if variant not in ["freebsd"] %}
 - puppet
 - chef
 - salt-minion
 - mcollective
{% endif %}
 - rightscale_userdata
 - scripts-vendor
 - scripts-per-once
 - scripts-per-boot
 - scripts-per-instance
 - scripts-user
 - ssh-authkey-fingerprints
 - keys-to-console
 - phone-home
 - final-message
 - power-state-change
票数 36
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/34095839

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档