Showing with 196 additions and 146 deletions.
  1. +20 −0 .editorconfig
  2. +1 −0 .fixtures.yml
  3. +7 −7 .gitignore
  4. +12 −10 .travis.yml
  5. +1 −0 Gemfile
  6. +0 −11 Modulefile
  7. +3 −1 README.md
  8. +0 −24 lib/facter/pip_version.rb
  9. +0 −32 lib/facter/python_version.rb
  10. +0 −24 lib/facter/virtualenv_version.rb
  11. +7 −1 manifests/init.pp
  12. +18 −4 manifests/install.pp
  13. +4 −2 manifests/params.pp
  14. +1 −1 manifests/pip.pp
  15. +10 −17 manifests/virtualenv.pp
  16. +19 −10 metadata.json
  17. +92 −2 spec/classes/python_spec.rb
  18. +1 −0 spec/spec_helper_acceptance.rb
20 changes: 20 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# editorconfig.org

root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 4
tab_width = 4
indent_style = tab
insert_final_newline = true
trim_trailing_whitespace = true

[*.txt]
trim_trailing_whitespace = false

[*.{md,json,yml}]
trim_trailing_whitespace = false
indent_style = space
indent_size = 2
1 change: 1 addition & 0 deletions .fixtures.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
fixtures:
repositories:
"stdlib": "git://github.com/puppetlabs/puppetlabs-stdlib.git"
"epel": "git://github.com/stahnma/puppet-module-epel.git"
symlinks:
"python": "#{source_dir}"
14 changes: 7 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,6 @@ project.properties
sftp-config.json
.idea

# OS X metadata
.DS_Store

# Windows junk
Thumbs.db

# Modules
pkg/
Gemfile.lock
Expand All @@ -26,4 +20,10 @@ coverage/
# Beaker
.vagrant/
log/
junit/
junit/

# OS X metadata
.DS_Store

# Windows junk
Thumbs.db
22 changes: 12 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
---
language: ruby
bundler_args: --without system_tests
script: "bundle exec rake validate && bundle exec rake lint && bundle exec rake spec SPEC_OPTS='--format documentation'"
script: "bundle exec metadata-json-lint metadata.json && bundle exec rake validate && bundle exec rake lint && bundle exec rake spec SPEC_OPTS='--format documentation'"
rvm:
- 1.9.3
- 2.0.0
matrix:
fast_finish: true
include:
- rvm: 1.8.7
env: PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.6.0"
- rvm: 1.8.7
env: PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.7.0"
- rvm: 1.9.3
env: PUPPET_GEM_VERSION="~> 3.0"
exclude:
- rvm: 2.0.0
env: PUPPET_VERSION="~> 2.7.0"
- rvm: 2.0.0
env: PUPPET_GEM_VERSION="~> 3.0"
env: PUPPET_VERSION="~> 3.1.0"
- rvm: 1.9.3
env: PUPPET_VERSION="~> 2.7.0"

sudo: false
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
source ENV['GEM_SOURCE'] || "https://rubygems.org"

group :development, :test do
gem 'metadata-json-lint', :require => false
gem 'rake', :require => false
gem 'rspec-puppet', :require => false
gem 'puppetlabs_spec_helper', :require => false
Expand Down
11 changes: 0 additions & 11 deletions Modulefile

This file was deleted.

4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ Installs and manages python, python-pip, python-dev, python-virtualenv and Gunic

**manage_gunicorn** - Allow Installation / Removal of Gunicorn. Default: true

**use_epel** - Boolean to determine if the epel class is used. Default: true

