ansibleをインストール後、下記のplaybookを実行すれば、phpとcomposerを纏めてインストールできます。
動作テストは、vagrant上のubuntu-trusty-64にて行っています。
#!/usr/bin/env ansible-playbook
- name: install php and composer
become: True
tasks:
- name: install php5
apt: name=php5 update_cache=yes
- name: get composer
get_url: url=https://getcomposer.org/installer dest=/tmp/composer-setup.php
- name: install composer
shell: chdir=/tmp php composer-setup.php
- name: move composer.phar
shell: mv /tmp/composer.phar /bin/composer
上記の例ではphpのインストールをubuntuインストール時のデフォルトバージョンを取得しています。PHP7を入れたいなどバージョン指定する場合は、playbookを分けた方が管理しやすいです。
こちらもおススメ
- name: install composer
shell: chdir=/tmp php composer-setup.php --install-dir=/bin --filename=composer
上記のようにすると
- name: move composer.phar 以下は要らない。