Upgrade php from 5.4.* to 5.5.*

This commit is contained in:
Benoît Burnichon
2015-03-17 10:09:07 +01:00
parent e32816a8e0
commit 7ad443a88b
2027 changed files with 72 additions and 88 deletions

View File

@@ -0,0 +1,5 @@
fixtures:
repositories:
git: "git://github.com/puppetlabs/puppetlabs-git"
symlinks:
composer: "#{source_dir}"

View File

@@ -0,0 +1,13 @@
language: ruby
rvm:
- 1.9.3
before_script:
after_script:
script: "bundle exec rake spec"
env:
- PUPPET_VERSION=2.7.23
- PUPPET_VERSION=3.0.2
- PUPPET_VERSION=3.2.4
- PUPPET_VERSION=3.3.0
notifications:
email: false

View File

@@ -0,0 +1,133 @@
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.

View File

@@ -0,0 +1,17 @@
#ruby=1.9.3@puppet-composer
if ENV.key?('PUPPET_VERSION')
puppetversion = "= #{ENV['PUPPET_VERSION']}"
else
puppetversion = ['>= 2.7']
end
source 'https://rubygems.org'
ruby '1.9.3'
gem 'puppet', puppetversion
gem 'puppetlabs_spec_helper'
gem 'rspec-puppet', :github => 'rodjek/rspec-puppet', :ref => '03e94422fb9bbdd950d5a0bec6ead5d76e06616b'
gem 'mocha'
gem 'puppet-lint'

View File

@@ -0,0 +1,21 @@
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.

View File

@@ -0,0 +1,8 @@
name 'tPl0ch-composer'
version '1.2.1'
dependency 'puppetlabs/git', '>= 0.0.2'
summary "This module provides the 'Composer' PHP dependency manager."
description "This module installs the 'Composer' PHP dependency manager and provides some custom types to create, update
and install projects. Until now the Debian and Redhat OS families are supported."
project_page "https://github.com/tPl0ch/puppet-composer"
author "tPl0ch - Thomas Ploch <profiploch@gmail.com>"

View File

