[英]Using cloud-init user data
我有一個簡單的cloud-init用戶數據,即將傳遞給ec2。 我在ec2實例上通過右鍵單擊該實例並在其中設置用戶數據來設置此數據。
以下是我的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"
我從這里得到了這個示例,並添加了touch命令
我的期望是在/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: "The system is finally up"
output : { all : '| tee -a /var/log/cloud-init-output.log' }
請注意,它僅在/var/log/cloud-init.log
顯示cloud-init執行日志。 指定output
指令后,您應該在/var/log/cloud-init-output.log
看到輸出。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.