弊社が AWS MarketPlace で提供している WordPress 実行用環境 AMIMOTO で PHP 7.1 が使用できるようになりました。
AMIMOTO AMI (HVM/PVM) で PHP7.1 を使う方法
こんな感じの yml とシェルスクリプト使えば、まるっと既存のインスタンス群を PHP 7.1 にアップデートできると思います。
php-update.yml
---
- hosts: all
become: yes
gather_facts: no
tasks:
- name: test connection (before update)
ping:
- name: "php-update"
script: ./php-update.sh
- name: reboot!
command: shutdown -r now
php-update.sh
#!/bin/bash
set -eux
instance_type=$(curl -s http://169.254.169.254/latest/meta-data/instance-type/ | sed -e 's/^[^\.]*\.//g')
amimoto_json='/opt/local/amimoto.json'
# monit stop
/sbin/service monit stop
if [ "${instance_type}" = "micro" ]; then
/sbin/service nginx stop && /sbin/service php-fpm stop && /sbin/service mysql stop
fi
# middleware update
/usr/bin/jq -s '.[1] * .[0]' <(echo '{"phpfpm":{"enabled":true, "version":"71"}}') ${amimoto_json} > /tmp/amimoto.json \
&& /bin/mv -f /tmp/amimoto.json ${amimoto_json}
/usr/bin/git -C /opt/local/chef-repo/cookbooks/amimoto/ pull origin 2016.01
/opt/chef/bin/chef-solo -c /opt/local/solo.rb -j ${amimoto_json} -l error
/usr/bin/yum update -y
実行は、こんな感じで。
ansible-playbook php-update.yml -i ./hosts