问题描述
我可以构建AMI图像就好了。但是,他们已经停止了与EC2用户数据的工作:
有用户数据:
$猫/tmp/user_data.sh
#!/斌/庆典
触摸的/ tmp / i_have_user_data /根/ i_have_user_data
和我可以启动一个普通的Ubuntu的形象:
AWS EC2运行实例--instance型m3.medium --image-ID AMI-eed10e86 --user数据文件:///tmp/user_data.sh
和它的作品:
的ubuntu @ IP-10-165-90-180:〜$ LS的/ tmp / i_have_user_data
的/ tmp / i_have_user_data P>
但是,如果我建立一个AMI基于该之一,帕克:
建设者:
{
类型:亚马逊EBS,
区域:美东1,
source_ami:AMI-eed10e86,
INSTANCE_TYPE:m3.large,
ssh_username:Ubuntu的,
标签:{
OS_VERSION:Ubuntu的,
发行:LTS
}
}
]
...并运行非常相同的方式和以前一样,没有什么在/ tmp目录。但是,很明显,如果你运行有用户数据的 ec2metadata em>的:
的ramdisk-ID:不可用
reserveration ID:不可用
安全组:默认
用户数据:#!/斌/庆典
触摸的/ tmp / i_have_user_data /根/ i_have_user_data
我是pretty的肯定这是一个国家的问题,而且删除状态文件将会使这一切神奇的工作。或者,有一个办法可以把云决赛的新贵脚本的工作,这可能是什么坏了。无论如何,我还没有发现呢。
更新
我做到了转动用户数据脚本转换为boothook工作:
#云boothook
#!/ bin / sh的
回声运行用户数据脚本
还在寻找他们为什么停止工作的解释。云初始化的文档越来越好,但还有很长的路要走。
帕克创建图像然后拿着快照使得AMI之前。这是你第一次启动。在这一点上,你需要引导例如,根据Ubuntu的它,将清洁的目录。
我会尝试把文件中的某处,看看它是否仍然存在。
借助#云boothook 运行每次,因为说明你负责禁用它的文档。
I can build AMI images just fine. But they've stopped working with EC2 User Data:
There is user data:
$ cat /tmp/user_data.sh
#!/bin/bash
touch /tmp/i_have_user_data /root/i_have_user_data
And I can launch a plain Ubuntu image:
aws ec2 run-instances --instance-type m3.medium --image-id ami-eed10e86 --user-data file:///tmp/user_data.sh
And it works:
ubuntu@ip-10-165-90-180:~$ ls /tmp/i_have_user_data
/tmp/i_have_user_data
But if I build an AMI based on that one, with Packer:
"builders": [
{
"type": "amazon-ebs",
"region": "us-east-1",
"source_ami": "ami-eed10e86",
"instance_type": "m3.large",
"ssh_username": "ubuntu",
"tags": {
"OS_Version": "Ubuntu",
"Release": "LTS"
}
}
],
... and run that the very same way as before, there's nothing in /tmp. However, it's clear that there is user data if you run ec2metadata:
ramdisk-id: unavailable
reserveration-id: unavailable
security-groups: default
user-data: #!/bin/bash
touch /tmp/i_have_user_data /root/i_have_user_data
I'm pretty sure it's a state issue and that removing a statefile is going to make it all magically work. Or, there's a trick to make the cloud-final upstart script work, which might be what's broken. Anyway, I haven't found that yet.
Update:
I made it work by turning the user-data script into a boothook:
#cloud-boothook
#!/bin/sh
echo "RUNNING USER DATA SCRIPT"
Still looking for an explanation for why they stopped working. Cloud Init's docs are getting better, but there's still a way to go.
Packer creates your image then takes a snapshot before making the AMI. This is your first boot. At this point you would need to boot the instance, which according to Ubuntu, would clean the /tmp directory.
I would try putting the file elsewhere and see if it persists.
The #cloud-boothook runs every time, given the docs that state you responsible for disabling it.
这篇关于如何使在刚建的AMI,与帕克取得了EC2的用户数据工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!