Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where to find logs for a cloud-init user-data script?

Tags:

I'm initializing spot instances running a derivative of the standard Ubuntu 13.04 AMI by pasting a shell script into the user-data field.

This works. The script runs. But it's difficult to debug because I can't figure out where the output of the script is being logged, if anywhere.

I've looked in /var/log/cloud-init.log, which seems to contain a bunch of stuff that would be relevant to debugging cloud-init, itself, but nothing about my script. I grepped in /var/log and found nothing.

Is there something special I have to do to turn logging on?

like image 777
cbare Avatar asked Sep 09 '13 05:09

cbare


People also ask

Where can I find cloud-init logs?

Boot Time Analysis - cloud-init analyze log file into formatted and sorted events. It allows for detailed analysis of the most costly cloud-init operations are to determine the long-pole in cloud-init configuration and setup. These subcommands default to reading /var/log/cloud-init. log.

Where are cloud-init scripts stored?

Cloud-init config is provided in two places: /etc/cloud/cloud. cfg. /etc/cloud/cloud.


2 Answers

The default location for cloud init user data is already /var/log/cloud-init-output.log, in AWS, DigitalOcean and most other cloud providers. You don't need to set up any additional logging to see the output.

like image 149
mikemaccana Avatar answered Nov 03 '22 08:11

mikemaccana


You could create a cloud-config file (with "#cloud-config" at the top) for your userdata, use runcmd to call the script, and then enable output logging like this:

output: {all: '| tee -a /var/log/cloud-init-output.log'} 
like image 40
Michael Avatar answered Nov 03 '22 09:11

Michael