我的用戶數據腳本執行用戶數據(雲-INIT)腳本不是EC2
#!
set -e -x
echo `whoami`
su root
yum update -y
touch ~/PLEASE_WORK.txt
其在從命令饋送:
ec2-run-instances ami-05355a6c -n 1 -g mongo-group -k mykey -f myscript.sh -t t1.micro -z us-east-1a
但是當我檢查文件/var/log/cloud-init.log
,該tail -n 5
是:
[CLOUDINIT] 2013-07-22 16:02:29,566 - cloud-init-cfg[INFO]: cloud-init-cfg ['runcmd']
[CLOUDINIT] 2013-07-22 16:02:29,583 - __init__.py[DEBUG]: restored from cache type DataSourceEc2
[CLOUDINIT] 2013-07-22 16:02:29,686 - cloud-init-cfg[DEBUG]: handling runcmd with freq=None and args=[]
[CLOUDINIT] 2013-07-22 16:02:33,691 - cloud-init-run-module[INFO]: cloud-init-run-module ['once-per-instance', 'user-scripts', 'execute', 'run-parts', '/var/lib/cloud/data/scripts']
[CLOUDINIT] 2013-07-22 16:02:33,699 - __init__.py[DEBUG]: restored from cache type DataSourceEc2
我也驗證了curl http://169.254.169.254/latest/user-data
返回我的文件準備編輯。
並沒有其他錯誤或腳本的輸出發生。我怎樣才能讓用戶數據腳本在啓動時正確執行?
ah我看到了 - 所有內容都必須經過MIME編碼。 我使用的是通用的亞馬遜linux AMI,但我在啓動日誌中看到'cloud-init'進程,因此我認爲它與ubuntu風格相同。 – lollercoaster
您不必爲ec2-run-instances使用MIME編碼腳本。 Cloud-init可能需要特定格式的數據,但亞馬遜會爲您負責 - 請參閱http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AmazonLinuxAMIBasics.html#CloudInit MIME/Base64/gzip編碼是可選的 - 您的腳本只需要以#開頭! –
好點,我使用OpenStack ... – lzap