@@ -0,0 +1,155 @@
# Composer Puppet Module
[![Build Status](https://travis-ci.org/tPl0ch/puppet-composer.png?branch=master)](https://travis-ci.org/tPl0ch/puppet-composer)
## Description
The `puppet-composer` module installs the latest version of Composer from http://getcomposer.org. Composer is a dependency manager for PHP.
## Supported Platforms
* `Debian`
* `Redhat`
* `Centos`
* `Amazon Linux`
## 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](#dependencies) section below.
git submodule add git://github.com/tPl0ch/puppet-composer.git modules/composer
## Dependencies
This module requires the following Puppet modules:
* [`puppetlabs-git`](https://github.com/puppetlabs/puppetlabs-git/)
And additional (for puppet version lower than 3.0.0) you need:
* [`libaugeas`](http://augeas.net/) (For automatically updating php.ini settings for suhosin patch)
## 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:
```puppet
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,
}
```
### Creating Projects
The `composer::project` definition provides a way to create projects in a target directory.
```puppet
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.
```puppet
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 => false, # Install dev dependencies
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.
```puppet
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 => false, # Install dev dependencies
}
```
## Development
We have `rspec-puppet` and Travis CI setup for the project. To run the spec 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
```
## 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

View File

@@ -0,0 +1,2 @@
require 'puppet-lint/tasks/puppet-lint'
require 'puppetlabs_spec_helper/rake_tasks'

View File

@@ -0,0 +1,5 @@
Facter.add(:composer_home) do
setcode do
ENV['HOME']
end
end

View File

@@ -0,0 +1,55 @@
# == Type: composer::exec
#
# Either installs from composer.json or updates project or specific packages
#
# === Authors
#
# Thomas Ploch <profiploch@gmail.com>
#
# === Copyright
#
# Copyright 2013 Thomas Ploch
#
define composer::exec (
$cmd,
$cwd,
$packages = [],
$prefer_source = false,
$prefer_dist = false,
$dry_run = false,
$custom_installers = false,
$scripts = false,
$optimize = false,
$interaction = false,
$dev = false,
$logoutput = false,
$verbose = false,
$refreshonly = false,
$user = undef,
) {
require composer
require git
Exec {
path => "/bin:/usr/bin/:/sbin:/usr/sbin:${composer::target_dir}",
environment => "COMPOSER_HOME=${composer::composer_home}",
user => $user,
}
if $cmd != 'install' and $cmd != 'update' {
fail("Only types 'install' and 'update' are allowed, ${cmd} given")
}
if $prefer_source and $prefer_dist {
fail('Only one of \$prefer_source or \$prefer_dist can be true.')
}
$command = "${composer::php_bin} ${composer::target_dir}/${composer::composer_file} ${cmd}"
exec { "composer_update_${title}":
command => template('composer/exec.erb'),
cwd => $cwd,
logoutput => $logoutput,
refreshonly => $refreshonly
}
}

View File

@@ -0,0 +1,156 @@
# == Class: composer
#
# The parameters for the composer class and corresponding definitions
#
# === Parameters
#
# Document parameters here.
#
# [*target_dir*]
# The target dir that composer should be installed to.
# Defaults to ```/usr/local/bin```.
#
# [*composer_file*]
# The name of the composer binary, which will reside in ```target_dir```.
#
# [*download_method*]
# Either ```curl``` or ```wget```.
#
# [*logoutput*]
# If the output should be logged. Defaults to FALSE.
#
# [*tmp_path*]
# Where the composer.phar file should be temporarily put.
#
# [*php_package*]
# The Package name of tht PHP CLI package.
#
# [*curl_package*]
# The name of the curl package to override the default set in the
# composer::params class.
#
# [*wget_package*]
# The name of the wget package to override the default set in the
# composer::params class.
#
# [*composer_home*]
# Folder to use as the COMPOSER_HOME environment variable. Default comes
# from our composer::params class which derives from our own $composer_home
# fact. The fact returns the current users $HOME environment variable.
#
# [*php_bin*]
# The name or path of the php binary to override the default set in the
# composer::params class.
#
# === Authors
#
# Thomas Ploch <profiploch@gmail.com>
#
class composer(
$target_dir = $composer::params::target_dir,
$composer_file = $composer::params::composer_file,
$download_method = $composer::params::download_method,
$logoutput = $composer::params::logoutput,
$tmp_path = $composer::params::tmp_path,
$php_package = $composer::params::php_package,
$curl_package = $composer::params::curl_package,
$wget_package = $composer::params::wget_package,
$composer_home = $composer::params::composer_home,
$php_bin = $composer::params::php_bin,
$suhosin_enabled = $composer::params::suhosin_enabled
) inherits composer::params {
Exec { path => "/bin:/usr/bin/:/sbin:/usr/sbin:${target_dir}" }
if defined(Package[$php_package]) == false {
package { $php_package: ensure => present, }
}
# download composer
case $download_method {
'curl': {
$download_command = "curl -s http://getcomposer.org/installer | ${composer::php_bin}"
$download_require = $suhosin_enabled ? {
true => [ Package['curl', $php_package], Augeas['allow_url_fopen', 'whitelist_phar'] ],
false => [ Package['curl', $php_package] ]
}
$method_package = $curl_package
}
'wget': {
$download_command = 'wget http://getcomposer.org/composer.phar -O composer.phar'
$download_require = $suhosin_enabled ? {
true => [ Package['wget', $php_package], Augeas['allow_url_fopen', 'whitelist_phar'] ],
false => [ Package['wget', $php_package] ]
}
$method_package = $wget_package
}
default: {
fail("The param download_method ${download_method} is not valid. Please set download_method to curl or wget.")
}
}
if defined(Package[$method_package]) == false {
package { $method_package: ensure => present, }
}
exec { 'download_composer':
command => $download_command,
cwd => $tmp_path,
require => $download_require,
creates => "${tmp_path}/composer.phar",
logoutput => $logoutput,
}
# check if directory exists
file { $target_dir:
ensure => directory,
}
# move file to target_dir
file { "${target_dir}/${composer_file}":
ensure => present,
source => "${tmp_path}/composer.phar",
require => [ Exec['download_composer'], File[$target_dir] ],
mode => 0755,
}
if $suhosin_enabled {
case $family {
'Redhat','Centos': {
# set /etc/php5/cli/php.ini/suhosin.executor.include.whitelist = phar
augeas { 'whitelist_phar':
context => '/files/etc/suhosin.ini/suhosin',
changes => 'set suhosin.executor.include.whitelist phar',
require => Package[$php_package],
}
# set /etc/cli/php.ini/PHP/allow_url_fopen = On
augeas{ 'allow_url_fopen':
context => '/files/etc/php.ini/PHP',
changes => 'set allow_url_fopen On',
require => Package[$php_package],
}
}
'Debian': {
# set /etc/php5/cli/php.ini/suhosin.executor.include.whitelist = phar
augeas { 'whitelist_phar':
context => '/files/etc/php5/conf.d/suhosin.ini/suhosin',
changes => 'set suhosin.executor.include.whitelist phar',
require => Package[$php_package],
}
# set /etc/php5/cli/php.ini/PHP/allow_url_fopen = On
augeas{ 'allow_url_fopen':
context => '/files/etc/php5/cli/php.ini/PHP',
changes => 'set allow_url_fopen On',
require => Package[$php_package],
}
}
}
}
}

View File

@@ -0,0 +1,53 @@
# == Class: composer::params
#
# The parameters for the composer class and corresponding definitions
#
# === Authors
#
# Thomas Ploch <profiploch@gmail.com>
# Andrew Johnstone <andrew@ajohnstone.com>
#
# === Copyright
#
# Copyright 2013 Thomas Ploch
#
class composer::params {
$composer_home = $::composer_home
# Support Amazon Linux which is supported by RedHat family
if $::osfamily == 'Linux' and $::operatingsystem == 'Amazon' {
$family = 'RedHat'
} else {
$family = $::osfamily
}
case $family {
'Debian': {
$target_dir = '/usr/local/bin'
$composer_file = 'composer'
$download_method = 'curl'
$logoutput = false
$tmp_path = '/tmp'
$php_package = 'php5-cli'
$curl_package = 'curl'
$wget_package = 'wget'
$php_bin = 'php'
$suhosin_enabled = true
}
'RedHat', 'Centos': {
$target_dir = '/usr/local/bin'
$composer_file = 'composer'
$download_method = 'curl'
$logoutput = false
$tmp_path = '/tmp'
$php_package = 'php-cli'
$curl_package = 'curl'
$wget_package = 'wget'
$php_bin = 'php'
$suhosin_enabled = true
}
default: {
fail("Unsupported platform: ${family}")
}
}
}

View File

@@ -0,0 +1,96 @@
# == Type: composer::project
#
# Installs a given project with composer create-project
#
# === Parameters
#
# Document parameters here.
#
# [*target_dir*]
# The target dir that composer should be installed to.
# Defaults to ```/usr/local/bin```.
#
# [*composer_file*]
# The name of the composer binary, which will reside in ```target_dir```.
#
# [*download_method*]
# Either ```curl``` or ```wget```.
#
# [*logoutput*]
# If the output should be logged. Defaults to FALSE.
#
# [*tmp_path*]
# Where the composer.phar file should be temporarily put.
#
# [*php_package*]
# The Package name of the PHP CLI package.
#
# [*user*]
# The user name to exec the composer commands as. Default is undefined.
#
# === Authors
#
# Thomas Ploch <profiploch@gmail.com>
#
# === Copyright
#
# Copyright 2013 Thomas Ploch
#
define composer::project(
$project_name,
$target_dir,
$version = undef,
$dev = false,
$prefer_source = false,
$stability = 'dev',
$repository_url = undef,
$keep_vcs = false,
$tries = 3,
$timeout = 1200,
$user = undef,
) {
require git
require composer
Exec {
path => "/bin:/usr/bin/:/sbin:/usr/sbin:${composer::target_dir}",
environment => "COMPOSER_HOME=${composer::composer_home}",
user => $user,
}
$exec_name = "composer_create_project_${title}"
$base_command = "${composer::php_bin} ${composer::target_dir}/${composer::composer_file} --stability=${stability}"
$end_command = "${project_name} ${target_dir}"
$dev_arg = $dev ? {
true => ' --dev',
default => '',
}
$vcs = $keep_vcs? {
true => ' --keep-vcs',
default => '',
}
$repo = $repository_url? {
undef => '',
default => " --repository-url=${repository_url}",
}
$pref_src = $prefer_source? {
true => ' --prefer-source',
false => ''
}
$v = $version? {
undef => '',
default => " ${version}",
}
exec { $exec_name:
command => "${base_command}${dev_arg}${repo}${pref_src}${vcs} create-project ${end_command}${v}",
tries => $tries,
timeout => $timeout,
creates => $target_dir,
}
}

View File

@@ -0,0 +1,14 @@
require 'spec_helper'
describe 'composer::params' do
['RedHat', 'Debian', 'Linux'].each do |osfamily|
context "on #{osfamily} operating system family" do
let(:facts) { {
:osfamily => osfamily,
:operatingsystem => 'Amazon',
} }
it { should compile }
end
end
end

View File

@@ -0,0 +1,116 @@
require 'spec_helper'
describe 'composer' do
['RedHat', 'Debian', 'Linux'].each do |osfamily|
case osfamily
when 'RedHat'
php_package = 'php-cli'
php_context = '/files/etc/php.ini/PHP'
suhosin_context = '/files/etc/suhosin.ini/suhosin'
when 'Linux'
php_package = 'php-cli'
php_context = '/files/etc/php.ini/PHP'
suhosin_context = '/files/etc/suhosin.ini/suhosin'
when 'Debian'
php_package = 'php5-cli'
php_context = '/files/etc/php5/cli/php.ini/PHP'
suhosin_context = '/files/etc/php5/conf.d/suhosin.ini/suhosin'
else
php_package = 'php-cli'
php_context = '/files/etc/php.ini/PHP'
suhosin_context = '/files/etc/suhosin.ini/suhosin'
end
context "on #{osfamily} operating system family" do
let(:facts) { {
:osfamily => osfamily,
:operatingsystem => 'Amazon'
} }
it { should contain_class('composer::params') }
it {
should contain_exec('download_composer').with({
:command => 'curl -s http://getcomposer.org/installer | php',
:cwd => '/tmp',
:creates => '/tmp/composer.phar',
:logoutput => false,
})
}
it {
should contain_augeas('whitelist_phar').with({
:context => suhosin_context,
:changes => 'set suhosin.executor.include.whitelist phar',
})
}
it {
should contain_augeas('allow_url_fopen').with({
:context => php_context,
:changes => 'set allow_url_fopen On',
})
}
context 'with default parameters' do
it 'should compile' do
compile
end
it { should contain_package(php_package).with_ensure('present') }
it { should contain_package('curl').with_ensure('present') }
it { should contain_file('/usr/local/bin').with_ensure('directory') }
it {
should contain_file('/usr/local/bin/composer').with({
:source => 'present',
:source => '/tmp/composer.phar',
:mode => '0755',
})
}
end
context "on invalid operating system family" do
let(:facts) { {
:osfamily => 'Invalid',
:operatingsystem => 'Amazon'
} }
it 'should not compile' do
expect { should compile }.to raise_error(/Unsupported platform: Invalid/)
end
end
context 'with custom parameters' do
let(:params) { {
:target_dir => '/you_sir/lowcal/been',
:php_package => 'php8-cli',
:composer_file => 'compozah',
:curl_package => 'kerl',
:php_bin => 'pehpe',
:suhosin_enabled => false,
} }
it 'should compile' do
compile
end
it { should contain_package('php8-cli').with_ensure('present') }
it { should contain_package('kerl').with_ensure('present') }
it { should contain_file('/you_sir/lowcal/been').with_ensure('directory') }
it {
should contain_file('/you_sir/lowcal/been/compozah').with({
:source => 'present',
:source => '/tmp/composer.phar',
:mode => '0755',
})
}
it { should_not contain_augeas('whitelist_phar') }
it { should_not contain_augeas('allow_url_fopen') }
end
end
end
end

View File

@@ -0,0 +1,65 @@
require 'spec_helper'
describe 'composer::exec' do
['RedHat', 'Debian'].each do |osfamily|
context "on #{osfamily} operating system family" do
let(:facts) { {
:osfamily => osfamily,
} }
context 'using install command' do
it { should contain_class('git') }
it { should contain_class('composer') }
let(:title) { 'myproject' }
let(:params) { {
:cmd => 'install',
:cwd => '/my/awesome/project',
:user => 'linus',
} }
it {
should contain_exec('composer_update_myproject').with({
:command => %r{php /usr/local/bin/composer install --no-plugins --no-scripts --no-interaction},
:cwd => '/my/awesome/project',
:user => 'linus',
:logoutput => false,
})
}
end
context 'using update command' do
it { should contain_class('git') }
it { should contain_class('composer') }
let(:title) { 'yourpr0ject' }
let(:params) { {
:cmd => 'update',
:cwd => '/just/in/time',
:packages => ['package1', 'packageinf'],
:logoutput => true,
} }
it {
should contain_exec('composer_update_yourpr0ject').without_user.with({
:command => %r{php /usr/local/bin/composer update --no-plugins --no-scripts --no-interaction package1 packageinf},
:cwd => '/just/in/time',
:logoutput => true,
})
}
end
end
end
context 'on unsupported operating system family' do
let(:facts) { {
:osfamily => 'Darwin',
} }
let(:title) { 'someproject' }
it 'should not compile' do
expect { should compile }.to raise_error(/Unsupported platform: Darwin/)
end
end
end

View File

@@ -0,0 +1,61 @@
require 'spec_helper'
describe 'composer::project' do
['RedHat', 'Debian'].each do |osfamily|
context "on #{osfamily} operating system family" do
let(:facts) { {
:osfamily => osfamily,
} }
context 'with default params' do
let(:title) { 'myproject' }
let(:params) { {
:project_name => 'projectzzz',
:target_dir => '/my/subpar/project',
} }
it { should contain_class('git') }
it { should contain_class('composer') }
it {
should contain_exec('composer_create_project_myproject').without_user.with({
:command => "php /usr/local/bin/composer --stability=dev create-project projectzzz /my/subpar/project",
:tries => 3,
:timeout => 1200,
:creates => '/my/subpar/project',
})
}
end
context 'with all custom params' do
let(:title) { 'whoadawg' }
let(:params) { {
:project_name => 'whoadawg99',
:target_dir => '/my/mediocre/project',
:version => '0.0.8',
:dev => true,
:prefer_source => true,
:stability => 'dev',
:repository_url => 'git@github.com:trollface/whoadawg.git',
:keep_vcs => true,
:tries => 2,
:timeout => 600,
:user => 'mrploch',
} }
it { should contain_class('git') }
it { should contain_class('composer') }
it {
should contain_exec('composer_create_project_whoadawg').with({
:command => %r{php /usr/local/bin/composer --stability=dev --dev --repository-url=git@github.com:trollface/whoadawg.git --prefer-source --keep-vcs create-project whoadawg99 /my/mediocre/project 0.0.8},
:tries => 2,
:timeout => 600,
:creates => '/my/mediocre/project',
:user => 'mrploch',
})
}
end
end
end
end

View File

@@ -0,0 +1,8 @@
node default {
include composer
composer::exec {'ohai':
cmd => 'install',
cwd => '/some/cool/dir',
}
}

View File

@@ -0,0 +1,6 @@
--format
s
--colour
--loadby
mtime
--backtrace

View File

@@ -0,0 +1 @@
require 'puppetlabs_spec_helper/module_spec_helper'

View File

@@ -0,0 +1,17 @@
<%= @command -%>
<% if @prefer_source %> --prefer-source<% end -%>
<% if @prefer_dist %> --prefer-dist<% end -%>
<% unless @custom_installers %> --no-plugins<% end -%>
<% unless @scripts %> --no-scripts<% end -%>
<% unless @interaction %> --no-interaction<% end -%>
<% if @dev %> --dev<% end -%>
<% if @verbose %> -v<% end -%>
<% if @dry_run %> --dry-run<% end -%>
<% if @cmd == 'update' -%>
<%- if @packages -%>
<%- @packages.each do |package| -%>
<%= ' ' + package -%>
<%- end -%>
<%- end -%>
<% end -%>

View File

@@ -0,0 +1,11 @@
# The baseline for module testing used by Puppet Labs is that each manifest
# should have a corresponding test manifest that declares that class or defined
# type.
#
# Tests are then run by using puppet apply --noop (to check for compilation errors
# and view a log of events) or by fully applying the test in a virtual environment
# (to compare the resulting system state to the desired state).
#
# Learn more about module testing here: http://docs.puppetlabs.com/guides/tests_smoke.html
#
include composer

View File

@@ -0,0 +1,23 @@
# The baseline for module testing used by Puppet Labs is that each manifest
# should have a corresponding test manifest that declares that class or defined
# type.
#
# Tests are then run by using puppet apply --noop (to check for compilation errors
# and view a log of events) or by fully applying the test in a virtual environment
# (to compare the resulting system state to the desired state).
#
# Learn more about module testing here: http://docs.puppetlabs.com/guides/tests_smoke.html
#
composer::project { 'my_first_test':
project_name => 'fabpot/silex-skeleton',
target_dir => '/tmp/first_test',
}
composer::project { 'my_second_test':
project_name => 'fabpot/silex-skeleton',
target_dir => '/tmp/second_test',
prefer_source => true,
stability => 'dev',
}