Forge Home

composer

This module installs Composer, a dependency manager for PHP.

971,886 downloads

12,311 latest version

4.6 quality score

We run a couple of automated
scans to help you access a
module's quality. Each module is
given a score based on how well
the author has formatted their
code and documentation and
modules are also checked for
malware using VirusTotal.

Please note, the information below
is for guidance only and neither of
these methods should be considered
an endorsement by Puppet.

Version information

  • 1.2.10 (latest)
  • 1.2.9
  • 1.2.8
  • 1.2.7
  • 1.2.6
  • 1.2.5
  • 1.2.4
  • 1.2.3
  • 1.2.2
  • 1.2.1
  • 1.2.0
  • 1.1.1
  • 1.1.0
  • 1.0.0
  • 0.0.7
  • 0.0.6
  • 0.0.5
  • 0.0.4
released Jun 6th 2021
This version is compatible with:
  • Puppet Enterprise 2019.8.x, 2019.7.x, 2019.5.x, 2019.4.x, 2019.3.x, 2019.2.x, 2019.1.x, 2019.0.x, 2018.1.x, 2017.3.x, 2017.2.x, 2017.1.x, 2016.5.x, 2016.4.x
  • Puppet >=4.0 <7.0.0
  • , , , FreeBSD

Start using this module

  • r10k or Code Manager
  • Bolt
  • Manual installation
  • Direct download

Add this module to your Puppetfile:

mod 'willdurand-composer', '1.2.10'
Learn more about managing modules with a Puppetfile

Add this module to your Bolt project:

bolt module add willdurand-composer
Learn more about using this module with an existing project

Manually install this module globally with Puppet module tool:

puppet module install willdurand-composer --version 1.2.10

Direct download is not typically how you would use a Puppet module to manage your infrastructure, but you may want to download the module in order to inspect the code.

Download
Tags: php, composer

Documentation

willdurand/composer — version 1.2.10 Jun 6th 2021

puppet-composer

Build Status

This module installs Composer, a dependency manager for PHP.

Installation

Using the Puppet Module Tool, install the willdurand/composer by running the following command:

puppet module install willdurand/composer

Otherwise, clone this repository and make sure to install the proper dependencies (puppetlabs-stdlib, puppetlabs-cron_core):

git clone git://github.com/willdurand/puppet-composer.git modules/composer

puppet-wget module

The puppet-wget module is required until version 1.1.x, but dropped in version 1.2.x. For further notes about this module, please have a look at the 1.1 docs.

In 1.2 the puppetlabs-stdlib dependency has been added in order to gain lots of puppet features located in this module and improve the type validation in the manifests.

Installing dependencies locally

In order to avoid messing up your global gem installation and installing the ruby dependencies during the dev phase, it's possible to install the dependencies in a local path which is ignored by .gitignore by default:

bundle install --path vendor/bundle

Usage

Install composer through puppet

Include the composer class:

include composer

You can specify the command name you want to get, and the target directory (aka where to install Composer):

class { '::composer':
  command_name => 'composer',
  target_dir   => '/usr/local/bin'
}

You can also auto update composer by using the auto_update parameter. This will update Composer only when you will run Puppet.

class { '::composer':
  auto_update => true
}

You can specify a particular user that will be the owner of the Composer executable:

class { '::composer':
  user => 'foo',
}

As the user is configurable, the group is changeable, too:

class { '::composer':
  group => 'owner_group_name',
}

It is also possible to specify a custom composer version:

class { '::composer':
  version => '1.0.0-alpha11',
}

When having an infrastructure with slower connections, it is possible to increase the timeout in order to avoid running into errors because of a slow connection:

class { '::composer':
  download_timeout => '100',
}

Repairing duplicated packages

As described in #44 in several cases it's possible that the catalogue crashes because of duplicate package declarations.

In order to skip the installation of wget from this module, you can use the build_deps argument:

class { '::composer':
  build_deps => false,
}

Global composer configs

One feature of composer are global configuration parameters. There are some important parameters like oauth_token for the GitHub API that should be configured through composer.

::composer::config { 'composer-vagrant-config':
  ensure  => present,
  user    => 'vagrant',
  configs => {
    'github-oauth' => {
      'github.com' => 'token'
    },
    'process-timeout' => 500,
    'http-basic' => {
      'github.com' => ['username', 'password']
    },
  },
}

And removing single params is also possible:

::composer::config { 'remove-platform':
  ensure  => absent,
  configs => ['process-timeout', 'github-oauth.github.com', 'http-basic.github.com'],
  user    => 'vagrant',
}

Note that the config items must be structured like when using the CLI. This means that when having a gitlab-oauth entry for site gitlab.org then the following key should be removed:

gitlab-oauth.gitlab.org

Furthermore it is possible to configure the home_dir parameter as some users might use another one:

::composer::config { 'composer-vagrant-config':
  ensure   => present,
  user     => 'vagrant',
  home_dir => '/custom/home/dir',
}

Clear cache

The composer dependency resolver is quite complex and there are issues where the cache hides actual conflicts that make reproduction of such issues a lot harder. In order to keep the cache clean, it is possible to clear the cache via puppet:

::composer::clear_cache { 'clear-cache-for-user':
  exec_user => 'user',
}

As the home directory is configurable, it is possible to adjust the homedir to this resource:

::composer::clear_cache { 'clear-cache-for-user':
  home_dir => '/custom/home/dir',
  exec_user     => 'user',
}

Handle dependency order

Since this module does only handler the composer installation, but doesn't care about the php setup, you might run into errors due to a missing php instance. This can be fixed by using the require parameter:

class { '::composer':
  require => Package['php5'],
}

This will puppet tell to wait with the composer install process until the php package is installed.

Running the tests

Install the dependencies using Bundler:

bundle install

Run the following command:

bundle exec rake spec

Development with nix

If you're using nix as dependency manager, you can create a custom shell which contains all dependencies declared in Gemfile.lock by running nix-shell in the root directory.

License

puppet-composer is released under the MIT License. See the bundled LICENSE file for details.