```puppet
class { 'python' :
version => 'system',
Expand Down Expand Up @@ -278,4 +280,4 @@ python::python_pips:
## Authors
[Sergey Stankevich](https://github.com/stankevich) | [Shiva Poudel](https://github.com/shivapoudel)
[Sergey Stankevich](https://github.com/stankevich) | [Shiva Poudel](https://github.com/shivapoudel) | [Garrett Honeycutt](http://learnpuppet.com)
24 changes: 0 additions & 24 deletions lib/facter/pip_version.rb
Original file line number Diff line number Diff line change
@@ -1,33 +1,9 @@
# Make pip version available as a fact
# Works with pip loaded and without, pip installed using pip and package installed

facter_puppet_version = Facter.value(:puppetversion)
facter_is_pe = Facter.value(:is_pe)

if facter_is_pe
facter_puppet_version = facter_puppet_version.to_s.split(' ')[0]
end

if (Puppet::Util::Package.versioncmp(facter_puppet_version, '3.6') >= 0)
pkg = Puppet::Type.type(:package).new(:name => 'python-pip', :allow_virtual => 'false')
else
pkg = Puppet::Type.type(:package).new(:name => 'python-pip')
end

Facter.add("pip_version") do
has_weight 100
setcode do
if Facter::Util::Resolution.which('pip')
Facter::Util::Resolution.exec('pip --version 2>&1').match(/^pip (\d+\.\d+\.?\d*).*$/)[1]
end
end
end

Facter.add("pip_version") do
has_weight 50
setcode do
unless [:absent,:purged].include?(pkg.retrieve[pkg.property(:ensure)])
pkg.retrieve[pkg.property(:ensure)]
end
end
end
32 changes: 0 additions & 32 deletions lib/facter/python_version.rb
Original file line number Diff line number Diff line change
@@ -1,41 +1,9 @@
# Make python versions available as facts
# In lists default python and system python versions

facter_puppet_version = Facter.value(:puppetversion)
facter_is_pe = Facter.value(:is_pe)

if facter_is_pe
facter_puppet_version = facter_puppet_version.to_s.split(' ')[0]
end

if (Puppet::Util::Package.versioncmp(facter_puppet_version, '3.6') >= 0)
pkg = Puppet::Type.type(:package).new(:name => 'python-pip', :allow_virtual => 'false')
else
pkg = Puppet::Type.type(:package).new(:name => 'python-pip')
end

Facter.add("system_python_version") do
setcode do
unless [:absent,:purged].include?(pkg.retrieve[pkg.property(:ensure)])
pkg.retrieve[pkg.property(:ensure)]
end
end
end

Facter.add("python_version") do
has_weight 100
setcode do
if Facter::Util::Resolution.which('python')
Facter::Util::Resolution.exec('python -V 2>&1').match(/^.*(\d+\.\d+\.\d+)$/)[1]
end
end
end

Facter.add("python_version") do
has_weight 50
setcode do
unless [:absent,:purged].include?(pkg.retrieve[pkg.property(:ensure)])
pkg.retrieve[pkg.property(:ensure)]
end
end
end
24 changes: 0 additions & 24 deletions lib/facter/virtualenv_version.rb
Original file line number Diff line number Diff line change
@@ -1,33 +1,9 @@
# Make virtualenv version available as a fact
# Works with virualenv loaded and without, pip installed and package installed

facter_puppet_version = Facter.value(:puppetversion)
facter_is_pe = Facter.value(:is_pe)

if facter_is_pe
facter_puppet_version = facter_puppet_version.to_s.split(' ')[0]
end

if (Puppet::Util::Package.versioncmp(facter_puppet_version, '3.6') >= 0)
pkg = Puppet::Type.type(:package).new(:name => 'python-pip', :allow_virtual => 'false')
else
pkg = Puppet::Type.type(:package).new(:name => 'python-pip')
end

Facter.add("virtualenv_version") do
has_weight 100
setcode do
if Facter::Util::Resolution.which('virtualenv')
Facter::Util::Resolution.exec('virtualenv --version 2>&1').match(/^(\d+\.\d+\.?\d*).*$/)[0]
end
end
end

Facter.add("virtualenv_version") do
has_weight 50
setcode do
unless [:absent,:purged].include?(pkg.retrieve[pkg.property(:ensure)])
pkg.retrieve[pkg.property(:ensure)]
end
end
end
8 changes: 7 additions & 1 deletion manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
# Default: system default provider
# Allowed values: 'pip'
#
# [*use_epel*]
# Boolean to determine if the epel class is used. Default: true
#
# === Examples
#
# class { 'python':
Expand All @@ -50,6 +53,7 @@
# === Authors
#
# Sergey Stankevich
# Garrett Honeycutt <code@garretthoneycutt.com>
#
class python (
$version = $python::params::version,
Expand All @@ -63,6 +67,7 @@
$python_pips = { },
$python_virtualenvs = { },
$python_pyvenvs = { },
$use_epel = $python::params::use_epel,
) inherits python::params{

# validate inputs
Expand All @@ -82,9 +87,10 @@
validate_bool($virtualenv)
validate_bool($gunicorn)
validate_bool($manage_gunicorn)
validate_bool($use_epel)

# Module compatibility check
$compatible = [ 'Debian', 'RedHat']
$compatible = [ 'Debian', 'RedHat', 'Suse' ]
if ! ($::osfamily in $compatible) {
fail("Module is not compatible with ${::operatingsystem}")
}
Expand Down
22 changes: 18 additions & 4 deletions manifests/install.pp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# == Define: python::install
# == Class: python::install
#
# Installs core python packages
#
Expand All @@ -11,8 +11,8 @@
# Sergey Stankevich
# Ashley Penney
# Fotis Gimian
# Garrett Honeycutt <code@garretthoneycutt.com>
#

class python::install {

$python = $::python::version ? {
Expand All @@ -23,7 +23,8 @@

$pythondev = $::osfamily ? {
'RedHat' => "${python}-devel",
'Debian' => "${python}-dev"
'Debian' => "${python}-dev",
'Suse' => "${python}-devel",
}

# pip version: use only for installation via os package manager!
Expand Down Expand Up @@ -56,6 +57,20 @@
package { "python==${python::version}": ensure => latest, provider => pip }
}
default: {
if $::osfamily == 'RedHat' {
if $pip_ensure == present {
if $python::use_epel == true {
include 'epel'
Class['epel'] -> Package[$pip]
}
}
if ($venv_ensure == present) and ($::operatingsystemrelease =~ /^6/) {
if $python::use_epel == true {
include 'epel'
Class['epel'] -> Package['python-virtualenv']
}
}
}
package { 'python-virtualenv': ensure => $venv_ensure }
package { $pip: ensure => $pip_ensure }
package { $pythondev: ensure => $dev_ensure }
Expand All @@ -70,5 +85,4 @@
}
package { 'gunicorn': ensure => $gunicorn_ensure }
}

}
6 changes: 4 additions & 2 deletions manifests/params.pp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

# Class: python::params
# == Class: python::params
#
# The python Module default configuration settings.
#
class python::params {
Expand All @@ -13,5 +13,7 @@
$valid_versions = $::osfamily ? {
'RedHat' => ['3'],
'Debian' => ['3', '3.3'],
'Suse' => [],
}
$use_epel = true
}
2 changes: 1 addition & 1 deletion manifests/pip.pp
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@
if $source =~ /^(git\+|hg\+|bzr\+|svn\+)(http|https|ssh|svn|sftp|ftp|lp)(:\/\/).+$/ {
if $ensure != present and $ensure != latest {
exec { "pip_install_${name}":
command => "${pip_env} wheel --help > /dev/null 2>&1 && { ${pip_env} wheel --version > /dev/null 2>&1 || wheel_support_flag='--no-use-wheel'; } ; { ${pip_env} --log ${log}/pip.log install ${install_args} \$wheel_support_flag ${proxy_flag} ${install_args} ${install_editable} ${source}@${ensure} || ${pip_env} --log ${log}/pip.log install ${install_args} ${proxy_flag} ${install_args} ${install_editable} ${source}@${ensure} ;}",
command => "${pip_env} wheel --help > /dev/null 2>&1 && { ${pip_env} wheel --version > /dev/null 2>&1 || wheel_support_flag='--no-use-wheel'; } ; { ${pip_env} --log ${log}/pip.log install ${install_args} \$wheel_support_flag ${proxy_flag} ${install_args} ${install_editable} ${source}@${ensure}#egg=${egg_name} || ${pip_env} --log ${log}/pip.log install ${install_args} ${proxy_flag} ${install_args} ${install_editable} ${source}@${ensure}#egg=${egg_name} ;}",
unless => "${pip_env} freeze | grep -i -e ${grep_regex}",
user => $owner,
cwd => $cwd,
Expand Down
Loading