从cloud-init (在云中启动虚拟机时自动运行脚本,例如Amazon EC2)的输出到哪里去? 我想知道我的初始化脚本执行成功。
有一个/var/log/cloud-init.log文件,但它似乎只包含部分输出(即从SSH密钥初始化)。
自从cloud-init 0.7.5 (2014年4月1日发布)以来, cloud-init所有输出都被默认捕获到/var/log/cloud-init-output.log 。 此默认日志loggingconfiguration是从2014年1月14日起提交的 :
# 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'}
要添加对以前版本的cloud-init ,您可以手动将此configuration手动添加到您的Cloud Config Data 。
我无法find一个“原生”的方式来做到这一点。 在将脚本传递给cloud-init之前,我只是(自动)在脚本的每一行添加>> /tmp/init-script-log 2>&1来将stout和stderr转发到文件。
在我正在使用的Centos 7 AMI上,我的用户数据脚本的输出位于/var/log/cloud-init-output.log 。
在我的EC2盒子上(运行Amazon Linux AMI),它存储在/var/log/cloud-init.log中
首先让我恭喜你使用cloud-init,这是一个非常了不起的工具!
没有办法设置日志级别,但默认情况下,cloud-init将在启用DEBUG的情况下运行。
目前仍处于繁重的发展阶段,我认为Ubuntu的发布会让它变得更好