---
- name: Add Composer PPA
  apt_repository: repo="ppa:duggan/composer" update_cache=yes

- name: Install Composer
  apt: name=php5-composer state=present force=yes

- name: Composer self update
  command: composer self-update
  register: composer_update_result
  changed_when: composer_update_result.rc == 0 and 'already using composer version' not in composer_update_result.stderr

---
- name: Add Composer PPA
  apt_repository: repo="ppa:duggan/composer" update_cache=yes

- name: Install Composer
  apt: name=php5-composer state=present force=yes

- name: Composer self update
  command: composer self-update
  register: composer_update_result
  changed_when: composer_update_result.rc == 0 and 'already using composer version' not in composer_update_result.stderr

- name: add Composer vendor binary path
  lineinfile:
    dest: /etc/environment
    regexp: ^PATH="(((?!:./vendor/bin).)*)"
    line: PATH="\1:./vendor/bin"
    backrefs: yes

Add composer binary path to the default path.
Add composer binary path to the default path.

Update the regex to capture the full path.
