[Solved] Installing composer V1 with Ansible

Image for [Solved] Installing composer V1 with Ansible from unsplash.com

By Andrew McCombe
November 12, 2020


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.