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?
相关问题
- JQ: Select when attribute value exists in a bash a
- How to upgrade/install Upstart deamon version 1.5
- Connecting to Windows Server Service Bus on AWS
- how to get the available capacity of a zone in AWS
- Amazon S3: Grant anonymous access from IP (via buc
相关文章
- I cannot locate production log files on Elastic Be
- AWS - Configuring access to EC2 instance from Bean
- Error: “The security token included in the request
- Ansible Timeout (12s) waiting for privilege escala
- resource:memory error when trying to run an ECS ta
- Spark EC2 SSH connection error SSH return code 255
- GPU based algorithm on AWS Lambda
- AWS S3 access denied when getting image by url
On most Linux distros (including CentOS and Ubuntu), you can restart the cloud-init service using systemctl:
And then check the output of the journal to see the results:
Kudus to @Rico, and also, if you want to run a single module - either for testing or because your distro doesn't enable a module by default (hi Precise!), you can
For example when my distro doesn't run
write_files
by default (like a lot of old distros), I use this at the top of runcmd:[I know its not really an answer to the OP, but when looking to solve my problem this question was one of the top results, so I figure other people might find this useful]
You can just run it like this:
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:
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:
In older versions the equivalent of
cloud-init init
is: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.