如何手动运行cloud-init? [英] How to run cloud-init manually?

查看:223
本文介绍了如何手动运行cloud-init?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写CloudFormation模板,并尝试调试模板中提供的用户数据脚本。如何手动运行 cloud-init 并使其执行与启动新实例时相同的操作?

I'm writing a CloudFormation template and I'm trying to debug the user-data script I provide in the template. How can I run the cloud-init manually and make it perform the same actions it does when starting a new instance?

推荐答案

您可以像这样运行它:

/usr/bin/cloud-init -d init

这将使用初始模块运行云初始化设置。 (-d选项用于调试)如果要运行所有模块,则必须运行:

This runs the cloud init setup with the initial modules. (The -d option is for debug) If want to run all the modules you have to run:

/usr/bin/cloud-init -d modules

请记住,第二次运行这些命令不会起作用因为它已经在启动时运行了。要强制在引导时间后运行,可以从命令行运行:

Keep in mind that the second time you run these it doesn't do much since it has already run at boot time. To force to run after boot time you can run from the command line:

( cd /var/lib/cloud/ && sudo rm -rf * )

在旧版本中,等效于 cloud -init init 是:

In older versions the equivalent of cloud-init init is:

/usr/bin/cloud-init start

您可能还会发现此问题很有用,尽管它适用于旧版本的cloud-init:如何制作cloud-init启动脚本

You may also find this question useful although it applies to the older versions of cloud-init: How do I make cloud-init startup scripts run every time my EC2 instance boots?

云初始化文档此处仅举几个例子。但这并没有说明命令行选项或每个模块,因此您必须在配置中使用不同的值才能获得所需的结果。当然,您也可以查看代码。

The documentation for cloud init here just gives you examples. But it doesn't explain the command line options or each one of the modules, so you have to play around with different values in the config to get your desired results. Of course you can also look at the code.

这篇关于如何手动运行cloud-init?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