Showing with 245 additions and 108 deletions.
  1. +16 −73 .travis.yml
  2. +9 −4 Gemfile
  3. +15 −6 README.md
  4. +7 −1 Rakefile
  5. +33 −0 lib/facter/python_release.rb
  6. +31 −6 manifests/gunicorn.pp
  7. +7 −4 manifests/init.pp
  8. +10 −5 manifests/install.pp
  9. +9 −3 manifests/virtualenv.pp
  10. +5 −3 metadata.json
  11. +2 −0 spec/classes/python_spec.rb
  12. +3 −3 spec/defines/pip_spec.rb
  13. +98 −0 spec/unit/facter/python_release_spec.rb
89 changes: 16 additions & 73 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,90 +11,33 @@ before_install:
- gem --version
- bundle -v

rvm:
- 1.8.7
- 1.9.3
- 2.0.0
- 2.1.0
- 2.3.1

env:
matrix:
- PUPPET_GEM_VERSION="~> 3.1.0"
- PUPPET_GEM_VERSION="~> 3.2.0"
- PUPPET_GEM_VERSION="~> 3.3.0"
- PUPPET_GEM_VERSION="~> 3.4.0"
- PUPPET_GEM_VERSION="~> 3.5.0"
- PUPPET_GEM_VERSION="~> 3.6.0"
- PUPPET_GEM_VERSION="~> 3.7.0"
- PUPPET_GEM_VERSION="~> 3.8.0"
- PUPPET_GEM_VERSION="~> 3" FUTURE_PARSER="yes"
- PUPPET_GEM_VERSION="~> 4.0.0"
- PUPPET_GEM_VERSION="~> 4.1.0"
- PUPPET_GEM_VERSION="~> 4.2.0"
- PUPPET_GEM_VERSION="~> 4.3.0"
- PUPPET_GEM_VERSION="~> 4.4.0"
- PUPPET_GEM_VERSION="~> 4.5.0"
- PUPPET_GEM_VERSION="~> 4.6.0"
- PUPPET_GEM_VERSION="~> 4.7.0"
- PUPPET_GEM_VERSION="~> 4.8.0"
- PUPPET_GEM_VERSION="~> 4"

sudo: false

script: 'SPEC_OPTS="--format documentation" bundle exec rake validate lint spec'

matrix:
fast_finish: true
exclude:
- rvm: 2.0.0
env: PUPPET_GEM_VERSION="~> 3.1.0"
- rvm: 2.1.0
env: PUPPET_GEM_VERSION="~> 3.1.0"
- rvm: 2.1.0
env: PUPPET_GEM_VERSION="~> 3.2.0"
- rvm: 2.1.0
env: PUPPET_GEM_VERSION="~> 3.3.0"
- rvm: 2.1.0
env: PUPPET_GEM_VERSION="~> 3.4.0"
- rvm: 1.8.7
env: PUPPET_GEM_VERSION="~> 4.0.0"
- rvm: 1.8.7
env: PUPPET_GEM_VERSION="~> 4.1.0"
- rvm: 1.8.7
env: PUPPET_GEM_VERSION="~> 4.2.0"
- rvm: 1.8.7
env: PUPPET_GEM_VERSION="~> 4.3.0"
- rvm: 1.8.7
env: PUPPET_GEM_VERSION="~> 4.4.0"
- rvm: 1.8.7
env: PUPPET_GEM_VERSION="~> 4.5.0"
include:
- rvm: 1.8.7
env: PUPPET_GEM_VERSION="~> 3" FUTURE_PARSER="yes"
- rvm: 1.9.3
env: PUPPET_GEM_VERSION="~> 3" FUTURE_PARSER="yes"
- rvm: 2.0.0
env: PUPPET_GEM_VERSION="~> 3" FUTURE_PARSER="yes"
- rvm: 2.1.9
env: PUPPET_GEM_VERSION="~> 3" FUTURE_PARSER="yes"
- rvm: 2.1.9
env: PUPPET_GEM_VERSION="~> 4.6.0"
- rvm: 1.8.7
- rvm: 2.1.9
env: PUPPET_GEM_VERSION="~> 4.7.0"
- rvm: 1.8.7
- rvm: 2.1.9
env: PUPPET_GEM_VERSION="~> 4.8.0"
- rvm: 1.8.7
- rvm: 2.1.9
env: PUPPET_GEM_VERSION="~> 4.9.0"
- rvm: 2.1.9
env: PUPPET_GEM_VERSION="~> 4.10.0"
- rvm: 2.1.9
env: PUPPET_GEM_VERSION="~> 4"
- rvm: 2.3.1
env: PUPPET_GEM_VERSION="~> 3.1.0"
- rvm: 2.3.1
env: PUPPET_GEM_VERSION="~> 3.2.0"
- rvm: 2.3.1
env: PUPPET_GEM_VERSION="~> 3.3.0"
- rvm: 2.3.1
env: PUPPET_GEM_VERSION="~> 3.4.0"
- rvm: 2.3.1
env: PUPPET_GEM_VERSION="~> 3.5.0"
- rvm: 2.3.1
env: PUPPET_GEM_VERSION="~> 3.6.0"
- rvm: 2.3.1
env: PUPPET_GEM_VERSION="~> 3.7.0"
- rvm: 2.3.1
env: PUPPET_GEM_VERSION="~> 3.8.0"
- rvm: 2.3.1
env: PUPPET_GEM_VERSION="~> 3" FUTURE_PARSER="yes"

