shaneholloman.composer

Ansible Role: composer

CI

This role installs Composer, the tool for managing PHP dependencies, on any Linux or UNIX system.

Requirements

  • You need to have php (version 5.4 or newer) installed. You can use the shaneholloman.php role to install it.
  • git must also be installed. You can use the shaneholloman.git role for this.

Role Variables

Here are the available variables and their default settings (check defaults/main.yml for details):

composer_path: /usr/local/bin/composer

This sets where Composer will be installed on your system. It should be in your user’s $PATH, which allows you to run it using just composer instead of the full path.

composer_keep_updated: false

Set this to true to update Composer to the latest version every time you run the playbook.

composer_home_path: '~/.composer'
composer_home_owner: root
composer_home_group: root

This is the directory where global packages are installed. It defines the COMPOSER_HOME path and who owns the directory.

composer_version: ''

You can specify a certain version of Composer to install, like composer_version: '1.0.0-alpha11'. If you leave it empty, it will install the latest version. The composer_keep_updated option will take precedence here.

composer_version_branch: '--2'

This lets you choose which major version of Composer to use. The default is --2. The composer_keep_updated option will keep this branch up to date.

composer_global_packages: []

List of packages to install globally. To add a package, include it as - { name: phpunit/phpunit, release: "4.7.*" }. The 'release' is optional and defaults to @stable.

composer_add_to_path: true

If this is true and you have global packages installed, the vendor/bin directory in composer_home_path will be added to the system’s default $PATH.

composer_project_path: /path/to/project

This is the path to a specific Composer project.

composer_add_project_to_path: false

If set to true and you have a composer_project_path set, the vendor/bin directory in composer_project_path will be added to the system's default $PATH.

composer_github_oauth_token: ''

This is your GitHub OAuth token. It helps avoid hitting GitHub API rate limits when using Composer. You can create a token by following GitHub’s instructions on Creating a personal access token.

php_executable: php

This is the name or full path to your PHP executable. It defaults to php unless you change it.

Staying on Composer 1

If you need to use Composer 1 while upgrading projects to support Composer 2, set these variables:

composer_version_branch: ''
composer_version: '1.10.12'

Dependencies

There are no required dependencies, but you should install PHP first (using the shaneholloman.php role is recommended).

Example Playbook

- hosts: servers
  roles:
    - shaneholloman.composer

After running the playbook, composer will be installed in /usr/local/bin/composer (this location can be changed) and will be available to use normally.

License

Unlicense

Author Information

This role was created in 2023.

Informazioni sul progetto

Composer PHP Dependency Manager

Installa
ansible-galaxy install shaneholloman.composer
Licenza
unlicense
Download
6.1k
Proprietario