我正在尝试执行需要在 Ubuntu 14.04 ec2 实例上运行的脚本,只要实例或其在 Auto Scaling 组中的映像启动 -
#!/bin/bash-x
REGION=`curl http://169.254.169.254/latest/dynamic/instance- identity/document|grep region|awk -F\" '{print $4}'`
sudo apt-get update
sudo apt-get install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties libffi-dev
cd
wget http://ftp.ruby-lang.org/pub/ruby/2.3/ruby-2.3.1.tar.gz
tar -xzvf ruby-2.3.1.tar.gz
cd ruby-2.3.1/
./configure
make
sudo make install
apt-get install apache2
cd /home/ubuntu
wget https://aws-codedeploy-$REGION.s3.amazonaws.com/latest/install
chmod +x ./install
./install auto
但是脚本永远不会运行。我去了 cloud-init-output.log 文件,以下是日志详细信息-
Cloud-init v. 0.7.5 running 'modules:final' at Mon, 12 Dec 2016 15:54:20 +0000. Up 36.92 seconds.
2016-12-12 15:54:20,432 - util.py[WARNING]: Failed running /var/lib/cloud/instance/scripts/part-001 [-]
2016-12-12 15:54:20,436 - cc_scripts_user.py[WARNING]: Failed to run module scripts-user (scripts in /var/lib/cloud/instance/scripts)
2016-12-12 15:54:20,436 - util.py[WARNING]: Running scripts-user (<module 'cloudinit.config.cc_scripts_user' from '/usr/lib/python2.7/dist-packages/cloudinit/config/cc_scrip$
Cloud-init v. 0.7.5 finished at Mon, 12 Dec 2016 15:54:20 +0000. Datasource DataSourceEc2. Up 37.11 seconds
具体来说,我想要实现的是在实例中安装 codedeploy 。