notifications:
email: false
13 changes: 9 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,21 @@ else
gem 'facter', :require => false
end

gem 'puppetlabs_spec_helper', '>= 1.2.0', :require => false
gem 'rspec-puppet', :require => false
gem 'rspec-puppet', '~> 2.0', :require => false
gem 'puppet-lint', '~> 2.0', :require => false
gem 'simplecov', :require => false

gem 'rspec', '~> 2.0', :require => false if RUBY_VERSION >= '1.8.7' && RUBY_VERSION < '1.9'
gem 'rake', '~> 10.0', :require => false if RUBY_VERSION >= '1.8.7' && RUBY_VERSION < '1.9'
gem 'rake', '<= 12.2.1', :require => false if RUBY_VERSION >= '1.9' && RUBY_VERSION < '2.0.0'
gem 'json', '<= 1.8', :require => false if RUBY_VERSION < '2.0.0'
gem 'json_pure', '<= 2.0.1', :require => false if RUBY_VERSION < '2.0.0'
gem 'metadata-json-lint', '0.0.11', :require => false if RUBY_VERSION < '1.9'
gem 'metadata-json-lint', :require => false if RUBY_VERSION >= '1.9'
gem 'metadata-json-lint', '0.0.11' if RUBY_VERSION >= '1.8.7' && RUBY_VERSION < '1.9'
gem 'metadata-json-lint', '1.0.0' if RUBY_VERSION >= '1.9' && RUBY_VERSION < '2.0'
gem 'metadata-json-lint' if RUBY_VERSION >= '2.0'

gem 'puppetlabs_spec_helper', '2.0.2', :require => false if RUBY_VERSION >= '1.8.7' && RUBY_VERSION < '1.9'
gem 'puppetlabs_spec_helper', '>= 2.0.0', :require => false if RUBY_VERSION >= '1.9'
gem 'parallel_tests', '<= 2.9.0', :require => false if RUBY_VERSION < '2.0.0'

# vim:ft=ruby
21 changes: 15 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,17 @@ Puppet module for installing and managing python, pip, virtualenvs and Gunicorn

# Compatibility #

* Puppet v3 (with and without the future parser)
See `.travis.yml` for compatibility matrix.

* Puppet v3 (with the future parser)
* Puppet v4

## Ruby versions

* 1.8.7
* 1.9.3
* 2.0.0
* 2.1.0
* 2.3.1
* 1.8.7 - Puppet 3
* 1.9.3 - Puppet 3
* 2.0.0 - Puppet 3
* 2.1.9 - Puppet 3 & 4

## OS Distributions ##

Expand All @@ -24,6 +25,7 @@ This module has been tested to work on the following systems.
* Debian 6
* Debian 7
* Debian 8
* Debian 9
* EL 5
* EL 6
* EL 7
Expand All @@ -32,6 +34,7 @@ This module has been tested to work on the following systems.
* Ubuntu 10.04
* Ubuntu 12.04
* Ubuntu 14.04
* Ubuntu 16.04

===

