Version information
This version is compatible with:
- Puppet 3.x
- , ,
Start using this module
Add this module to your Puppetfile:
mod 'gajdaw-filefetcher', '0.1.6'
Learn more about managing modules with a PuppetfileDocumentation
filefetcher
Puppet Module
Table of Contents
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:
wget
to download filesmaestrodev-wget
puppet module https://github.com/maestrodev/puppet-wget- when missing,
wget
is automatically installed bymaestrodev-wget
module
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.
Dependencies
- maestrodev/wget (>=1.2.0)
Copyright (c) 2015 Włodzimierz Gajda 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.