Version information
This version is compatible with:
- , , , , , ,
Start using this module
Add this module to your Puppetfile:
mod 'tPl0ch-composer', '1.3.7'
Learn more about managing modules with a PuppetfileDocumentation
Composer Puppet Module
Description
The puppet-composer
module installs the latest version of Composer from http://getcomposer.org. Composer is a dependency manager for PHP.
Supported Puppet versions
This module supports puppet in versions >= 2.7, <3.5
Supported Platforms
Debian
Ubuntu
Redhat
Centos
Amazon Linux
FreeBSD
Installation
Puppet Forge
We recommend installing using the Puppet Forge as it automatically satisfies dependencies.
puppet module install --target-dir=/your/path/to/modules tPl0ch-composer
Installation via git submodule
You can also install as a git submodule and handle the dependencies manually. See the Dependencies section below.
git submodule add git://github.com/tPl0ch/puppet-composer.git modules/composer
Dependencies
This module requires the following Puppet modules:
And additional (for puppet version lower than 3.0.0) you need:
libaugeas
(For automatically updating php.ini settings for suhosin patch)hiera-puppet
(For managing config data)
Usage
To install the composer
binary globally in /usr/local/bin
you only need to declare the composer
class. We try to set some sane defaults. There are also a number of parameters you can tweak should the defaults not be sufficient.
Simple Include
To install the binary with the defaults you just need to include the following in your manifests:
include composer
Full Include
Alternatively, you can set a number of options by declaring the class with parameters:
class { 'composer':
target_dir => '/usr/local/bin',
composer_file => 'composer', # could also be 'composer.phar'
download_method => 'curl', # or 'wget'
logoutput => false,
tmp_path => '/tmp',
php_package => 'php5-cli',
curl_package => 'curl',
wget_package => 'wget',
composer_home => '/root',
php_bin => 'php', # could also i.e. be 'php -d "apc.enable_cli=0"' for more fine grained control
suhosin_enabled => true,
auto_update => false, # Set to true to automatically update composer to the latest version
github_token => '1234567890abcdefgh',
user => 'app',
}
Creating Projects
The composer::project
definition provides a way to create projects in a target directory.
composer::project { 'silex':
project_name => 'fabpot/silex-skeleton', # REQUIRED
target_dir => '/vagrant/silex', # REQUIRED
version => '2.1.x-dev', # Some valid version string
prefer_source => true,
stability => 'dev', # Minimum stability setting
keep_vcs => false, # Keep the VCS information
dev => true, # Install dev dependencies
repository_url => 'http://repo.example.com', # Custom repository URL
user => undef, # Set the user to run as
}
Updating Packages
The composer::exec
definition provides a more generic wrapper arround composer update
and install
commands. The following example will update the silex/silex
and symfony/browser-kit
packages in the /vagrant/silex
directory. You can omit packages
to update the entire project.
composer::exec { 'silex-update':
cmd => 'update', # REQUIRED
cwd => '/vagrant/silex', # REQUIRED
packages => ['silex/silex', 'symfony/browser-kit'], # leave empty or omit to update whole project
prefer_source => false, # Only one of prefer_source or prefer_dist can be true
prefer_dist => false, # Only one of prefer_source or prefer_dist can be true
dry_run => false, # Just simulate actions
custom_installers => false, # No custom installers
scripts => false, # No script execution
interaction => false, # No interactive questions
optimize => false, # Optimize autoloader
dev => true, # Install dev dependencies
timeout => undef, # Set a timeout for the exec type
user => undef, # Set the user to run as
refreshonly => false, # Only run on refresh
}
Installing Packages
We support the install
command in addition to update
. The install command will ignore the packages
parameter and the following example is the equivalent to running composer install
in the /vagrant/silex
directory.
composer::exec { 'silex-install':
cmd => 'install', # REQUIRED
cwd => '/vagrant/silex', # REQUIRED
prefer_source => false,
prefer_dist => false,
dry_run => false, # Just simulate actions
custom_installers => false, # No custom installers
scripts => false, # No script execution
interaction => false, # No interactive questions
optimize => false, # Optimize autoloader
dev => true, # Install dev dependencies
onlyif => undef, # If true
unless => undef, # If true
}
Updating composer
You can use the defined type composer::selfupdate
to update (or rollback) composer to the latest (or specific) version.
composer::selfupdate { 'selfupdate_composer':
version => undef, # Leave undef for latest version, otherwise specify commit hash here
rollback => false, # Set to true to rollback to a specified version (version MUST be given)
clean_backups => false, # Set to true to clean backups
user => undef, # If the command should be run as a user
logoutput => false, # If the command's output should be written to the logs
timeout => 300, # Timeout for this command
tries => 3, # Retries for this command
}
Development
For unit testing we use rspec-puppet
and Travis CI. Functional testing happens through a Vagrant VM where you can test changes in a real server scenario.
Unit Tests
When contributing fixes or features you should try and create RSpec tests for those changes. It is always a good idea to make sure the entire suite passes before opening a pull request. To run the RSpec tests locally you need bundler
installed:
gem install bundler
Then you can install the required gems:
bundle install
Finally, the tests can be run:
rake spec
Functional Tests
For easier development and actual testing the use of the module, we rely on Vagrant, which allows us to bring up a VM that we can use to test changes and perform active development without needing a real server.
To get started with the Vagrant VM you should first get the Unit Tests working. Then you will need to install VirtualBox and Vagrant.
To bring up the development VM you can run rake vagrant:up
. This Rake task runs rake spec_prep
as a pre-requisite so that the git
Puppet module is available. With the VM up and running you can login via SSH with vagrant ssh
and run puppet apply
against it with rake vagrant:provision
.
The VM will get the spec/fixtures/manifests/vagrant.pp
file applied to the node. This currently creates a Silex project at /tmp/silex
when the VM starts up. You can modify this manifest to your liking.
Acceptance Tests
Acceptance tests are written using Beaker.
To run the beaker tests via rake, you can simply run rake beaker
.
To use something other than the default beaker node, try the following:
BEAKER_set=ubuntu-server-1404-x64 rake beaker
To use beaker without rake, simply run rspec spec/acceptance
.
Beaker + Hiera
When running acceptance tests, you may hit GitHub rate limits much faster than you would otherwise. To ensure your tests do not fail arbitrarily, you can add your GitHub auth token via hiera.
Create a hiera config at spec/fixtures/puppet/common.yaml
, that looks like this:
composer::github_token: 'my_github_auth_token'
Happy testing!
Contributing
We welcome everyone to help develop this module. To contribute:
- Fork this repository
- Add features and spec tests for them
- Commit to feature named branch
- Open a pull request outlining your changes and the reasoning for them
Todo
- Add a
composer::require
type
v1.2.1
f44b7e5 Now also supports Amazon Linux (RedHat)
9341805 Now suhosin_enabled
parameter is correctly documented.
v1.2.0
66b071a (HEAD, tag: 1.2.0, master) Bumping version to 1.2.0
166ec87 Updated README.md
626ee43 (origin/master, origin/HEAD) Updated CHANGELOG format
1364058 Moved CHANGELOG to markdown format
6f21dcb Updated LICENSE file
6209eb8 Added CHANGELOG file
6307d5a Add parameter 'php_bin' to override name or path of php binary
9e484e9 (origin/rspec_head_fixes, rspec_head_fixes) just match on errorname, not specific exception
db4176e update specs for latest rspec-puppet 1.0.1+
v1.1.1
17b2309 (tag: 1.1.1) Update Modulefile
d848038 Used puppetlabs/git >= 0.0.2
0d75cff doc updates for 1.1.0 release
v1.1.0
3b46e4d (tag: 1.1.0) bumping version to 1.1.0 for refreshonly and user features
5290e8e support setting exec user for project and exec
6af1e25 ignore puppet module package folder
c2106ec Add refreshonly parameter to exec
v1.0.1
fb1fd04 (tag: 1.0.1) Bumped version to 1.0.1
bf43913 (origin/deprecated_erb_variables) fix deprecated variables in the exec erb template
342b898 (origin/documentation_refactor) document refactor, add spec test information
3677acc adding tests for new suhosin_enable param and Debian family
de86c0d Only run augeas commands if suhosin is enabled
v1.0.0
f5d214a (tag: 1.0.0) Bumping version to 1.0.0
12589bf fixes for travis-ci building
5279b92 spec testing using rspec-puppet
3069608 documentation updates for composer_home and previous PRs
b5faa45 add a composer_home fact and use it to set up environment
v0.1.1
dbc0c74 Bumping version to 0.1.1
b4833d6 no-custom-installers is deprecated in favor of no-plugins
acdc73c dry up the composer binary download code
41f3a7b CentOS isn't actually an $::osfamily value
d54c0db PHP binary is provided by php-cli on RHEL systems
v0.1.0
1e8f9f1 (tag: 0.1.0) Adding License file.
523c28f (igalic/option-names, igalic-option-names) update readme with the new options
3d2ddda double-negating option names is confusing
be518cf (igalic/style, igalic-style) Fix puppet lint complaints
4050077 There's no need for these files to be executable
522e93c Updated temp path.
bf0f9e7 Support centos/redhat
f45e9de Support redhat/centos
920d1ca Support redhat/centos
v0.0.6
78643ef (tag: 0.0.6) Bumping version to 0.0.6
0fbfb53 Fixing bug where global path is overwritten by local scope.
v0.0.5
ee4e49b (tag: 0.0.5) Bumping version to 0.0.5
17ca5ee Added varaible composer path to exec calls.
v0.0.4
e94be5e (tag: 0.0.4) Bumping version to 0.0.4
a27e45f Fixed dry_run parameter
28cfee8 Adding version parameter to project task README
v0.0.3
4787b24 Bumping version to 0.0.3
4ee9547 (tag: 0.0.3) Fixing type in exec manifest.
v0.0.2
974d2ad (tag: 0.0.2) Bumping version to 0.0.2
667eb18 Fixed README
925aa97 Fixed Modulefile.
Dependencies
- puppetlabs/git (>= 0.0.2)
- puppetlabs/stdlib (>=3.0.0)
The MIT License (MIT) Copyright (c) 2013 - 2014 Thomas Ploch Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.