我正在尝试创建一个 AMI(基于 ubuntu;ami-2d39803a),我可以将其重用于安装了一组组件的项目。我正在使用 packer 通过一个由配置程序执行的 shell 脚本来实现这一点:
#/bin/bash
# salt
sudo add-apt-repository --yes ppa:saltstack/salt
sudo apt-get update
sudo apt-get install --yes salt-api salt-cloud salt-master salt-minion salt-ssh salt-syndic
# run on startup
sudo update-rc.d salt-master defaults
# salt hostname for minions
sudo bash -v -c "echo 127.0.0.1 salt >> /etc/hosts"
# get docker-formula and move it to /srv/salt
sudo mkdir /tmp/docker-formula
sudo git clone https://github.com/saltstack-formulas/docker-formula /tmp/docker-formula/.
sudo mkdir -p /srv/salt
sudo cp -vr /tmp/docker-formula/docker /srv/salt/docker/
# top.sls
sudo cp -v /ops/config/top.sls /srv/salt/
# accept all minions (minions try to connect to master every 30 seconds)
sudo sleep 30
sudo salt-key -A --yes
# apply to minions
sudo salt '*' -v -t 60 state.apply
# add user to docker group
sudo usermod -aG docker $USER
这是奇怪的部分。当我创建一个新实例并一一执行 shell 脚本命令时,运行它就可以了。但是,当我运行时,packer build
我得到以下信息:
......
aws-us-east-1-ubuntu-base: The following keys are going to be accepted:
aws-us-east-1-ubuntu-base: Unaccepted Keys:
aws-us-east-1-ubuntu-base: ip-172-30-2-245.ec2.internal
aws-us-east-1-ubuntu-base: Key for minion ip-172-30-2-245.ec2.internal accepted.
aws-us-east-1-ubuntu-base: Executing job with jid 20160913191722659701
aws-us-east-1-ubuntu-base: -------------------------------------------
aws-us-east-1-ubuntu-base:
aws-us-east-1-ubuntu-base: ip-172-30-2-245.ec2.internal:
aws-us-east-1-ubuntu-base: Minion did not return. [No response]
aws-us-east-1-ubuntu-base: usermod: group 'docker' does not exist
==> aws-us-east-1-ubuntu-base: Terminating the source AWS instance...
==> aws-us-east-1-ubuntu-base: No AMIs to cleanup
==> aws-us-east-1-ubuntu-base: Deleting temporary security group...
==> aws-us-east-1-ubuntu-base: Deleting temporary keypair...
Build 'aws-us-east-1-ubuntu-base' errored: Script exited with non-zero exit status: 6
它sudo salt '*' -v -t 60 state.apply
失败了:
小黄人没有回来。[没有反应]
这两种情况之间的唯一区别是加壳程序是从文件执行 bash 脚本,而创建实例不是执行文件。我看不出它与盐大师和它的爪牙之间的沟通有什么关系。
有什么想法吗?