Solved: Installing composer V1 with Ansible

November 12th, 2020

Warning: This post is 3 years old. Some of this information may be out of date.

Composer 2 was released a few weeks back but one of the projects I'm working with won't install the dependencies as it has a check for Composer v1. We use Vagrant and ansible to provision dev environments and this is now failing on a brand new vagrant up.

To fix this I had to modify the Ansible playbook to force installation of composer v1:

    # Install composer
    - name: Download composer
      get_url:
        url: https://getcomposer.org/installer
        dest: /tmp/composer-installer

    - name: Install composer
      command: php /tmp/composer-installer --1 --install-dir=/usr/local/bin/ --filename=composer
      args:
        creates: /usr/local/bin/composer

Note the --1 in the 'Install Composer' command.