使用cloud-init用户数据 [英] Using cloud-init user data

查看:429
本文介绍了使用cloud-init用户数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的cloud-init用户数据,正在传递给ec2。我在ec2实例上通过右键单击该实例并在其中设置用户数据来设置此数据。



以下是我的云初始化用户数据

 #cloud-config 

runcmd:
-[ls,-l,/]
- [sh,-xc, echo $(date)':hello world!']
-[sh,-c,echo ========= hello world'===== ====]
-[touch,/home/ec2-user/hello.txt]

final_message:系统终于在10秒后启动

我从这里,我添加了触摸命令



我的期望是查看/var/log/cloud-init.log上的数据。但我在那里看不到。另外我也看不到任何错误,也看不到创建的hello.txt文件。



是否缺少某些内容?



我正在运行amazon linux实例,而不是ubuntu实例

解决方案

这是您第三条命令中的语法错误:

 -[sh,-c,echo ========== hello world'===== ====] 

这是有效的用户数据:

 #cloud-config 

runcmd:
-[ls,-l,/]
-[ sh,-xc,'echo $(date):hello world!']
-[sh,-c,'echo ========= hello world ====== ===']
-[touch,/home/ec2-user/hello.txt]

final_message:系统终于启动了

输出:{全部:'| tee -a /var/log/cloud-init-output.log'}

注意cloud-init执行日志仅在 /var/log/cloud-init.log 中。指定 output 指令后,您应该在 /var/log/cloud-init-output.log 中看到输出。 / p>

I have a simple cloud-init user data that I am passing in to ec2. I set this data on my ec2 instance by right clicking the instance and setting the user data in there.

Following is my cloud-init 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, after 10 seconds"

I got this example from here and I added the touch command

My expectation was to see the data on the /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

Is there something that I am missing?

I am running an amazon linux instance and not an ubuntu instance

解决方案

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. you should see output in /var/log/cloud-init-output.log after specifying the output directive.

这篇关于使用cloud-init用户数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