Takes a Composer-based Git repository branch, updates it, and then pushes to the same (or another) branch.
This Ansible role does the following:
- Clones the Git repository to a temporary directory.
- Switches to a different branch (if necessary).
- Runs Composer's update command.
- Commits
composer.lock
. - Pushes the commit to the specified (or same) branch.
The below requirements are needed on the host that executes this module.
- PHP
- Composer installed in bin path (recommended
/usr/local/bin
) - Git version >= 1.7.1 (the command line tool)
See defaults/main.yml.
None.
- Currently, this role always clones to a new temporary directory. It might make sense to use reuse an existing clone, but then things get more complicated as the working tree could be dirty. So additional work would be required to check for and handle that. As usual, merge requests are welcome.
- hosts: dev.example.com
roles:
- consensus.composer-update
vars:
composer_update_git_url: "[email protected]:example/myproject.git"
composer_update_git_clone_branch: "master"
composer_update_git_push_branch: "dev"
composer_update_packages: "foo/bar foo/baz"
Tests can be run like so (with more or fewer "v"s for verbosity):
ansible-playbook -vv --inventory TARGET_HOSTNAME, /path/to/this/role/tests/TEST_NAME.yml
Feel free to add your own tests in tests/
, using existing ones as examples. Contributions welcome.
For bugs, feature requests, etc., please visit the issue tracker.
Written by Colan Schwartz and other folks at Consensus Enterprises. To contact us, please use our Web contact form.