【问题标题】:cloud-init is there a way to force an execution order?cloud-init 有没有办法强制执行顺序?
【发布时间】:2018-02-25 01:43:52
【问题描述】:

我正在运行 Debian 9.1,我想在创建时使用 cloud-init 配置我的 VPS,但我遇到了一个特定的配置问题。

这是来自所提供快照的 cloud.cfg 的默认值:

# The modules that run in the 'init' stage
cloud_init_modules:
 - migrator
 - seed_random
 - bootcmd
 - write-files
 - growpart
 - resizefs
 - disk_setup
 - mounts
 - 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 my cloud config ready event
# this can be used by upstart jobs for 'start on cloud-config'.
 - emit_upstart
 - ssh-import-id
 - locale
 - set-passwords
 - grub-dpkg
 - apt-pipelining
 - apt-configure
 - ntp
 - timezone
 - disable-ec2-metadata
 - runcmd
 - byobu

# The modules that run in the 'final' stage
cloud_final_modules:
 - package-update-upgrade-install
 - fan
 - puppet
 - chef
 - salt-minion
 - mcollective
 - 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

如您所见,runcmd 将在 config 阶段执行,在 apt-configure 之后。

作为我的配置的一部分,我正在安装多个包,其中一个需要我添加一个新源并从密钥服务器导入一个密钥。有一个问题,因为导入密钥需要在系统上安装dirmngr,但Debian 9.1默认没有安装它。

但是,由于 apt-configure 在 runcmd 之前执行,我无法在尝试导入密钥之前安装 dirmngr。结果,其余配置将失败,系统将处于不需要的状态。

我该如何解决这个问题?

【问题讨论】:

    标签: linux debian cloud-init


    【解决方案1】:

    关于 Debian 9.1 上缺少 dirmngr 包导致 apt-configure 模块失败的具体情况,我已成功将以下 bootcmd 条目添加到我的 cloud-init 配置中:

    # APT fails to acquire GPG keys if package dirmngr is missing
    bootcmd:
      - [ cloud-init-per, once, dirmngr-aptupdate, apt-get, update ]
      - [ cloud-init-per, once, dirmngr-aptinstall, apt-get, install, dirmngr ]
    

    由于cloud-init的配置是从网络获取的(我使用的是EC2用户数据),所以当bootcmd被执行时,网络保证是正常的。 cloud-init-per 程序可以轻松确保在进一步的实例启动时不会重新执行这些命令。

    【讨论】:

      猜你喜欢
      • 2011-03-28
      • 2022-11-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-10-06
      • 2011-10-07
      相关资源
      最近更新 更多