我试图将简单的bash脚本传递给AWS CentOS 7实例。用户数据如下所示:
#!/bin/bash
yum update -y
这是cloud init log的一个片段:
Apr 1 19:03:01 ip-172-20-60-102 cloud-init: /usr/bin/env: bash yum update -y : No such file or directory
Apr 1 19:03:01 ip-172-20-60-102 cloud-init: 2016-04-01 19:03:01,604 - util.py[WARNING]: Failed running /var/lib/cloud/instance/scripts/part-001 [127]
Apr 1 19:03:01 ip-172-20-60-102 cloud-init: 2016-04-01 19:03:01,616 - cc_scripts_user.py[WARNING]: Failed to run module scripts-user (scripts in /var/lib/cloud/instance/scripts)
Apr 1 19:03:01 ip-172-20-60-102 cloud-init: 2016-04-01 19:03:01,617 - util.py[WARNING]: Running scripts-user (<module 'cloudinit.config.cc_scripts_user' from '/usr/lib/python2.7/site-packages/cloudinit/config/cc_scripts_user.pyc'>) failed
我尝试了一种不同的方法,如下所示: Bash script passed to AWS EC2 Instance as User Data file fails to load on initial boot
所以我将用户数据更改为:
"UserData" : { "Fn::Base64" : { "Fn::Join" : ["", [
"#!/bin/bash\n\n",
"yum update -y"
]]}}
我遇到了不同的错误:
Apr 1 19:28:17 ip-172-20-60-102 cloud-init: 2016-04-01 19:28:17,450 - __init__.py[WARNING]: Unhandled non-multipart (text/x-not-multipart) userdata: '"UserData" : { "Fn::Base...'
Apr 1 19:28:20 ip-172-20-60-102 cloud-init: Cloud-init v. 0.7.5 running 'modules:config' at Fri, 01 Apr 2016 19:28:20 +0000. Up 48.56 seconds.
Apr 1 19:28:21 ip-172-20-60-102 cloud-init: Cloud-init v. 0.7.5 running 'modules:final' at Fri, 01 Apr 2016 19:28:20 +0000. Up 48.89 seconds.
答案 0 :(得分:0)
使用绝对路径。试试/usr/bin/yum -y update
。