Note
This module is part of the community.general collection (version 10.7.3).
You might already have this collection installed if you are using the ansible package. It is not included in ansible-core. To check whether it is installed, run ansible-galaxy collection list.
To install it, use: ansible-galaxy collection install community.general. You need further requirements to be able to use this module, see Requirements for details.
To use it in a playbook, specify: community.general.composer.
The below requirements are needed on the host that executes this module.
/usr/local/bin) or specified in composer_executable
Parameter | Comments |
|---|---|
apcu_autoloader boolean | Uses APCu to cache found/not-found classes. Choices:
|
arguments string | Composer arguments like required package, version and so on. Default: |
classmap_authoritative boolean | Autoload classes from classmap only. Implicitly enable optimize_autoloader. Recommended especially for production, but can take a bit of time to run. Choices:
|
command string | Composer command like Default: |
composer_executable path added in community.general 3.2.0 | Path to composer executable on the remote host, if composer is not in |
executable aliases: php_path path | Path to PHP executable on the remote host, if PHP is not in |
global_command boolean | Runs the specified command globally. Choices:
|
ignore_platform_reqs boolean | Ignore php, hhvm, lib-* and ext-* requirements and force the installation even if the local machine does not fulfill these. Choices:
|
no_dev boolean | Disables installation of require-dev packages (see Choices:
|
no_plugins boolean | Disables all plugins (see Choices:
|
no_scripts boolean | Skips the execution of all scripts defined in composer.json (see Choices:
|
optimize_autoloader boolean | Optimize autoloader during autoloader dump (see Convert PSR-0/4 autoloading to classmap to get a faster autoloader. Recommended especially for production, but can take a bit of time to run. Choices:
|
prefer_dist boolean | Forces installation from package dist even for dev versions (see Choices:
|
prefer_source boolean | Forces installation from package sources when possible (see Choices:
|
working_dir path | Directory of your project (see This is ignored if |
Attribute | Support | Description |
|---|---|---|
check_mode | Support: full | Can run in |
diff_mode | Support: none | Will return details on what has changed (or possibly needs changing in |
Note
--no-ansi, --no-interaction and --no-progress if available.- name: Download and installs all libs and dependencies outlined in the /path/to/project/composer.lock
community.general.composer:
command: install
working_dir: /path/to/project
- name: Install a new package
community.general.composer:
command: require
arguments: my/package
working_dir: /path/to/project
- name: Clone and install a project with all dependencies
community.general.composer:
command: create-project
arguments: package/package /path/to/project ~1.0
working_dir: /path/to/project
prefer_dist: true
- name: Install a package globally
community.general.composer:
command: require
global_command: true
arguments: my/package
© 2012–2018 Michael DeHaan
© 2018–2025 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/latest/collections/community/general/composer_module.html