Closed6

EC2のプロビジョニング

TocyukiTocyuki

個人的に以下がEC2プロビジョニングおよびAMI作成のベストプラクティス

  • PackerのAnsibleプロビジョナーを使ってプロビジョニング&AMI作成
  • ローカルはVagrantで開発
  • テストはGoss

難点は時間がかかることだけどそれ以外はとても良い感じ
久しぶりにこの構成でプロビジョニングするので最新バージョンのAnsible、Packer、Vagrantでの奮闘記録を連ねていこう

TocyukiTocyuki

いきなりvagrant upでこけたw

==> app: Running provisioner: ansible_local...
    app: Installing Ansible...
    app: Installing pip... (for Ansible installation)
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

curl https://bootstrap.pypa.io/get-pip.py | sudo python

Stdout from the command:

ERROR: This script does not work on Python 2.7 The minimum supported Python version is 3.6. Please use https://bootstrap.pypa.io/2.7/get-pip.py instead.


Stderr from the command:

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 1882k  100 1882k    0     0   806k      0  0:00:02  0:00:02 --:--:--  806k
TocyukiTocyuki

おや?

==> app: Running provisioner: shell...
    app: Running: inline script
    app: /tmp/vagrant-shell: line 1: dnf: command not found
The SSH command responded with a non-zero exit status. Vagrant
assumes that this means the command failed. The output for this command
should be in the log above. Please read the output to determine what
went wrong.
TocyukiTocyuki

あー、dnfのままになってただけかw
OSがAmazonLinux2なのでyumに直したらちゃんと動いた!
と思ったらまたエラー\(^o^)/

app: Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-1vvm78yl/cryptography/
The SSH command responded with a non-zero exit status. Vagrant
assumes that this means the command failed. The output for this command
should be in the log above. Please read the output to determine what
went wrong.
TocyukiTocyuki

Vagrantfile内でAnsibleのインストールを以下のように修正したらうまくいった
という感じで今まで通りansible2.9でやってく感じにしますか

config.vm.provision "shell", inline: <<-SHELL
    sudo yum -y update
    sudo amazon-linux-extras install ansible2
  SHELL
このスクラップは3日前にクローズされました