Version information
This version is compatible with:
- Puppet Enterprise 3.2.x
- Puppet 3.x
- , , ,
Start using this module
Add this module to your Puppetfile:
mod 'daenney-pyenv', '0.9.2'
Learn more about managing modules with a PuppetfileDocumentation
pyenv
Pyenv provides a way to build and use Pythons outside of your platforms package manager's purview.
Table of contents
- Overview - What is the pyenv module?
- Module description - What is the purpose of this mdoule?
- Setup - The basics of getting started with pyenv
- Usage - The classes and types available for configuration
Overview
The pyenv module allows you to install pyenv on a target system. The module
also provides a Puppet type called pyenv_python
which will instruct pyenv
to build a Python for you.
This module only supports global installations of pyenv, meaning it will not install into a user's home directory. Though it can be made to do so the types that come with it do not support this work flow.
Module description
Python is a often-used programming language ranging from simple scripts to automate a repetitive task to powering large (web) applications. The problem we often encounter is that a distribution only ships with one (outdated) Python version. Pyenv remedies this situation by allow you to build your own Pythons and use those instead.
Setup
This modules will:
- Install pyenv for you. It will do so by checking out the latest tag at the time this module was written;
- Symlink pyenv so that it will be found when looking through
$PATH
; - Install the necessary packages to ensure you can build Python;
- A type and provider to make Puppet build Pythons through pyenv.
This module requires:
Beginning with pyenv
In order to install pyenv with the defaults:
include ::pyenv
This will install pyenv for you in /usr/local/pyenv
and symlink
/usr/local/bin/pyenv
to /usr/local/pyenv/bin/pyenv
.
Installing a Python
Use the pyenv_python
type to instruct Puppet to build a Python:
pyenv_python { '3.4.0': }
The pyenv_python
defaults to ensure => present,
, therefor you do not need to
specify it yourself.
If you want to build a debug version of a Python add -debug to the name of the Python:
pyenv_python { '3.4.0-debug': }
Relocation the pyenv installation
The module installs pyenv to /usr/local/pyenv
by default and symlinks the
pyenv
binary onto your path. This is needed so that the provider can find
pyenv
and set up the PYENV_ROOT
environment variable accordingly.
If you change the location of the pyenv checkout you must either:
- Make sure the symlink is changed too. This is done automatically if you
set
symlink_pyenv
to true; - Create a custom Fact called
pyenv_binary
with the location of/path/to/checkout/bin/pyenv
.
The former of the two methods is preferred if at all possible.
If Puppet's $PATH
does not by default include /usr/local/bin
either add
that to it or change the symlink_path
to a different location that is part of
Puppet's $PATH
.
Usage
Classes and defined types
Class: pyenv
The pyenv module's primary and only class, pyenv
sets up your system with pyenv
and the necessary packages to compile.
It takes the following parameters:
ensure_repo
: Whether to add or remove the repository- default:
present
- options:
present
,absent
- default:
repo_location
: Where to checkout the repository on the filesystem- default:
/usr/local/pyenv
- options: any absolute path
- default:
repo_revision
: The revision to checkout- default:
v0.4.0-20140404
- options: tag, commit SHA, branch
- default:
symlink_pyenv
: Create a symlink to the pyenv binary- default:
true
- options:
true
,false
- default:
symlink_path
: Where to symlink pyenv to- default:
/usr/local/bin
- options: any absolute path known to
$PATH
- default:
manage_packages
: Install packages needed to compile Python- default:
true
- options:
true
,false
- default:
ensure_packages
: State of the packages to ensure- default:
latest
- options: any valid value for the ensure attribute of the package type
- default:
python_build_packages
: Array/list of packages to install- default: depends on what Facter returns for
osfamily
, see (params.pp)[params.pp] - options: an array of strings representing package names
- default: depends on what Facter returns for
Types
Type: pyenv_python
pyenv_python
allows you to build a Python which in turn will make it
available to someone wishing to use it.
It takes the following options:
name
(namevar): name of the Python to be installed, seepyenv install -l
. If omitted the title of the resource will be used.ensure
: state the Python should be in- default:
present
- options: valid values for ensure
- default:
keep
: keep the sources after compiling- default:
false
- options:
true
,false
- default:
virtualenv
: Install virtualenv in the new Python- default:
false
- options:
true
,false
- default:
Keep one thing in mind: if a Python was installed without setting keep
to
true
you cannot add it later, the provider will call the fail()
method in
such cases.
Types in this module release
Dependencies
- puppetlabs/stdlib (>= 3.2.1)
- puppetlabs/vcsrepo (>= 0.2.0)
Copyright 2014 Daniele Sluijters Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.