[英]Using cloud-init user data
I have a simple cloud-init user data that I am passing in to ec2. 我有一个简单的cloud-init用户数据,即将传递给ec2。 I set this data on my ec2 instance by right clicking the instance and setting the user data in there.
我在ec2实例上通过右键单击该实例并在其中设置用户数据来设置此数据。
Following is my cloud-init user data 以下是我的cloud-init用户数据
#cloud-config
runcmd:
- [ ls, -l, / ]
- [ sh, -xc, "echo $(date) ': hello world!'" ]
- [ sh, -c, echo "=========hello world'=========" ]
- [ touch, /home/ec2-user/hello.txt ]
final_message: "The system is finally up, after 10 seconds"
I got this example from here and I added the touch command 我从这里得到了这个示例,并添加了touch命令
My expectation was to see the data on the /var/log/cloud-init.log. 我的期望是在/var/log/cloud-init.log上看到数据。 But I don't see it there.
但我在那里看不到。 Also I don't see any errors nor see the hello.txt file created
我也看不到任何错误,也看不到创建的hello.txt文件
Is there something that I am missing? 有什么我想念的吗?
I am running an amazon linux instance and not an ubuntu instance 我正在运行amazon linux实例而不是ubuntu实例
It's an syntax error in your 3rd command: 这是您的第三个命令中的语法错误:
- [ sh, -c, echo "=========hello world'=========" ]
This is a working user-data: 这是一个有效的用户数据:
#cloud-config
runcmd:
- [ ls, -l, / ]
- [ sh, -xc, 'echo $(date) ": hello world!"' ]
- [ sh, -c, 'echo "=========hello world========="' ]
- [ touch, /home/ec2-user/hello.txt ]
final_message: "The system is finally up"
output : { all : '| tee -a /var/log/cloud-init-output.log' }
Notice that it shows cloud-init execution log only in /var/log/cloud-init.log
. 请注意,它仅在
/var/log/cloud-init.log
显示cloud-init执行日志。 you should see output in /var/log/cloud-init-output.log
after specifying the output
directive. 指定
output
指令后,您应该在/var/log/cloud-init-output.log
看到输出。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.