Expand Down Expand Up @@ -302,6 +305,12 @@ python::python_pips:
virtualenv: "/opt/env1"
"coverage":
virtualenv: "/opt/env2"
python::python_dotfiles:
"/var/lib/jenkins/.pip/pip.conf":
config:
global:
index-url: "https://mypypi.acme.com/simple/"
extra-index-url: "https://pypi.risedev.at/simple/"
```
### Using SCL packages from RedHat or CentOS
Expand Down
8 changes: 7 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ PuppetLint.configuration.send('disable_class_inherits_from_params_class')
PuppetLint.configuration.send('disable_class_parameter_defaults')
PuppetLint.configuration.send('disable_documentation')
PuppetLint.configuration.send('disable_single_quote_string_with_variables')
PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "pkg/**/*.pp"]

exclude_paths = [
"pkg/**/*",
Expand All @@ -27,6 +26,13 @@ exclude_paths = [
PuppetLint.configuration.ignore_paths = exclude_paths
PuppetSyntax.exclude_paths = exclude_paths

desc 'Validate manifests, templates, ruby files and shell scripts'
task :validate do
Dir['spec/**/*.rb'].each do |ruby_file|
sh "ruby -c #{ruby_file}" unless ruby_file =~ /spec\/fixtures/
end
end

desc "Run acceptance tests"
RSpec::Core::RakeTask.new(:acceptance) do |t|
t.pattern = 'spec/acceptance'
Expand Down
33 changes: 33 additions & 0 deletions lib/facter/python_release.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Make python release available as facts

def get_python_release(executable)
if Facter::Util::Resolution.which(executable)
results = Facter::Util::Resolution.exec("#{executable} -V 2>&1").match(/^.*(\d+\.\d+)\.\d+\+?$/)
if results
results[1]
end
end
end

Facter.add("python_release") do
setcode do
get_python_release 'python'
end
end

Facter.add("python2_release") do
setcode do
default_release = get_python_release 'python'
if default_release.nil? or !default_release.start_with?('2')
get_python_release 'python2'
else
default_release
end
end
end

Facter.add("python3_release") do
setcode do
get_python_release 'python3'
end
end
37 changes: 31 additions & 6 deletions manifests/gunicorn.pp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@
# [*ensure*]
# present|absent. Default: present
#
# [*config_dir*]
# Configure the gunicorn config directory path. Default: /etc/gunicorn.d
#
# [*manage_config_dir*]
# Set if the gunicorn config directory should be created. Default: false
#
# [*virtualenv*]
# Run in virtualenv, specify directory. Default: disabled
#
Expand Down Expand Up @@ -70,6 +76,8 @@
#
define python::gunicorn (
$ensure = present,
$config_dir = '/etc/gunicorn.d',
$manage_config_dir = false,
$virtualenv = false,
$mode = 'wsgi',
$dir = false,
Expand All @@ -96,12 +104,29 @@

validate_re($log_level, 'debug|info|warning|error|critical', "Invalid \$log_level value ${log_level}")

file { "/etc/gunicorn.d/${name}":
ensure => $ensure,
mode => '0644',
owner => 'root',
group => 'root',
content => template($template),
if $manage_config_dir {
file { $config_dir:
ensure => directory,
mode => '0755',
owner => 'root',
group => 'root',
}
file { "${config_dir}/${name}":
ensure => $ensure,
mode => '0644',
owner => 'root',
group => 'root',
content => template($template),
require => File[$config_dir],
}
} else {
file { "${config_dir}/${name}":
ensure => $ensure,
mode => '0644',
owner => 'root',
group => 'root',
content => template($template),
}
}

}
11 changes: 7 additions & 4 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
$python_virtualenvs = { },
$python_pyvenvs = { },
$python_requirements = { },
$python_dotfiles = { },
$use_epel = $python::params::use_epel,
$rhscl_use_public_repository = $python::params::rhscl_use_public_repository,
) inherits python::params{
Expand Down Expand Up @@ -123,6 +124,7 @@
validate_re($gunicorn, ['^(absent|present|latest)$'])
}

validate_hash($python_dotfiles)
validate_bool($manage_gunicorn)
validate_bool($use_epel)

Expand All @@ -133,15 +135,16 @@
}

# Anchor pattern to contain dependencies
anchor { 'python::begin': } ->
class { 'python::install': } ->
class { 'python::config': } ->
anchor { 'python::end': }
anchor { 'python::begin': }
-> class { 'python::install': }
-> class { 'python::config': }
-> anchor { 'python::end': }

# Allow hiera configuration of python resources
create_resources('python::pip', $python_pips)
create_resources('python::pyvenv', $python_pyvenvs)
create_resources('python::virtualenv', $python_virtualenvs)
create_resources('python::requirements', $python_requirements)
create_resources('python::dotfile', $python_dotfiles)

}
15 changes: 10 additions & 5 deletions manifests/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -164,12 +164,12 @@
}

if $::python::rhscl_use_public_repository {
Package <| tag == 'python-scl-repo' |> ->
Package <| tag == 'python-scl-package' |>
Package <| tag == 'python-scl-repo' |>
-> Package <| tag == 'python-scl-package' |>
}

Package <| tag == 'python-scl-package' |> ->
Package <| tag == 'python-pip-package' |>
Package <| tag == 'python-scl-package' |>
-> Package <| tag == 'python-pip-package' |>
}
default: {

Expand All @@ -182,6 +182,7 @@
package { 'python-dev':
ensure => $dev_ensure,
name => $pythondev,
alias => $pythondev,
}
}

Expand All @@ -203,14 +204,18 @@
} else {
if $::lsbdistcodename == 'jessie' {
$virtualenv_package = 'virtualenv'
} elsif $::lsbdistcodename == 'stretch' {
$virtualenv_package = 'virtualenv'
} elsif $::lsbdistcodename == 'xenial' {
$virtualenv_package = 'virtualenv'
} elsif $::osfamily == 'Gentoo' {
$virtualenv_package = 'virtualenv'
} else {
$virtualenv_package = 'python-virtualenv'
}
}

if $::python::version =~ /^3/ {
if "${::python::version}" =~ /^3/ { #lint:ignore:only_variable_string
$pip_category = undef
$pip_package = 'python3-pip'
} elsif ($::osfamily == 'RedHat') and (versioncmp($::operatingsystemmajrelease, '7') >= 0) {
Expand Down
Loading