Forge Home

filefetcher

A module to download, chown and chmod files.

23,745 downloads

22,505 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.

Support the Puppet Community by contributing to this module

You are welcome to contribute to this module by suggesting new features, currency updates, or fixes. Every contribution is valuable to help ensure that the module remains compatible with the latest Puppet versions and continues to meet community needs. Complete the following steps:

  1. Review the module’s contribution guidelines and any licenses. Ensure that your planned contribution aligns with the author’s standards and any legal requirements.
  2. Fork the repository on GitHub, make changes on a branch of your fork, and submit a pull request. The pull request must clearly document your proposed change.

For questions about updating the module, contact the module’s author.

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 Feb 4th 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.6'
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.6

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.6 Feb 4th 2015

filefetcher Puppet Module

Table of Contents

  1. Overview
  2. Module Description
  3. Setup
  4. Usage
  5. Reference
  6. Limitations
  7. Development
  8. Inspiration

Overview

This module aims to simplify the three actions wget + chown + chmod. It helps you to download the files from the net and set appropriate the owner and access rights.

Genesis

I prepared it for PHP Phars, like:

  • composer.phar
  • phpunit.phar
  • box.phar
  • php-cs-fixer.phar
  • symfony.phar

But filefetcher is a general tool to perform wget/chown/chmod.

If you are interested in PHARS, please refer to a more specialized puppet-php_phars module.

Module Description

In general:

  • the module downloads a file to an arbitrary directory
  • sets the owner
  • sets the rights

It can be seen as a sequence of three:

  • 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 a given name (e.g. composer) in an 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/filefetcher
cd /etc/puppet/modules/filefetcher
git clone --depth 1 https://github.com/puppet-by-examples/puppet-filefetcher.git .

To lock the version, use:

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

Usage

The examples are stored under examples/ directory.

Symfony Homepage

# Filename: examples/symfony-homepage.pp
filefetcher::fetch { 'Symfony Homepage':
    filename   => 'symfony-homepage',
    target_dir => '/tmp',
    user       => 'vagrant',
    rights     => '644',
    url        => 'http://symfony.com',
    redownload => true,
}

To run it use the following command:

sudo puppet apply examples/symfony-standard-composer-json.pp

Reference

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

Limitations

The module was tested on:

  • Ubuntu
    • 12.04 / Puppet 3.7
    • 14.04 / Puppet 3.7
  • CentOS
    • 6.5 / Puppet 3.7

Development

The best method I have found so far to work on Puppet modules is:

  • keep all modules in a single directory of your host (host/some/dir)
  • create a Vagrant env in the dir that contains all the modules
    .
    ├── puppet-filefetcher
    │   ├── examples
    │   ├── Gemfile
    │   ├── LICENSE
    │   ├── manifests
    │   ├── metadata.json
    │   ├── pkg
    │   ├── Rakefile
    │   ├── README.md
    │   ├── spec
    │   ├── tests
    │   └── tmp
    ├── puppet-php_phars
    │   ├── examples
    │   ├── Gemfile
    │   ├── LICENSE
    │   ├── manifests
    │   ├── metadata.json
    │   ├── Rakefile
    │   ├── README.md
    │   ├── spec
    │   └── tests
    └── Vagrantfile

Then create symbolic links to modules:

sudo ln -s /vagrant/puppet-filefetcher /etc/puppet/modules/filefetcher

Working this way you can test the module without:

  • building
  • installing
  • uploading to the Puppet Forge

The command to check CS:

puppet-lint manifests --no-autoloader_layout-check

The commands to build a module:

rm -rf pkg/
puppet module build

sudo puppet module list
sudo puppet module install gajdaw-filefetcher
sudo puppet module install pkg/gajdaw-filefetcher-0.1.2.tar.gz
sudo puppet module uninstall gajdaw-filefetcher

All the examples:

sudo puppet apply examples/symfony-homepage.pp

Inspiration

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