Forge Home

filefetcher

A module to download and install one-file-applications (like phpunit, composer, php-cs-fixer, box).

23,587 downloads

22,416 latest version

3.1 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

  • 0.1.6 (latest)
  • 0.1.5
  • 0.1.4
  • 0.1.3
  • 0.1.2
  • 0.1.1
  • 0.1.0
released Jan 6th 2015
This version is compatible with:
  • Puppet 3.x

Start using this module

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

Add this module to your Puppetfile:

mod 'gajdaw-filefetcher', '0.1.0'
Learn more about managing modules with a Puppetfile

Add this module to your Bolt project:

bolt module add gajdaw-filefetcher
Learn more about using this module with an existing project

Manually install this module globally with Puppet module tool:

puppet module install gajdaw-filefetcher --version 0.1.0

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

Documentation

gajdaw/filefetcher — version 0.1.0 Jan 6th 2015

filefetcher Puppet Module

Table of Contents

  1. Overview
  2. Module Description
  3. Setup
  4. Usage
  5. Reference
  6. Limitations
  7. Development
  8. Release notes
  9. To do
  10. Inspiration

Overview

This module aims to simplify the installation of applications that consist of a single file.

I prepared it and tested having PHP Phars in mind, like:

  • phpunit
  • composer
  • box
  • php-cs-fixer

Module Description

Currently, there are no binary distributions for many php command line applications, like composer, phpunit, etc. Thus, you cannot install them using package managers, like APT, for example:

# These won't work
#
$ sudo apt-get install composer
$ sudo apt-get install phpunit

The filefetcher module aims to make installation of one-file-applications easier.

In general:

  • the module downloads a file
  • sets the owner
  • sets the rights

It can be seen as a sequence of:

  • wget
  • chown
  • chmod

commands.

Setup

What filefetcher affects

Module:

  • downloads a file using URL parameter (e.g. https://getcomposer.org/composer.phar)
  • saves it under given name (e.g. composer) in arbitrary directory (e.g. /usr/local/bin)
  • sets the owner (e.g. root)
  • sets the rights (e.g. a+x)

Setup Requirements

The module uses:

Beginning with filefetcher

System wide install with Puppet

To install the module in your system run:

sudo puppet module install gajdaw-filefetcher

You may lock the version to avoid using the latest version:

sudo puppet module install gajdaw-filefetcher --version 0.1.0

System wide install with Git

You may also use git to install the module:

mkdir -p /etc/puppet/modules/box
cd /etc/puppet/modules/box
git clone --depth 1 https://github.com/pro-vagrant/puppet-filefetcher.git .

To lock the version, use:

git clone --depth 1 --branch v0.1.0 https://github.com/pro-vagrant/puppet-filefetcher.git .

Usage

The examples are stored under examples directory.

Composer

Here is composer.pp example:

# Filename: examples/composer.pp
filefetcher::fetch { 'composer':
    source => 'https://getcomposer.org/composer.phar',
}

To run it use the following command:

sudo puppet apply examples/composer.pp

Phpunit

Here is phpunit.pp example:

# Filename: examples/phpunit.pp
filefetcher::fetch { 'phpunit':
    source => 'https://phar.phpunit.de/phpunit.phar',
}

To run it use the following command:

sudo puppet apply examples/phpunit.pp

Php-cs-fixer

Here is php-cs-fixer.pp example:

# Filename: examples/php-cs-fixer.pp
filefetcher::fetch { 'php-cs-fixer':
    source => 'http://cs.sensiolabs.org/get/php-cs-fixer.phar',
}

To run it use the following command:

sudo puppet apply examples/php-cs-fixer.pp

Box

Here is box.pp example:

# Filename: examples/box.pp
filefetcher::fetch { 'box':
    source => 'https://github.com/box-project/box2/releases/download/2.5.0/box-2.5.0.phar',
}

To run it use the following command:

sudo puppet apply examples/box.pp

Running binaries

If php is missing, install it with:

sudo apt-get install php5 -y

Now, you can use the binaries:

phpunit --version
composer --version
php-cs-fixer --version
box --version

Uninstall

Currently, to uninstall binaries, you have to use rm command:

sudo rm /usr/local/bin/composer
sudo rm /usr/local/bin/phpunit
sudo rm /usr/local/bin/php-cs-fixer
sudo rm /usr/local/bin/box

Reference

The complete list of parameters is available in manifests/fetch.pp file.

Limitations

The box was tested on:

  • Ubuntu 14.04 / Puppet 3.7

Development

When I work on this module I find the following commands indispensable:

cd some/dir/with/source/code/for/the/module

sudo puppet module list
puppet module build .
puppet-lint manifests --no-autoloader_layout-check
sudo puppet module install pkg/gajdaw-filefetcher-0.1.0.tar.gz
sudo puppet module uninstall gajdaw-filefetcher

sudo puppet apply examples/phpunit.pp
sudo puppet apply examples/composer.pp
sudo puppet apply examples/php-cs-fixer.pp
sudo puppet apply examples/box.pp
sudo puppet apply examples/symfony-standard-composer-json.pp

sudo puppet apply examples/php-common-phars.pp

Using them I don't have to upload the module to the Puppet Forge just to verify if it is working or not.

Release Notes

0.1.0

  • initial release
  • works fine with four attached examples

To do

  • using array of hashes as in examples/php-common-phars.pp
  • tests

Inspiration

The inspiration came from willdurrand-composer authored by William Durand.