26

Where does output from cloud-init (automatically runs scripts when starting up a virtual machine in the cloud, for example at Amazon EC2) go? I would like to know that my initialization scripts executed successfully.

There is a /var/log/cloud-init.log file, but it seems to contain only partial output (namely from the SSH key initialization).

Jonas
  • 1,215
Make Mark
  • 2,024
  • 4
  • 17
  • 16

8 Answers8

26

Since cloud-init 0.7.5 (released on Apr 1 2014), all output from cloud-init is captured by default to /var/log/cloud-init-output.log. This default logging configuration was added in a commit from Jan 14 2014:

# this tells cloud-init to redirect its stdout and stderr to
# 'tee -a /var/log/cloud-init-output.log' so the user can see output
# there without needing to look on the console.
output: {all: '| tee -a /var/log/cloud-init-output.log'}

To add support for previous versions of cloud-init, you can manually add this configuration manually to your Cloud Config Data.

pawstrong
  • 131
  • 2
  • 6
7

The log is stored in systemd:

journalctl -u cloud-final
Graham North
  • 71
  • 1
  • 1
3

I couldn't find way a "native" way for doing that. Before passing the script to cloud-init, I've simply (automatically) appended a >> /tmp/init-script-log 2>&1 to each line of the script, to forward stout and stderr to a file.

2

On the Centos 7 AMI I am using, the output of my user data script is in /var/log/cloud-init-output.log.

rakslice
  • 492
1

On my EC2 box (running the Amazon Linux AMI) it's stored in /var/log/cloud-init.log

Edouard
  • 11
  • 1
0

SystemD vote for me when trying to find logs in CentOs7 when /var/log/cloud-init-output.log is not present. journalctl -u cloud-final

0

I've found log output in /var/log/messages (CentOS7 AWS AMI)

mbo
  • 101
-5

First of all let me congratulate you on using cloud-init, it's a quite amazing tool!

There's no way yet to setup a log level but by default cloud-init will run with DEBUG enabled.

It's still in heavy development, I expect it to be a lot better by the release of Ubuntu Natty

lynxman
  • 9,597