Ubuntu的AMI不加载用户数据 [英] Ubuntu AMI not loading user-data

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

问题描述

我试图将用户数据加载到一个Ubuntu 12.04 LTS急性心肌梗死(AMI-a29943cb,但我已经尝试了一些别人没有用),通过博托的ec2.run_instances(...,USER_DATA = USER_DATA)。同样,我曾与手动提供用户数据,同时通过AWS控制台启动实例没有成功。有在/ var /日志/系统日志没有结果或信息的任何我试过的方法。

I am attempting to load user data into an Ubuntu 12.04 LTS AMI (ami-a29943cb, but I've tried a few others to no avail) via boto's ec2.run_instances(..., user_data=USER_DATA). Similarly, I have had no success with manually supplying the user data while launching the instances via the AWS console. There are no results or messages in /var/logs/syslog for any of the methods I've tried.

USER_DATA看起来像下面,请阅读从一个文件中的字符串:

USER_DATA looks something like the following, read in as a string from a file:

#!/usr/bin/env python

import boto

AWS_BOOTSTRAP_BUCKET  = ''
AWS_ACCESS_KEY_ID     = ''
AWS_SECRET_ACCESS_KEY = ''

# Pull processing script from S3.
print 'Bootstrapping started.....'
print 'Connecting to S3...'
s3     = boto.connect_s3(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)
bucket = s3.get_bucket(AWS_BOOTSTRAP_BUCKET)
print 'Downloading bootstrap file...'
key    = bucket.get_key('xxx')
key.get_contents_to_filename('xxx')

print 'Importing Bootstrap file...'
import xxx
xxx.process()

# Shut down the EC2 instance running this process.
print 'Shutting down this instance...'
import socket
desired_hostname = socket.gethostname()
ec2 = boto.connect_ec2(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)
reservations = ec2.get_all_instances()
for reservation in reservations:
    for instance in reservation.instances:
        if desired_hostname in instance.private_dns_name:
            instance.terminate()

予人还试图将文件上传到公共S3存储和装载它以这种方式,再次无济于事:

I have furthermore tried uploading the file to a public S3 bucket and loading it in this manner, once again to no avail:

#include
https://s3.amazonaws.com/bucket/file.py

有没有人在这方面有什么建议?难道我完全误解的用户数据/目的云init或为技术仅仅是打破在AMI我想利用?

Does anyone have any advice in this regard? Am I completely misunderstanding the purpose of user-data/cloud-init or is the technology merely broken in the AMI I am trying to utilize?

推荐答案

这是很难知道发生了什么事情没有一条错误信息,但也有一些地方,你可以看一下:

It's hard to know what happened without an error message, but there are a few places you can look:

  1. 文件 /var/log/cloud-init.log 通常包含任何错误(例如博托导入失败),在实例引导的发生。
  2. 目录的/ var / lib中/云/实例将包含下载到该实例的原始脚本和用户数据
  3. 您可以通过右键单击该实例,看看是否博托正确填充它。
  4. 查看/编辑USER_DATA的AWS控制台中
  1. The file /var/log/cloud-init.log will usually contain any errors (e.g. boto import failure) that occurred during instance bootstrapping.
  2. The directory /var/lib/cloud/instance will contain the raw scripts and user-data downloaded to the instance
  3. You can View/Edit USER_DATA inside the AWS console by right-clicking the instance, to see if boto populated it correctly.

寻找在这些地方应该帮助提供清晰。

Looking in those places should help provide clarity.

我知道的Ubuntu 12.04自带博托2.2.2:

I know Ubuntu 12.04 comes with boto 2.2.2:

root@vanilla-562c:/var/lib/cloud/instance# python
Python 2.7.3 (default, Apr 20 2012, 22:44:07) 
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import boto
>>> boto.__version__
'2.2.2'

..但我不知道它在你的PYTHONPATH在运行时实际访问。

..but I wonder if it's actually accessible in your PYTHONPATH at runtime.

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

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