From df25cc78db263ddfbd8588b6cc320a1970387c47 Mon Sep 17 00:00:00 2001 From: Sergey Stankevich Date: Sat, 19 Oct 2013 15:01:45 +0300 Subject: Adding .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b2bcbe8 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +pkg/ \ No newline at end of file -- cgit v1.2.3 From 680107d214b452feea02b4ad8dc4fdecaa565d94 Mon Sep 17 00:00:00 2001 From: Sergey Stankevich Date: Sat, 19 Oct 2013 15:02:25 +0300 Subject: Version bump --- Modulefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modulefile b/Modulefile index 6bfbe7a..f8b02b5 100644 --- a/Modulefile +++ b/Modulefile @@ -1,5 +1,5 @@ name 'puppet-python' -version '1.1.4' +version '1.1.6' author 'Sergey Stankevich' license 'Apache License, Version 2.0' -- cgit v1.2.3 From 94f0993b4f37a7f64bcf54f885f69f9de3a7ccc3 Mon Sep 17 00:00:00 2001 From: Sergey Stankevich Date: Sat, 19 Oct 2013 16:10:44 +0300 Subject: Forge upload --- Modulefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modulefile b/Modulefile index f8b02b5..0b1feed 100644 --- a/Modulefile +++ b/Modulefile @@ -1,4 +1,4 @@ -name 'puppet-python' +name 'stankevich-python' version '1.1.6' author 'Sergey Stankevich' -- cgit v1.2.3 From 65bf6fe8b6cf23050e755d62291f56f7e8654ede Mon Sep 17 00:00:00 2001 From: Sergey Stankevich Date: Sat, 19 Oct 2013 16:10:59 +0300 Subject: pip log option. Fixes #28 --- manifests/pip.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/pip.pp b/manifests/pip.pp index 8bd21d3..3ca33a8 100644 --- a/manifests/pip.pp +++ b/manifests/pip.pp @@ -88,7 +88,7 @@ define python::pip ( case $ensure { present: { exec { "pip_install_${name}": - command => "$pip_env --log-file ${cwd}/pip.log install $install_args ${proxy_flag} ${source}", + command => "$pip_env --log ${cwd}/pip.log install $install_args ${proxy_flag} ${source}", unless => "$pip_env freeze | grep -i -e ${grep_regex}", user => $owner, environment => $environment, -- cgit v1.2.3 From e47c5bbc602cdc7d0e2c1fffe890517dd190999c Mon Sep 17 00:00:00 2001 From: Sergey Stankevich Date: Sat, 19 Oct 2013 16:14:44 +0300 Subject: Version 1.1.7 --- Modulefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modulefile b/Modulefile index 0b1feed..890910f 100644 --- a/Modulefile +++ b/Modulefile @@ -1,5 +1,5 @@ name 'stankevich-python' -version '1.1.6' +version '1.1.7' author 'Sergey Stankevich' license 'Apache License, Version 2.0' -- cgit v1.2.3 From 176915523acd5ddd88de187426966b0d9ffb5f4b Mon Sep 17 00:00:00 2001 From: Jarl Stefansson Date: Fri, 1 Nov 2013 18:20:01 -0400 Subject: Disable system package flag on older virtualenv --- lib/facter/virtualenv_version.rb | 7 +++++++ manifests/virtualenv.pp | 11 ++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 lib/facter/virtualenv_version.rb diff --git a/lib/facter/virtualenv_version.rb b/lib/facter/virtualenv_version.rb new file mode 100644 index 0000000..2ede3f9 --- /dev/null +++ b/lib/facter/virtualenv_version.rb @@ -0,0 +1,7 @@ +require 'puppet' +pkg = Puppet::Type.type(:package).new(:name => "virtualenv") +Facter.add("virtualenv_version") do + setcode do + /^(\d+\.\d+\.\d+).*$/.match(pkg.retrieve[pkg.property(:ensure)])[1] + end +end diff --git a/manifests/virtualenv.pp b/manifests/virtualenv.pp index bdcfc6f..fc46c72 100644 --- a/manifests/virtualenv.pp +++ b/manifests/virtualenv.pp @@ -15,6 +15,8 @@ # # [*systempkgs*] # Copy system site-packages into virtualenv. Default: don't +# If virtualenv version < 1.7 this flag has no effect since +# the system packages were not supported # # [*distribute*] # Include distribute in the virtualenv. Default: true @@ -88,9 +90,12 @@ define python::virtualenv ( default => "&& export http_proxy=${proxy}", } - $system_pkgs_flag = $systempkgs ? { - false => '', - default => '--system-site-packages', + # Virtualenv versions prior to 1.7 do not support the + # --system-site-packages flag, default off for prior versions + if versioncmp($::virtualenv_version,'1.7') > 0 and systempkgs == true { + $system_pkgs_flag = '--system-site-packages', + } else { + $system_pkgs_flag = '' } $distribute_pkg = $distribute ? { -- cgit v1.2.3 From d38db335949c6f8abfb4247276492b1a5051e8f9 Mon Sep 17 00:00:00 2001 From: Jarl Stefansson Date: Fri, 1 Nov 2013 18:32:16 -0400 Subject: Fix virtualenv conditional syntax --- manifests/virtualenv.pp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manifests/virtualenv.pp b/manifests/virtualenv.pp index fc46c72..8b707c8 100644 --- a/manifests/virtualenv.pp +++ b/manifests/virtualenv.pp @@ -92,8 +92,8 @@ define python::virtualenv ( # Virtualenv versions prior to 1.7 do not support the # --system-site-packages flag, default off for prior versions - if versioncmp($::virtualenv_version,'1.7') > 0 and systempkgs == true { - $system_pkgs_flag = '--system-site-packages', + if (( versioncmp($::virtualenv_version,'1.7') > 0 ) and ( $systempkgs == true )) { + $system_pkgs_flag = '--system-site-packages' } else { $system_pkgs_flag = '' } -- cgit v1.2.3 From b044b0b9fa03adb6897a20fdc5adbb56f97856e4 Mon Sep 17 00:00:00 2001 From: Jarl Stefansson Date: Mon, 4 Nov 2013 15:39:02 -0500 Subject: Add system wide default python version to facter --- lib/facter/system_python_version.rb | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 lib/facter/system_python_version.rb diff --git a/lib/facter/system_python_version.rb b/lib/facter/system_python_version.rb new file mode 100644 index 0000000..099104f --- /dev/null +++ b/lib/facter/system_python_version.rb @@ -0,0 +1,7 @@ +require 'puppet' +pkg = Puppet::Type.type(:package).new(:name => "python") +Facter.add("system_python_version") do + setcode do + /^(\d+\.\d+\.\d+).*$/.match(pkg.retrieve[pkg.property(:ensure)])[1] + end +end -- cgit v1.2.3 From 42e0f436f08778374bc44aa6a0b81d6fd48d6f43 Mon Sep 17 00:00:00 2001 From: Jarl Stefansson Date: Mon, 4 Nov 2013 16:32:46 -0500 Subject: Added support for pip installed virtualenv facter --- lib/facter/virtualenv_version.rb | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/facter/virtualenv_version.rb b/lib/facter/virtualenv_version.rb index 2ede3f9..327b2ca 100644 --- a/lib/facter/virtualenv_version.rb +++ b/lib/facter/virtualenv_version.rb @@ -1,7 +1,19 @@ +# Show the virtualenv version +# works with virualenv loaded and without, pip installed and package installed require 'puppet' pkg = Puppet::Type.type(:package).new(:name => "virtualenv") Facter.add("virtualenv_version") do + has_weight 100 setcode do - /^(\d+\.\d+\.\d+).*$/.match(pkg.retrieve[pkg.property(:ensure)])[1] + Facter::Util::Resolution.exec('virtualenv --version') + end +end + +Facter.add("virtualenv_version") do + has_eight 50 + setcode do + if pkg.retrieve[pkg.property(:ensure)] != 'purged' + /^.*(\d+\.\d+\.\d+).*$/.match(pkg.retrieve[pkg.property(:ensure)])[1] + end end end -- cgit v1.2.3 From 669e62ca668255b179d93644101fd4e534f02bcb Mon Sep 17 00:00:00 2001 From: Jarl Stefansson Date: Tue, 5 Nov 2013 10:44:38 -0500 Subject: Improve python version and virtualenv version facts --- lib/facter/system_python_version.rb | 19 +++++++++++++++++++ lib/facter/virtualenv_version.rb | 6 +++--- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/lib/facter/system_python_version.rb b/lib/facter/system_python_version.rb index 099104f..6df6ae4 100644 --- a/lib/facter/system_python_version.rb +++ b/lib/facter/system_python_version.rb @@ -1,7 +1,26 @@ +# Make python versions available as facts +# In lists default python and system python versions require 'puppet' pkg = Puppet::Type.type(:package).new(:name => "python") + Facter.add("system_python_version") do setcode do /^(\d+\.\d+\.\d+).*$/.match(pkg.retrieve[pkg.property(:ensure)])[1] end end + +Facter.add("python_version") do + has_weight 100 + setcode do + /^.*(\d+\.\d+\.\d+)$/.match(Facter::Util::Resolution.exec('python -V'))[1] + end +end + +Facter.add("python_version") do + has_weight 50 + setcode do + if pkg.retrieve[pkg.property(:ensure)] != 'purged' + /^.*(\d+\.\d+\.\d+).*$/.match(pkg.retrieve[pkg.property(:ensure)])[1] + end + end +end diff --git a/lib/facter/virtualenv_version.rb b/lib/facter/virtualenv_version.rb index 327b2ca..c923b09 100644 --- a/lib/facter/virtualenv_version.rb +++ b/lib/facter/virtualenv_version.rb @@ -1,5 +1,5 @@ -# Show the virtualenv version -# works with virualenv loaded and without, pip installed and package installed +# Make virtualenv version available as a fact +# Works with virualenv loaded and without, pip installed and package installed require 'puppet' pkg = Puppet::Type.type(:package).new(:name => "virtualenv") Facter.add("virtualenv_version") do @@ -10,7 +10,7 @@ Facter.add("virtualenv_version") do end Facter.add("virtualenv_version") do - has_eight 50 + has_weight 50 setcode do if pkg.retrieve[pkg.property(:ensure)] != 'purged' /^.*(\d+\.\d+\.\d+).*$/.match(pkg.retrieve[pkg.property(:ensure)])[1] -- cgit v1.2.3 From b4cf920545959bf6cbb5f438b59b2cba6c0ff492 Mon Sep 17 00:00:00 2001 From: Jarl Stefansson Date: Tue, 5 Nov 2013 11:22:59 -0500 Subject: Fix facter for versions --- lib/facter/python_version.rb | 28 ++++++++++++++++++++++++++++ lib/facter/system_python_version.rb | 26 -------------------------- 2 files changed, 28 insertions(+), 26 deletions(-) create mode 100644 lib/facter/python_version.rb delete mode 100644 lib/facter/system_python_version.rb diff --git a/lib/facter/python_version.rb b/lib/facter/python_version.rb new file mode 100644 index 0000000..a2bdb26 --- /dev/null +++ b/lib/facter/python_version.rb @@ -0,0 +1,28 @@ +# Make python versions available as facts +# In lists default python and system python versions +require 'puppet' +pkg = Puppet::Type.type(:package).new(:name => "python") + +Facter.add("system_python_version") do + setcode do + if pkg.retrieve[pkg.property(:ensure)] != 'purged' + /^(\d+\.\d+\.\d+).*$/.match(pkg.retrieve[pkg.property(:ensure)])[1] + end + end +end + +Facter.add("python_version") do + has_weight 100 + setcode do + /^.*(\d+\.\d+\.\d+)$/.match(Facter::Util::Resolution.exec('python -V'))[1] + end +end + +Facter.add("python_version") do + has_weight 50 + setcode do + if pkg.retrieve[pkg.property(:ensure)] != 'purged' + /^.*(\d+\.\d+\.\d+).*$/.match(pkg.retrieve[pkg.property(:ensure)])[1] + end + end +end diff --git a/lib/facter/system_python_version.rb b/lib/facter/system_python_version.rb deleted file mode 100644 index 6df6ae4..0000000 --- a/lib/facter/system_python_version.rb +++ /dev/null @@ -1,26 +0,0 @@ -# Make python versions available as facts -# In lists default python and system python versions -require 'puppet' -pkg = Puppet::Type.type(:package).new(:name => "python") - -Facter.add("system_python_version") do - setcode do - /^(\d+\.\d+\.\d+).*$/.match(pkg.retrieve[pkg.property(:ensure)])[1] - end -end - -Facter.add("python_version") do - has_weight 100 - setcode do - /^.*(\d+\.\d+\.\d+)$/.match(Facter::Util::Resolution.exec('python -V'))[1] - end -end - -Facter.add("python_version") do - has_weight 50 - setcode do - if pkg.retrieve[pkg.property(:ensure)] != 'purged' - /^.*(\d+\.\d+\.\d+).*$/.match(pkg.retrieve[pkg.property(:ensure)])[1] - end - end -end -- cgit v1.2.3 From f6709549671caa40be8dd477ec4abb94fab7e36a Mon Sep 17 00:00:00 2001 From: Jarl Stefansson Date: Tue, 5 Nov 2013 17:13:40 -0500 Subject: Add support to install virtualenv from pip --- manifests/init.pp | 3 ++- manifests/install.pp | 17 ++++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 2a9a44c..cc9336f 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -14,7 +14,8 @@ # Install python-dev. Default: false # # [*virtualenv*] -# Install python-virtualenv. Default: false +# Install python-virtualenv. Default: false, also accepts 'pip' which will +# install latest virtualenv from pip rather than package manager # # [*gunicorn*] # Install Gunicorn. Default: false diff --git a/manifests/install.pp b/manifests/install.pp index 9306e3a..10331ff 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -28,9 +28,24 @@ class python::install { $venv_ensure = $python::virtualenv ? { true => present, default => absent, + pip => absent, } - package { 'python-virtualenv': ensure => $venv_ensure } + case $venv_ensure { + 'pip': { + exec { "pip-virtualenv": + command => "pip install --upgrade virtualenv", + cwd => $cwd, + user => $run_as_user, + timeout => 0, + path => ["/usr/local/bin","/usr/bin","/bin", "/usr/sbin"], + require => Package['python-pip'] + } + } + default: { + package { 'python-virtualenv': ensure => $venv_ensure } + } + } $gunicorn_ensure = $python::gunicorn ? { true => present, -- cgit v1.2.3 From ec2b62a53479cbc8dea7adad69904ad1a430cc5d Mon Sep 17 00:00:00 2001 From: Jarl Stefansson Date: Tue, 5 Nov 2013 17:31:55 -0500 Subject: Fix pip bug --- manifests/install.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/install.pp b/manifests/install.pp index 10331ff..cf0f78a 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -31,7 +31,7 @@ class python::install { pip => absent, } - case $venv_ensure { + case $python::virtualenv { 'pip': { exec { "pip-virtualenv": command => "pip install --upgrade virtualenv", -- cgit v1.2.3 From 0a97baffaec11215137d49a5e2e7b905f7f681db Mon Sep 17 00:00:00 2001 From: Jarl Stefansson Date: Tue, 5 Nov 2013 18:36:27 -0500 Subject: Fixing up virtualenv pip install --- manifests/install.pp | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/manifests/install.pp b/manifests/install.pp index cf0f78a..e90ecfe 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -28,19 +28,12 @@ class python::install { $venv_ensure = $python::virtualenv ? { true => present, default => absent, - pip => absent, } - case $python::virtualenv { - 'pip': { - exec { "pip-virtualenv": - command => "pip install --upgrade virtualenv", - cwd => $cwd, - user => $run_as_user, - timeout => 0, - path => ["/usr/local/bin","/usr/bin","/bin", "/usr/sbin"], - require => Package['python-pip'] - } + # Install latest from pip if pip is the provider + case $python::provider { + pip: { + package { 'python-virtualenv': ensure => latest, provider => pip } } default: { package { 'python-virtualenv': ensure => $venv_ensure } -- cgit v1.2.3 From c5c61860a5261b0334781fd2875f248d96fc2aff Mon Sep 17 00:00:00 2001 From: Jarl Stefansson Date: Thu, 7 Nov 2013 11:53:12 -0500 Subject: Add provider flag to class parameters --- manifests/init.pp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/manifests/init.pp b/manifests/init.pp index cc9336f..889d9c6 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -39,7 +39,8 @@ class python ( $pip = false, $dev = false, $virtualenv = false, - $gunicorn = false + $gunicorn = false, + $provider = undef, ) { # Module compatibility check -- cgit v1.2.3 From e7997712ce3d4ee520a2a335171d41e79f867176 Mon Sep 17 00:00:00 2001 From: Jarl Stefansson Date: Thu, 7 Nov 2013 12:19:41 -0500 Subject: Fix package names for pip --- manifests/install.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/install.pp b/manifests/install.pp index e90ecfe..ba4ff87 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -33,7 +33,7 @@ class python::install { # Install latest from pip if pip is the provider case $python::provider { pip: { - package { 'python-virtualenv': ensure => latest, provider => pip } + package { 'virtualenv': ensure => latest, provider => pip } } default: { package { 'python-virtualenv': ensure => $venv_ensure } -- cgit v1.2.3 From 56df14fb57b8583146b72560afa0a83e0ca63ef0 Mon Sep 17 00:00:00 2001 From: Jarl Stefansson Date: Thu, 7 Nov 2013 12:39:26 -0500 Subject: Add /usr/local/bin to path for pip installed bins --- manifests/virtualenv.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/virtualenv.pp b/manifests/virtualenv.pp index 8b707c8..06c342e 100644 --- a/manifests/virtualenv.pp +++ b/manifests/virtualenv.pp @@ -68,7 +68,7 @@ define python::virtualenv ( $group = 'root', $proxy = false, $environment = [], - $path = [ '/bin', '/usr/bin', '/usr/sbin' ] + $path = [ '/bin', '/usr/bin', '/usr/sbin','/usr/local/bin' ] ) { $venv_dir = $name -- cgit v1.2.3 From 8a68085f7450f95ca736c690e14b58a0998a13f1 Mon Sep 17 00:00:00 2001 From: Justin Quick Date: Thu, 7 Nov 2013 15:57:10 -0500 Subject: added cwd parameter, made timeout configurable --- manifests/virtualenv.pp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/manifests/virtualenv.pp b/manifests/virtualenv.pp index bdcfc6f..8fc17a9 100644 --- a/manifests/virtualenv.pp +++ b/manifests/virtualenv.pp @@ -66,7 +66,9 @@ define python::virtualenv ( $group = 'root', $proxy = false, $environment = [], - $path = [ '/bin', '/usr/bin', '/usr/sbin' ] + $path = [ '/bin', '/usr/bin', '/usr/sbin' ], + $cwd = undef, + $timeout = 1800 ) { $venv_dir = $name @@ -115,10 +117,11 @@ define python::virtualenv ( exec { "python_requirements_initial_install_${requirements}_${venv_dir}": command => "${venv_dir}/bin/pip --log-file ${venv_dir}/pip.log install ${pypi_index} ${proxy_flag} -r ${requirements}", refreshonly => true, - timeout => 1800, + timeout => $timeout, user => $owner, subscribe => Exec["python_virtualenv_${venv_dir}"], environment => $environment, + cwd => $cwd } python::requirements { "${requirements}_${venv_dir}": -- cgit v1.2.3 From c45a37b5819d3c0dab423b93cefb31e65bddad9d Mon Sep 17 00:00:00 2001 From: Justin Quick Date: Thu, 7 Nov 2013 16:03:28 -0500 Subject: docs --- README.md | 4 ++++ manifests/virtualenv.pp | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/README.md b/README.md index e9a2b85..cea0c2d 100644 --- a/README.md +++ b/README.md @@ -117,6 +117,10 @@ Creates Python virtualenv. **index** - Base URL of Python package index. Default: none +**cwd** - The directory from which to run the "pip install" command. Default: undef + +**timeout** - The maximum time in seconds the "pip install" command should take. Default: 1800 + python::virtualenv { '/var/www/project1': ensure => present, version => 'system', diff --git a/manifests/virtualenv.pp b/manifests/virtualenv.pp index 8fc17a9..8486183 100644 --- a/manifests/virtualenv.pp +++ b/manifests/virtualenv.pp @@ -37,6 +37,12 @@ # [*path*] # Specifies the PATH variable. Default: [ '/bin', '/usr/bin', '/usr/sbin' ] # +# [*cwd*] +# The directory from which to run the "pip install" command. Default: undef +# +# [*timeout*] +# The maximum time in seconds the "pip install" command should take. Default: 1800 +# # === Examples # # python::virtualenv { '/var/www/project1': -- cgit v1.2.3 From 343788fcd8b64f494145c07c41a39c1afd6eafd6 Mon Sep 17 00:00:00 2001 From: Justin Quick Date: Thu, 7 Nov 2013 16:04:30 -0500 Subject: example docs --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index cea0c2d..ec30953 100644 --- a/README.md +++ b/README.md @@ -130,6 +130,8 @@ Creates Python virtualenv. distribute => false, owner => 'appuser', group => 'apps', + cwd => '/var/www/project1', + timeout => 0, } ### python::gunicorn -- cgit v1.2.3 From 2d0f8216ab222a533d05d31331267b180c3aac47 Mon Sep 17 00:00:00 2001 From: Justin Quick Date: Thu, 7 Nov 2013 16:05:12 -0500 Subject: ws fix --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ec30953..0bcd952 100644 --- a/README.md +++ b/README.md @@ -130,8 +130,8 @@ Creates Python virtualenv. distribute => false, owner => 'appuser', group => 'apps', - cwd => '/var/www/project1', - timeout => 0, + cwd => '/var/www/project1', + timeout => 0, } ### python::gunicorn -- cgit v1.2.3 From be335fa2048a60921b0896c770d87a60b53c4aea Mon Sep 17 00:00:00 2001 From: Jarl Stefansson Date: Thu, 7 Nov 2013 16:36:28 -0500 Subject: Add path to pip when executed out of virtualenv --- manifests/pip.pp | 1 + 1 file changed, 1 insertion(+) diff --git a/manifests/pip.pp b/manifests/pip.pp index ddbcd6f..a6faea8 100644 --- a/manifests/pip.pp +++ b/manifests/pip.pp @@ -84,6 +84,7 @@ define python::pip ( unless => "$pip_env freeze | grep -i -e ${grep_regex}", user => $owner, environment => $environment, + path => [ '/usr/bin', '/usr/local/bin/' ], } } -- cgit v1.2.3 From 52dfd22110ab3fdf83edb11868c53803d9f82b45 Mon Sep 17 00:00:00 2001 From: Jarl Stefansson Date: Thu, 7 Nov 2013 17:24:53 -0500 Subject: Fix paths --- manifests/pip.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/pip.pp b/manifests/pip.pp index a6faea8..6075c3a 100644 --- a/manifests/pip.pp +++ b/manifests/pip.pp @@ -84,7 +84,7 @@ define python::pip ( unless => "$pip_env freeze | grep -i -e ${grep_regex}", user => $owner, environment => $environment, - path => [ '/usr/bin', '/usr/local/bin/' ], + path => [ '/bin', '/usr/bin', '/usr/local/bin/' ], } } -- cgit v1.2.3 From a1fc8ab73c6c34413e2957bea1d3a6719e4612c4 Mon Sep 17 00:00:00 2001 From: Jarl Stefansson Date: Thu, 7 Nov 2013 18:01:16 -0500 Subject: Add path to pip install/uninstall --- manifests/pip.pp | 1 + 1 file changed, 1 insertion(+) diff --git a/manifests/pip.pp b/manifests/pip.pp index 6075c3a..f64ea97 100644 --- a/manifests/pip.pp +++ b/manifests/pip.pp @@ -94,6 +94,7 @@ define python::pip ( onlyif => "$pip_env freeze | grep -i -e ${grep_regex}", user => $owner, environment => $environment, + path => [ '/bin', '/usr/bin', '/usr/local/bin/' ], } } } -- cgit v1.2.3 From 99a7bbbf8a0d4db3a2abba9f4a47ac65c223bbaa Mon Sep 17 00:00:00 2001 From: Jarl Stefansson Date: Thu, 7 Nov 2013 18:05:06 -0500 Subject: Fix paths --- manifests/pip.pp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manifests/pip.pp b/manifests/pip.pp index f64ea97..9589b1a 100644 --- a/manifests/pip.pp +++ b/manifests/pip.pp @@ -84,7 +84,7 @@ define python::pip ( unless => "$pip_env freeze | grep -i -e ${grep_regex}", user => $owner, environment => $environment, - path => [ '/bin', '/usr/bin', '/usr/local/bin/' ], + path => ["/usr/local/bin","/usr/bin","/bin", "/usr/sbin"], } } @@ -94,7 +94,7 @@ define python::pip ( onlyif => "$pip_env freeze | grep -i -e ${grep_regex}", user => $owner, environment => $environment, - path => [ '/bin', '/usr/bin', '/usr/local/bin/' ], + path => ["/usr/local/bin","/usr/bin","/bin", "/usr/sbin"], } } } -- cgit v1.2.3 From 2e3784ba2c93f8240648682ce0b3c14bcb8605a7 Mon Sep 17 00:00:00 2001 From: Jarl Stefansson Date: Thu, 7 Nov 2013 18:46:52 -0500 Subject: Added latest support to pip, fixed log param --log-file is not supported in older versions, changed to use --log Added ability to do pip --upgrade by using latest --- lib/facter/pip_version.rb | 19 +++++++++++++++++++ manifests/pip.pp | 11 ++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 lib/facter/pip_version.rb diff --git a/lib/facter/pip_version.rb b/lib/facter/pip_version.rb new file mode 100644 index 0000000..48dd0bf --- /dev/null +++ b/lib/facter/pip_version.rb @@ -0,0 +1,19 @@ +# Make pip version available as a fact +# Works with pip loaded and without, pip installed using pip and package installed +require 'puppet' +pkg = Puppet::Type.type(:package).new(:name => "python-pip") +Facter.add("pip_version") do + has_weight 100 + setcode do + Facter::Util::Resolution.exec('pip --version') + end +end + +Facter.add("pip_version") do + has_weight 50 + setcode do + if pkg.retrieve[pkg.property(:ensure)] != 'purged' + /^.*(\d+\.\d+\.\d+).*$/.match(pkg.retrieve[pkg.property(:ensure)])[1] + end + end +end diff --git a/manifests/pip.pp b/manifests/pip.pp index 9589b1a..0bed6dc 100644 --- a/manifests/pip.pp +++ b/manifests/pip.pp @@ -80,7 +80,7 @@ define python::pip ( case $ensure { present: { exec { "pip_install_${name}": - command => "$pip_env --log-file ${cwd}/pip.log install ${proxy_flag} ${source}", + command => "$pip_env --log ${cwd}/pip.log install ${proxy_flag} ${source}", unless => "$pip_env freeze | grep -i -e ${grep_regex}", user => $owner, environment => $environment, @@ -88,6 +88,15 @@ define python::pip ( } } + latest: { + exec { "pip_install_${name}": + command => "$pip_env --log ${cwd}/pip.log install --upgrade ${proxy_flag} ${source}", + user => $owner, + environment => $environment, + path => ["/usr/local/bin","/usr/bin","/bin", "/usr/sbin"], + } + } + default: { exec { "pip_uninstall_${name}": command => "echo y | $pip_env uninstall ${proxy_flag} ${name}", -- cgit v1.2.3 From 2a6f96857f44c5781733be314b92c0053ba0e9a6 Mon Sep 17 00:00:00 2001 From: Jarl Stefansson Date: Thu, 7 Nov 2013 19:03:13 -0500 Subject: Change --log-file to --log for backw. pip compat --- manifests/requirements.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/requirements.pp b/manifests/requirements.pp index 67906fc..af84707 100644 --- a/manifests/requirements.pp +++ b/manifests/requirements.pp @@ -79,7 +79,7 @@ define python::requirements ( exec { "python_requirements${name}": provider => shell, - command => "${pip_env} --log-file ${cwd}/pip.log install ${proxy_flag} -r ${requirements}", + command => "${pip_env} --log ${cwd}/pip.log install ${proxy_flag} -r ${requirements}", refreshonly => true, timeout => 1800, user => $owner, -- cgit v1.2.3 From 29bf73bfa6d3e0f6b880bb4c4125edc1b8f0675e Mon Sep 17 00:00:00 2001 From: Sergey Stankevich Date: Fri, 8 Nov 2013 13:28:12 +0200 Subject: Release 1.1.8 --- Modulefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modulefile b/Modulefile index 890910f..37a5401 100644 --- a/Modulefile +++ b/Modulefile @@ -1,5 +1,5 @@ name 'stankevich-python' -version '1.1.7' +version '1.1.8' author 'Sergey Stankevich' license 'Apache License, Version 2.0' -- cgit v1.2.3 From 56b98bc177f34fbafa292e8a339fcce3abdd939b Mon Sep 17 00:00:00 2001 From: Jarl Stefansson Date: Fri, 8 Nov 2013 11:34:54 -0500 Subject: Fix system package handling for < v.1.7 --- manifests/virtualenv.pp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/manifests/virtualenv.pp b/manifests/virtualenv.pp index 06c342e..96d48ee 100644 --- a/manifests/virtualenv.pp +++ b/manifests/virtualenv.pp @@ -92,8 +92,12 @@ define python::virtualenv ( # Virtualenv versions prior to 1.7 do not support the # --system-site-packages flag, default off for prior versions + # Prior to version 1.7 the default was equal to --system-site-packages + # and the flag --no-site-packages had to be passed to do the opposite if (( versioncmp($::virtualenv_version,'1.7') > 0 ) and ( $systempkgs == true )) { $system_pkgs_flag = '--system-site-packages' + } elif (( versioncmp($::virtualenv_version,'1.7') < { 0 ) and ( $systempkgs == false )) + $system_pkgs_flag = '--no-site-packages' } else { $system_pkgs_flag = '' } -- cgit v1.2.3 From 5f38429dbb30a119c8e7e4b646012075c862fa38 Mon Sep 17 00:00:00 2001 From: Jarl Stefansson Date: Fri, 8 Nov 2013 11:48:06 -0500 Subject: change elif to elsif --- manifests/virtualenv.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/virtualenv.pp b/manifests/virtualenv.pp index 96d48ee..e5397da 100644 --- a/manifests/virtualenv.pp +++ b/manifests/virtualenv.pp @@ -96,7 +96,7 @@ define python::virtualenv ( # and the flag --no-site-packages had to be passed to do the opposite if (( versioncmp($::virtualenv_version,'1.7') > 0 ) and ( $systempkgs == true )) { $system_pkgs_flag = '--system-site-packages' - } elif (( versioncmp($::virtualenv_version,'1.7') < { 0 ) and ( $systempkgs == false )) + } elsif (( versioncmp($::virtualenv_version,'1.7') < { 0 ) and ( $systempkgs == false )) $system_pkgs_flag = '--no-site-packages' } else { $system_pkgs_flag = '' -- cgit v1.2.3 From df103dd55f719de52b17f059557593bf6e383cb1 Mon Sep 17 00:00:00 2001 From: Jarl Stefansson Date: Fri, 8 Nov 2013 11:54:07 -0500 Subject: Fix syntax error --- manifests/virtualenv.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/virtualenv.pp b/manifests/virtualenv.pp index e5397da..282742b 100644 --- a/manifests/virtualenv.pp +++ b/manifests/virtualenv.pp @@ -96,7 +96,7 @@ define python::virtualenv ( # and the flag --no-site-packages had to be passed to do the opposite if (( versioncmp($::virtualenv_version,'1.7') > 0 ) and ( $systempkgs == true )) { $system_pkgs_flag = '--system-site-packages' - } elsif (( versioncmp($::virtualenv_version,'1.7') < { 0 ) and ( $systempkgs == false )) + } elsif (( versioncmp($::virtualenv_version,'1.7') < { 0 ) and ( $systempkgs == false )) { $system_pkgs_flag = '--no-site-packages' } else { $system_pkgs_flag = '' -- cgit v1.2.3 From 0f83afd92aeea4af35795f881f9eaa408d4082c3 Mon Sep 17 00:00:00 2001 From: Jarl Stefansson Date: Fri, 8 Nov 2013 11:56:04 -0500 Subject: Fix more syntax --- manifests/virtualenv.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/virtualenv.pp b/manifests/virtualenv.pp index 282742b..95fe1f7 100644 --- a/manifests/virtualenv.pp +++ b/manifests/virtualenv.pp @@ -96,7 +96,7 @@ define python::virtualenv ( # and the flag --no-site-packages had to be passed to do the opposite if (( versioncmp($::virtualenv_version,'1.7') > 0 ) and ( $systempkgs == true )) { $system_pkgs_flag = '--system-site-packages' - } elsif (( versioncmp($::virtualenv_version,'1.7') < { 0 ) and ( $systempkgs == false )) { + } elsif (( versioncmp($::virtualenv_version,'1.7') < 0 ) and ( $systempkgs == false )) { $system_pkgs_flag = '--no-site-packages' } else { $system_pkgs_flag = '' -- cgit v1.2.3 From 69d2a1447cb3b72fc25ebf19f6f82a35ef4aeb1f Mon Sep 17 00:00:00 2001 From: Jarl Stefansson Date: Fri, 8 Nov 2013 18:32:32 -0500 Subject: Added full pip install support for all packages --- manifests/install.pp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/manifests/install.pp b/manifests/install.pp index ba4ff87..8bc1b49 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -10,8 +10,6 @@ class python::install { /(?i:Debian|Ubuntu)/ => "${python}-dev" } - package { $python: ensure => present } - $dev_ensure = $python::dev ? { true => present, default => absent, @@ -22,9 +20,6 @@ class python::install { default => absent, } - package { $pythondev: ensure => $dev_ensure } - package { 'python-pip': ensure => $pip_ensure } - $venv_ensure = $python::virtualenv ? { true => present, default => absent, @@ -33,10 +28,16 @@ class python::install { # Install latest from pip if pip is the provider case $python::provider { pip: { - package { 'virtualenv': ensure => latest, provider => pip } + package { 'virtualenv': ensure => latest, provider => pip } + package { 'pip': ensure => latest, provider => pip } + package { $pythondev: ensure => latest } + package { "python==${python::version}": ensure => latest, provider => pip } } default: { package { 'python-virtualenv': ensure => $venv_ensure } + package { 'python-pip': ensure => $pip_ensure } + package { $pythondev: ensure => $dev_ensure } + package { $python: ensure => present } } } -- cgit v1.2.3 From 8bf9aac814812d0235ee5aa08e097d6dd03c188d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hubert=20Jagodzi=C5=84ski?= Date: Mon, 18 Nov 2013 08:27:57 +0100 Subject: Add to python::pip ensure => latest --- README.md | 2 +- manifests/pip.pp | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0bcd952..751376a 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,7 @@ Installs and manages python, python-dev, python-virtualenv and Gunicorn. Installs and manages packages from pip. -**ensure** - present/absent. Default: present +**ensure** - present/latest/absent. Default: present **virtualenv** - virtualenv to run pip in. Default: system (no virtualenv) diff --git a/manifests/pip.pp b/manifests/pip.pp index 3ca33a8..7b51439 100644 --- a/manifests/pip.pp +++ b/manifests/pip.pp @@ -95,6 +95,14 @@ define python::pip ( } } + latest: { + exec { "pip_install_${name}": + command => "$pip_env --log ${cwd}/pip.log install -U $install_args ${proxy_flag} ${source}", + user => $owner, + environment => $environment, + } + } + default: { exec { "pip_uninstall_${name}": command => "echo y | $pip_env uninstall $uninstall_args ${proxy_flag} ${name}", -- cgit v1.2.3 From 1f79c6c00bafb4afd744a4be74e804f87a09aba8 Mon Sep 17 00:00:00 2001 From: Sergey Stankevich Date: Mon, 18 Nov 2013 10:32:11 +0200 Subject: Release 1.1.9 --- Modulefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modulefile b/Modulefile index 37a5401..7b21f05 100644 --- a/Modulefile +++ b/Modulefile @@ -1,5 +1,5 @@ name 'stankevich-python' -version '1.1.8' +version '1.1.9' author 'Sergey Stankevich' license 'Apache License, Version 2.0' -- cgit v1.2.3 From 0d5e10790f83b6f2662bb89d34c510bb29f403bc Mon Sep 17 00:00:00 2001 From: John Jacobsen Date: Mon, 18 Nov 2013 17:11:24 -0600 Subject: Add support for Scientific Linux Fixes #39. Tested manually in a few cases on a Vagrant Scientific Linux 6 VM and seems to work OK so far. --- manifests/init.pp | 2 +- manifests/install.pp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 2a9a44c..c4e469d 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -42,7 +42,7 @@ class python ( ) { # Module compatibility check - $compatible = [ 'Debian', 'Ubuntu', 'CentOS', 'RedHat' ] + $compatible = [ 'Debian', 'Ubuntu', 'CentOS', 'RedHat', 'Scientific' ] if ! ($::operatingsystem in $compatible) { fail("Module is not compatible with ${::operatingsystem}") } diff --git a/manifests/install.pp b/manifests/install.pp index 9306e3a..415092e 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -6,8 +6,8 @@ class python::install { } $pythondev = $::operatingsystem ? { - /(?i:RedHat|CentOS|Fedora)/ => "${python}-devel", - /(?i:Debian|Ubuntu)/ => "${python}-dev" + /(?i:RedHat|CentOS|Fedora|Scientific)/ => "${python}-devel", + /(?i:Debian|Ubuntu)/ => "${python}-dev" } package { $python: ensure => present } -- cgit v1.2.3 From 725cf0d480b73abd53c8b4d31dc6b3190188ca74 Mon Sep 17 00:00:00 2001 From: Sergey Stankevich Date: Tue, 19 Nov 2013 12:11:22 +0200 Subject: Release 1.2.0 --- Modulefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modulefile b/Modulefile index 7b21f05..82069d4 100644 --- a/Modulefile +++ b/Modulefile @@ -1,5 +1,5 @@ name 'stankevich-python' -version '1.1.9' +version '1.2.0' author 'Sergey Stankevich' license 'Apache License, Version 2.0' -- cgit v1.2.3 From 04bffc411afb19a572af34d1a2e0f7029f16dfe4 Mon Sep 17 00:00:00 2001 From: Daniel Lawrence Date: Fri, 29 Nov 2013 09:16:31 +1100 Subject: Added manage_gunicorn flag. This will allow a user to stop the module from trying to do anything with gunicorn. --- manifests/config.pp | 21 +++++++++++---------- manifests/init.pp | 9 +++++---- manifests/install.pp | 11 ++++++----- 3 files changed, 22 insertions(+), 19 deletions(-) diff --git a/manifests/config.pp b/manifests/config.pp index 49e5230..fdd808f 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -6,18 +6,19 @@ class python::config { Python::Virtualenv <| |> -> Python::Pip <| |> - if $python::gunicorn { - Class['python::install'] -> Python::Gunicorn <| |> + if $python::manage_gunicorn { + if $python::gunicorn { + Class['python::install'] -> Python::Gunicorn <| |> - Python::Gunicorn <| |> ~> Service['gunicorn'] + Python::Gunicorn <| |> ~> Service['gunicorn'] - service { 'gunicorn': - ensure => running, - enable => true, - hasrestart => true, - hasstatus => false, - pattern => '/usr/bin/gunicorn', + service { 'gunicorn': + ensure => running, + enable => true, + hasrestart => true, + hasstatus => false, + pattern => '/usr/bin/gunicorn', + } } } - } diff --git a/manifests/init.pp b/manifests/init.pp index c4e469d..574573b 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -35,10 +35,11 @@ # class python ( $version = 'system', - $pip = false, - $dev = false, - $virtualenv = false, - $gunicorn = false + $pip = false, + $dev = false, + $virtualenv = false, + $gunicorn = false, + $manage_gunicorn = false ) { # Module compatibility check diff --git a/manifests/install.pp b/manifests/install.pp index 415092e..caead49 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -32,11 +32,12 @@ class python::install { package { 'python-virtualenv': ensure => $venv_ensure } - $gunicorn_ensure = $python::gunicorn ? { - true => present, - default => absent, + if $python::manage_gunicorn { + $gunicorn_ensure = $python::gunicorn ? { + true => present, + default => absent, + } + package { 'gunicorn': ensure => $gunicorn_ensure } } - package { 'gunicorn': ensure => $gunicorn_ensure } - } -- cgit v1.2.3 From fdf81012ea5f3d8124c86f41d91e4e97f769bc80 Mon Sep 17 00:00:00 2001 From: Daniel Lawrence Date: Fri, 29 Nov 2013 22:23:23 +1100 Subject: added manage_gunicorn docs --- Modulefile | 2 +- README.md | 2 ++ manifests/init.pp | 5 ++++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Modulefile b/Modulefile index 82069d4..171490c 100644 --- a/Modulefile +++ b/Modulefile @@ -1,5 +1,5 @@ name 'stankevich-python' -version '1.2.0' +version '1.3.0' author 'Sergey Stankevich' license 'Apache License, Version 2.0' diff --git a/README.md b/README.md index 751376a..6aa0c98 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,8 @@ Installs and manages python, python-dev, python-virtualenv and Gunicorn. **gunicorn** - Install Gunicorn. Default: false +**manage_gunicorn** - Allow Installation / Removal of Gunicorn. Default: true + class { 'python': version => 'system', dev => true, diff --git a/manifests/init.pp b/manifests/init.pp index 574573b..74244e1 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -19,6 +19,9 @@ # [*gunicorn*] # Install Gunicorn. Default: false # +# [*manage_gunicorn*] +# Allow Installation / Removal of Gunicorn. Default: true +# # === Examples # # class { 'python': @@ -39,7 +42,7 @@ class python ( $dev = false, $virtualenv = false, $gunicorn = false, - $manage_gunicorn = false + $manage_gunicorn = true ) { # Module compatibility check -- cgit v1.2.3 From 4781e59cc6ccf2499100bb1e35f862dc3f3af460 Mon Sep 17 00:00:00 2001 From: Phil Sturgeon Date: Fri, 6 Dec 2013 15:23:56 -0500 Subject: Fix deprecation warnings in template --- templates/gunicorn.erb | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/templates/gunicorn.erb b/templates/gunicorn.erb index 1a96531..99481e7 100644 --- a/templates/gunicorn.erb +++ b/templates/gunicorn.erb @@ -1,36 +1,36 @@ CONFIG = { -<% if mode == 'django' -%> +<% if @mode == 'django' -%> 'mode': 'django', <% else -%> 'mode': 'wsgi', <% end -%> -<% if virtualenv -%> +<% if @virtualenv -%> 'environment': { -<% if environment -%> - 'ENVIRONMENT': '<%= environment %>', +<% if @environment -%> + 'ENVIRONMENT': '<%= @environment %>', <% end -%> - 'PYTHONPATH': '<%= virtualenv %>' + 'PYTHONPATH': '<%= @virtualenv %>' }, <% end -%> - 'working_dir': '<%= dir %>', + 'working_dir': '<%= @dir %>', 'user': 'www-data', 'group': 'www-data', -<% if virtualenv -%> - 'python': '<%= virtualenv %>/bin/python', +<% if @virtualenv -%> + 'python': '<%= @virtualenv %>/bin/python', <% else -%> 'python': '/usr/bin/python', <% end -%> 'args': ( -<% if !virtualenv and !bind -%> - '--bind=unix:/tmp/gunicorn-<%= name %>.socket', -<% elsif virtualenv and !bind -%> - '--bind=unix:<%= virtualenv %>/<%= name %>.socket', +<% if !@virtualenv and !@bind -%> + '--bind=unix:/tmp/gunicorn-<%= @name %>.socket', +<% elsif @virtualenv and !@bind -%> + '--bind=unix:<%= @virtualenv %>/<%= @name %>.socket', <% else -%> - '--bind=<%= bind %>', + '--bind=<%= @bind %>', <% end -%> '--workers=<%= @processorcount.to_i*2 %>', '--timeout=30', -<% if mode != 'django' -%> +<% if @mode != 'django' -%> 'app:app', <% end -%> ), -- cgit v1.2.3 From 4854c78b29be47d7e23c09774a8b017c607998f9 Mon Sep 17 00:00:00 2001 From: Phil Sturgeon Date: Fri, 6 Dec 2013 15:27:30 -0500 Subject: Updated version to 1.2.1 --- Modulefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modulefile b/Modulefile index 82069d4..5806e9d 100644 --- a/Modulefile +++ b/Modulefile @@ -1,5 +1,5 @@ name 'stankevich-python' -version '1.2.0' +version '1.2.1' author 'Sergey Stankevich' license 'Apache License, Version 2.0' -- cgit v1.2.3 From f7801a4b0d9ae58187891d124c21d269eae19ba5 Mon Sep 17 00:00:00 2001 From: Jarl Stefansson Date: Thu, 12 Dec 2013 14:00:03 -0500 Subject: Fix virtualenv, rebuild if not correct env --- manifests/virtualenv.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/virtualenv.pp b/manifests/virtualenv.pp index 95fe1f7..1a2b093 100644 --- a/manifests/virtualenv.pp +++ b/manifests/virtualenv.pp @@ -114,10 +114,10 @@ define python::virtualenv ( exec { "python_virtualenv_${venv_dir}": command => "mkdir -p ${venv_dir} ${proxy_command} && virtualenv ${system_pkgs_flag} -p ${python} ${venv_dir} && ${venv_dir}/bin/pip --log-file ${venv_dir}/pip.log install ${pypi_index} ${proxy_flag} --upgrade pip ${distribute_pkg}", user => $owner, - creates => "${venv_dir}/bin/activate", path => $path, cwd => "/tmp", environment => $environment, + unless => "grep '^[ \t]*VIRTUAL_ENV=[\'\"]*/tmp[\"\']*[ \t]*$' /tmp/bin/activate", #Unless activate exists and VIRTUAL_ENV is correct we re-create the virtualenv } if $requirements { -- cgit v1.2.3 From 37363c422b7525006abafd824493324868a5cd1a Mon Sep 17 00:00:00 2001 From: Jarl Stefansson Date: Fri, 13 Dec 2013 16:27:34 -0500 Subject: Fix syntax error --- manifests/virtualenv.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/virtualenv.pp b/manifests/virtualenv.pp index 1fb55d6..d8e3915 100644 --- a/manifests/virtualenv.pp +++ b/manifests/virtualenv.pp @@ -74,7 +74,7 @@ define python::virtualenv ( $group = 'root', $proxy = false, $environment = [], - $path = [ '/bin', '/usr/bin', '/usr/sbin','/usr/local/bin' ] + $path = [ '/bin', '/usr/bin', '/usr/sbin','/usr/local/bin' ], $cwd = undef, $timeout = 1800 ) { -- cgit v1.2.3 From 607b527a11657ddd24545ebc33f0c0984d4c0093 Mon Sep 17 00:00:00 2001 From: Jarl Stefansson Date: Tue, 17 Dec 2013 16:05:05 -0500 Subject: Pip needs log argument not log-file. --- manifests/requirements.pp | 2 +- manifests/virtualenv.pp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/manifests/requirements.pp b/manifests/requirements.pp index 60c5b6c..ee44fa4 100644 --- a/manifests/requirements.pp +++ b/manifests/requirements.pp @@ -90,7 +90,7 @@ define python::requirements ( exec { "python_requirements${name}": provider => shell, - command => "${pip_env} --log-file ${cwd}/pip.log install ${proxy_flag} ${src_flag} -r ${requirements}", + command => "${pip_env} --log ${cwd}/pip.log install ${proxy_flag} ${src_flag} -r ${requirements}", refreshonly => true, timeout => 1800, user => $owner, diff --git a/manifests/virtualenv.pp b/manifests/virtualenv.pp index d8e3915..bc7141c 100644 --- a/manifests/virtualenv.pp +++ b/manifests/virtualenv.pp @@ -120,7 +120,7 @@ define python::virtualenv ( } exec { "python_virtualenv_${venv_dir}": - command => "mkdir -p ${venv_dir} ${proxy_command} && virtualenv ${system_pkgs_flag} -p ${python} ${venv_dir} && ${venv_dir}/bin/pip --log-file ${venv_dir}/pip.log install ${pypi_index} ${proxy_flag} --upgrade pip ${distribute_pkg}", + command => "mkdir -p ${venv_dir} ${proxy_command} && virtualenv ${system_pkgs_flag} -p ${python} ${venv_dir} && ${venv_dir}/bin/pip --log ${venv_dir}/pip.log install ${pypi_index} ${proxy_flag} --upgrade pip ${distribute_pkg}", user => $owner, path => $path, cwd => "/tmp", @@ -130,7 +130,7 @@ define python::virtualenv ( if $requirements { exec { "python_requirements_initial_install_${requirements}_${venv_dir}": - command => "${venv_dir}/bin/pip --log-file ${venv_dir}/pip.log install ${pypi_index} ${proxy_flag} -r ${requirements}", + command => "${venv_dir}/bin/pip --log ${venv_dir}/pip.log install ${pypi_index} ${proxy_flag} -r ${requirements}", refreshonly => true, timeout => $timeout, user => $owner, -- cgit v1.2.3 From c2a96f8dd40d75c6cf15518010e0a00889df6690 Mon Sep 17 00:00:00 2001 From: Sergey Stankevich Date: Wed, 18 Dec 2013 14:20:15 +0300 Subject: Version 1.3.0 --- Modulefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modulefile b/Modulefile index 5806e9d..171490c 100644 --- a/Modulefile +++ b/Modulefile @@ -1,5 +1,5 @@ name 'stankevich-python' -version '1.2.1' +version '1.3.0' author 'Sergey Stankevich' license 'Apache License, Version 2.0' -- cgit v1.2.3 From 071cc312167d3722bff723191fec229a071a03f4 Mon Sep 17 00:00:00 2001 From: Neil Saunders Date: Thu, 19 Dec 2013 17:43:51 +0000 Subject: Adding forcerefresh parameter --- manifests/requirements.pp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/manifests/requirements.pp b/manifests/requirements.pp index ee44fa4..5fa6eb9 100644 --- a/manifests/requirements.pp +++ b/manifests/requirements.pp @@ -27,6 +27,11 @@ # [*environment*] # Additional environment variables required to install the packages. Default: none # +# [*forceupdate*] +# Run a pip install requirements even if we don't receive an event from the +# requirements file - Useful for when the requirements file is written as part of a +# resource other than file (E.g vcsrepo) +# # === Examples # # python::requirements { '/var/www/project1/requirements.txt': @@ -47,7 +52,8 @@ define python::requirements ( $group = 'root', $proxy = false, $src = false, - $environment = [] + $environment = [], + $forceupdate = false, ) { if $virtualenv == 'system' and ($owner != 'root' or $group != 'root') { @@ -56,7 +62,7 @@ define python::requirements ( $cwd = $virtualenv ? { 'system' => '/', - default => "${virtualenv}", + default => $virtualenv, } $pip_env = $virtualenv ? { @@ -91,7 +97,7 @@ define python::requirements ( exec { "python_requirements${name}": provider => shell, command => "${pip_env} --log ${cwd}/pip.log install ${proxy_flag} ${src_flag} -r ${requirements}", - refreshonly => true, + refreshonly => !$forceupdate, timeout => 1800, user => $owner, subscribe => File[$requirements], -- cgit v1.2.3 From e92b2d2a7e1b20925a71d34dc83cd3bfa760fbf2 Mon Sep 17 00:00:00 2001 From: Sergey Stankevich Date: Thu, 19 Dec 2013 20:53:01 +0300 Subject: Version 1.3.1 --- Modulefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modulefile b/Modulefile index 171490c..c94af43 100644 --- a/Modulefile +++ b/Modulefile @@ -1,5 +1,5 @@ name 'stankevich-python' -version '1.3.0' +version '1.3.1' author 'Sergey Stankevich' license 'Apache License, Version 2.0' -- cgit v1.2.3 From 535115b9d1426a4d380dc4631fdd2944e0c29e88 Mon Sep 17 00:00:00 2001 From: Neil Saunders Date: Thu, 19 Dec 2013 18:06:25 +0000 Subject: Fixing lint issues as per http://docs.puppetlabs.com/guides/style_guide.html --- manifests/config.pp | 18 ++++++++++++++++-- manifests/install.pp | 15 +++++++++++++++ manifests/pip.pp | 20 ++++++++++---------- manifests/requirements.pp | 2 +- manifests/virtualenv.pp | 12 ++++++------ 5 files changed, 48 insertions(+), 19 deletions(-) diff --git a/manifests/config.pp b/manifests/config.pp index 49e5230..52c10be 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -1,3 +1,18 @@ +# == Define: python::config +# +# Optionally installs the gunicorn service +# +# === Examples +# +# include python::config +# +# === Authors +# +# Sergey Stankevich +# Ashley Penney +# Fotis Gimian +# + class python::config { Class['python::install'] -> Python::Pip <| |> @@ -19,5 +34,4 @@ class python::config { pattern => '/usr/bin/gunicorn', } } - -} +} \ No newline at end of file diff --git a/manifests/install.pp b/manifests/install.pp index 0d16659..bb5f090 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -1,3 +1,18 @@ +# == Define: python::install +# +# Installs core python packages +# +# === Examples +# +# include python::install +# +# === Authors +# +# Sergey Stankevich +# Ashley Penney +# Fotis Gimian +# + class python::install { $python = $python::version ? { diff --git a/manifests/pip.pp b/manifests/pip.pp index bcb7911..ebe549b 100644 --- a/manifests/pip.pp +++ b/manifests/pip.pp @@ -57,7 +57,7 @@ define python::pip ( $cwd = $virtualenv ? { 'system' => '/', - default => "${virtualenv}", + default => $virtualenv, } $pip_env = $virtualenv ? { @@ -88,26 +88,26 @@ define python::pip ( case $ensure { present: { exec { "pip_install_${name}": - command => "$pip_env --log ${cwd}/pip.log install $install_args ${proxy_flag} ${source}", - unless => "$pip_env freeze | grep -i -e ${grep_regex}", + command => "${pip_env} --log ${cwd}/pip.log install ${install_args} ${proxy_flag} ${source}", + unless => "${pip_env} freeze | grep -i -e ${grep_regex}", user => $owner, environment => $environment, - path => ["/usr/local/bin","/usr/bin","/bin", "/usr/sbin"], + path => ['/usr/local/bin','/usr/bin','/bin', '/usr/sbin'], } } latest: { exec { "pip_install_${name}": - command => "$pip_env --log ${cwd}/pip.log install --upgrade ${proxy_flag} ${source}", + command => "${pip_env} --log ${cwd}/pip.log install --upgrade ${proxy_flag} ${source}", user => $owner, environment => $environment, - path => ["/usr/local/bin","/usr/bin","/bin", "/usr/sbin"], + path => ['/usr/local/bin','/usr/bin','/bin', '/usr/sbin'], } } latest: { exec { "pip_install_${name}": - command => "$pip_env --log ${cwd}/pip.log install -U $install_args ${proxy_flag} ${source}", + command => "${pip_env} --log ${cwd}/pip.log install -U ${install_args} ${proxy_flag} ${source}", user => $owner, environment => $environment, } @@ -115,11 +115,11 @@ define python::pip ( default: { exec { "pip_uninstall_${name}": - command => "echo y | $pip_env uninstall $uninstall_args ${proxy_flag} ${name}", - onlyif => "$pip_env freeze | grep -i -e ${grep_regex}", + command => "echo y | ${pip_env} uninstall ${uninstall_args} ${proxy_flag} ${name}", + onlyif => "${pip_env} freeze | grep -i -e ${grep_regex}", user => $owner, environment => $environment, - path => ["/usr/local/bin","/usr/bin","/bin", "/usr/sbin"], + path => ['/usr/local/bin','/usr/bin','/bin', '/usr/sbin'], } } } diff --git a/manifests/requirements.pp b/manifests/requirements.pp index ee44fa4..9769b13 100644 --- a/manifests/requirements.pp +++ b/manifests/requirements.pp @@ -56,7 +56,7 @@ define python::requirements ( $cwd = $virtualenv ? { 'system' => '/', - default => "${virtualenv}", + default => $virtualenv, } $pip_env = $virtualenv ? { diff --git a/manifests/virtualenv.pp b/manifests/virtualenv.pp index bc7141c..85fc67a 100644 --- a/manifests/virtualenv.pp +++ b/manifests/virtualenv.pp @@ -98,7 +98,7 @@ define python::virtualenv ( default => "&& export http_proxy=${proxy}", } - # Virtualenv versions prior to 1.7 do not support the + # Virtualenv versions prior to 1.7 do not support the # --system-site-packages flag, default off for prior versions # Prior to version 1.7 the default was equal to --system-site-packages # and the flag --no-site-packages had to be passed to do the opposite @@ -120,12 +120,12 @@ define python::virtualenv ( } exec { "python_virtualenv_${venv_dir}": - command => "mkdir -p ${venv_dir} ${proxy_command} && virtualenv ${system_pkgs_flag} -p ${python} ${venv_dir} && ${venv_dir}/bin/pip --log ${venv_dir}/pip.log install ${pypi_index} ${proxy_flag} --upgrade pip ${distribute_pkg}", - user => $owner, - path => $path, - cwd => "/tmp", + command => "mkdir -p ${venv_dir} ${proxy_command} && virtualenv ${system_pkgs_flag} -p ${python} ${venv_dir} && ${venv_dir}/bin/pip --log ${venv_dir}/pip.log install ${pypi_index} ${proxy_flag} --upgrade pip ${distribute_pkg}", + user => $owner, + path => $path, + cwd => '/tmp', environment => $environment, - unless => "grep '^[ \t]*VIRTUAL_ENV=[\'\"]*/tmp[\"\']*[ \t]*$' /tmp/bin/activate", #Unless activate exists and VIRTUAL_ENV is correct we re-create the virtualenv + unless => "grep '^[ \t]*VIRTUAL_ENV=[\'\"]*/tmp[\"\']*[ \t]*$' /tmp/bin/activate", #Unless activate exists and VIRTUAL_ENV is correct we re-create the virtualenv } if $requirements { -- cgit v1.2.3 From ed1fed8d5cef752603ee469d2a093bd9218488ea Mon Sep 17 00:00:00 2001 From: Felipe Reyes Date: Thu, 26 Dec 2013 16:57:08 -0300 Subject: Expose user/group config to configure gunicorn gunicorn setup was forcing users to run their processes with the user www-data which isn't available in all distributions (for instance Fedora Linux) and it's a good practice to run each website under different users to reduce security issues --- manifests/gunicorn.pp | 4 ++++ templates/gunicorn.erb | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/manifests/gunicorn.pp b/manifests/gunicorn.pp index 13f4872..159afa3 100644 --- a/manifests/gunicorn.pp +++ b/manifests/gunicorn.pp @@ -37,6 +37,8 @@ # dir => '/var/www/project1/current', # bind => 'unix:/tmp/gunicorn.socket', # environment => 'prod', +# owner => 'www-data', +# group => 'www-data', # template => 'python/gunicorn.erb', # } # @@ -53,6 +55,8 @@ define python::gunicorn ( $dir = false, $bind = false, $environment = false, + $owner = 'www-data', + $group = 'www-data', $template = 'python/gunicorn.erb', ) { diff --git a/templates/gunicorn.erb b/templates/gunicorn.erb index 99481e7..10f81fa 100644 --- a/templates/gunicorn.erb +++ b/templates/gunicorn.erb @@ -13,8 +13,8 @@ CONFIG = { }, <% end -%> 'working_dir': '<%= @dir %>', - 'user': 'www-data', - 'group': 'www-data', + 'user': '<%= @owner %>', + 'group': '<%= @group %>', <% if @virtualenv -%> 'python': '<%= @virtualenv %>/bin/python', <% else -%> -- cgit v1.2.3 From 80ee7bcdf5ca4287432da9d2e06c3bb6c1dd8a91 Mon Sep 17 00:00:00 2001 From: Sergey Stankevich Date: Mon, 30 Dec 2013 17:52:27 +0300 Subject: Version 1.4.0 --- Modulefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modulefile b/Modulefile index c94af43..be19691 100644 --- a/Modulefile +++ b/Modulefile @@ -1,5 +1,5 @@ name 'stankevich-python' -version '1.3.1' +version '1.4.0' author 'Sergey Stankevich' license 'Apache License, Version 2.0' -- cgit v1.2.3 From 0b4438b64eb2f24f9aff75116cbefb3fc85b5241 Mon Sep 17 00:00:00 2001 From: Jarl Stefansson Date: Wed, 1 Jan 2014 12:44:24 -0500 Subject: Fix path for unless statement. https://github.com/stankevich/puppet-python/issues/46 --- manifests/virtualenv.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/virtualenv.pp b/manifests/virtualenv.pp index bc7141c..f74cc4f 100644 --- a/manifests/virtualenv.pp +++ b/manifests/virtualenv.pp @@ -125,7 +125,7 @@ define python::virtualenv ( path => $path, cwd => "/tmp", environment => $environment, - unless => "grep '^[ \t]*VIRTUAL_ENV=[\'\"]*/tmp[\"\']*[ \t]*$' /tmp/bin/activate", #Unless activate exists and VIRTUAL_ENV is correct we re-create the virtualenv + unless => "grep '^[ \t]*VIRTUAL_ENV=[\'\"]*/tmp[\"\']*[ \t]*$' ${venv_dir}/bin/activate", #Unless activate exists and VIRTUAL_ENV is correct we re-create the virtualenv } if $requirements { -- cgit v1.2.3 From ae04aad7b8fd5f88f6bc379dbabd21000dcb9a85 Mon Sep 17 00:00:00 2001 From: Jarl Stefansson Date: Thu, 2 Jan 2014 11:36:39 -0500 Subject: Add flag to disable wheels for python 2.6 Setuptools 0.8 is required for pip wheel support, Python 2.6 and older only support setuptools 0.7, we therefor need to disable wheels. --- manifests/virtualenv.pp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/manifests/virtualenv.pp b/manifests/virtualenv.pp index f74cc4f..3a7997e 100644 --- a/manifests/virtualenv.pp +++ b/manifests/virtualenv.pp @@ -98,7 +98,7 @@ define python::virtualenv ( default => "&& export http_proxy=${proxy}", } - # Virtualenv versions prior to 1.7 do not support the + # Virtualenv versions prior to 1.7 do not support the # --system-site-packages flag, default off for prior versions # Prior to version 1.7 the default was equal to --system-site-packages # and the flag --no-site-packages had to be passed to do the opposite @@ -110,6 +110,14 @@ define python::virtualenv ( $system_pkgs_flag = '' } + # Python 2.6 and older don't support setuptools > 0.8 which is required + # for pip wheel support, it therefor requires --no-use-wheel flag + if ( versioncmp($::python_version,'2.6') > 0 ) { + $wheel_support_flag = '--no-use-wheel' + } else { + $wheel_support_flag = '' + } + $distribute_pkg = $distribute ? { true => 'distribute', default => '', @@ -120,7 +128,7 @@ define python::virtualenv ( } exec { "python_virtualenv_${venv_dir}": - command => "mkdir -p ${venv_dir} ${proxy_command} && virtualenv ${system_pkgs_flag} -p ${python} ${venv_dir} && ${venv_dir}/bin/pip --log ${venv_dir}/pip.log install ${pypi_index} ${proxy_flag} --upgrade pip ${distribute_pkg}", + command => "mkdir -p ${venv_dir} ${proxy_command} && virtualenv ${system_pkgs_flag} -p ${python} ${venv_dir} && ${venv_dir}/bin/pip --log ${venv_dir}/pip.log install ${pypi_index} ${proxy_flag} ${wheel_support_flag} --upgrade pip ${distribute_pkg}", user => $owner, path => $path, cwd => "/tmp", @@ -130,7 +138,7 @@ define python::virtualenv ( if $requirements { exec { "python_requirements_initial_install_${requirements}_${venv_dir}": - command => "${venv_dir}/bin/pip --log ${venv_dir}/pip.log install ${pypi_index} ${proxy_flag} -r ${requirements}", + command => "${venv_dir}/bin/pip --log ${venv_dir}/pip.log install ${pypi_index} ${proxy_flag} ${wheel_support_flag} -r ${requirements}", refreshonly => true, timeout => $timeout, user => $owner, -- cgit v1.2.3 From 5dfe3e57489790823928a90363d7ab81500ce5e8 Mon Sep 17 00:00:00 2001 From: Jarl Stefansson Date: Thu, 2 Jan 2014 12:45:56 -0500 Subject: Fix wheel flag for pip commands Python 2.6 does not support setuptools < 0.8 which is required for pip wheel support, older versions need to use the --no-use-wheel flag --- manifests/pip.pp | 16 ++++++++++++---- manifests/virtualenv.pp | 2 +- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/manifests/pip.pp b/manifests/pip.pp index bcb7911..ba83658 100644 --- a/manifests/pip.pp +++ b/manifests/pip.pp @@ -70,6 +70,14 @@ define python::pip ( default => "--proxy=${proxy}", } + # Python 2.6 and older don't support setuptools > 0.8 which is required + # for pip wheel support, pip therefor requires --no-use-wheel flag + if ( versioncmp($::python_version,'2.6') > 0 ) { + $wheel_support_flag = '--no-use-wheel' + } else { + $wheel_support_flag = '' + } + $grep_regex = $name ? { /==/ => "^${name}\$", default => "^${name}==", @@ -88,7 +96,7 @@ define python::pip ( case $ensure { present: { exec { "pip_install_${name}": - command => "$pip_env --log ${cwd}/pip.log install $install_args ${proxy_flag} ${source}", + command => "$pip_env --log ${cwd}/pip.log install $install_args ${wheel_support_flag} ${proxy_flag} ${source}", unless => "$pip_env freeze | grep -i -e ${grep_regex}", user => $owner, environment => $environment, @@ -98,7 +106,7 @@ define python::pip ( latest: { exec { "pip_install_${name}": - command => "$pip_env --log ${cwd}/pip.log install --upgrade ${proxy_flag} ${source}", + command => "$pip_env --log ${cwd}/pip.log install --upgrade ${wheel_support_flag} ${proxy_flag} ${source}", user => $owner, environment => $environment, path => ["/usr/local/bin","/usr/bin","/bin", "/usr/sbin"], @@ -107,7 +115,7 @@ define python::pip ( latest: { exec { "pip_install_${name}": - command => "$pip_env --log ${cwd}/pip.log install -U $install_args ${proxy_flag} ${source}", + command => "$pip_env --log ${cwd}/pip.log install -U $install_args ${wheel_support_flag} ${proxy_flag} ${source}", user => $owner, environment => $environment, } @@ -115,7 +123,7 @@ define python::pip ( default: { exec { "pip_uninstall_${name}": - command => "echo y | $pip_env uninstall $uninstall_args ${proxy_flag} ${name}", + command => "echo y | $pip_env uninstall $uninstall_args ${wheel_support_flag} ${proxy_flag} ${name}", onlyif => "$pip_env freeze | grep -i -e ${grep_regex}", user => $owner, environment => $environment, diff --git a/manifests/virtualenv.pp b/manifests/virtualenv.pp index 3a7997e..7b4b53c 100644 --- a/manifests/virtualenv.pp +++ b/manifests/virtualenv.pp @@ -111,7 +111,7 @@ define python::virtualenv ( } # Python 2.6 and older don't support setuptools > 0.8 which is required - # for pip wheel support, it therefor requires --no-use-wheel flag + # for pip wheel support, pip therefor requires --no-use-wheel flag if ( versioncmp($::python_version,'2.6') > 0 ) { $wheel_support_flag = '--no-use-wheel' } else { -- cgit v1.2.3 From 6d88eb88f3ec00655a25f9cb83efd58f293ef4fe Mon Sep 17 00:00:00 2001 From: Jarl Stefansson Date: Thu, 2 Jan 2014 15:25:27 -0500 Subject: Fix wheel support and pip version compatability Fix wheel support and compatability for older pip versions by detecting suppport when running the pip command inside a virtualenv. --- lib/facter/pip_version.rb | 2 +- manifests/pip.pp | 20 ++++++++++---------- manifests/virtualenv.pp | 7 ++++--- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/lib/facter/pip_version.rb b/lib/facter/pip_version.rb index 48dd0bf..131d1f9 100644 --- a/lib/facter/pip_version.rb +++ b/lib/facter/pip_version.rb @@ -5,7 +5,7 @@ pkg = Puppet::Type.type(:package).new(:name => "python-pip") Facter.add("pip_version") do has_weight 100 setcode do - Facter::Util::Resolution.exec('pip --version') + /^pip (\d+\.\d+\.?\d*).*$/.match(Facter::Util::Resolution.exec('pip --version'))[1] end end diff --git a/manifests/pip.pp b/manifests/pip.pp index ba83658..a818e23 100644 --- a/manifests/pip.pp +++ b/manifests/pip.pp @@ -70,13 +70,6 @@ define python::pip ( default => "--proxy=${proxy}", } - # Python 2.6 and older don't support setuptools > 0.8 which is required - # for pip wheel support, pip therefor requires --no-use-wheel flag - if ( versioncmp($::python_version,'2.6') > 0 ) { - $wheel_support_flag = '--no-use-wheel' - } else { - $wheel_support_flag = '' - } $grep_regex = $name ? { /==/ => "^${name}\$", @@ -93,10 +86,17 @@ define python::pip ( default => "${url}#egg=${egg_name}", } + # Python 2.6 and older don't support setuptools/distribute > 0.8 which is required + # for pip wheel support, pip therefor requires --no-use-wheel flag if the + # pip version is more recent thatn 1.4.1 but using an old python or + # setuputils/distribute version + # To check for this we test for wheel parameter using help and then using + # version, this makes sure we only use wheels if they are supported + case $ensure { present: { exec { "pip_install_${name}": - command => "$pip_env --log ${cwd}/pip.log install $install_args ${wheel_support_flag} ${proxy_flag} ${source}", + command => "$pip_env wheel --help && pip wheel --version || wheel_support_flag="--no-use-wheel"; $pip_env --log ${cwd}/pip.log install $install_args \$wheel_support_flag ${proxy_flag} ${source}", unless => "$pip_env freeze | grep -i -e ${grep_regex}", user => $owner, environment => $environment, @@ -106,7 +106,7 @@ define python::pip ( latest: { exec { "pip_install_${name}": - command => "$pip_env --log ${cwd}/pip.log install --upgrade ${wheel_support_flag} ${proxy_flag} ${source}", + command => "$pip_env wheel --help && pip wheel --version || wheel_support_flag="--no-use-wheel"; $pip_env x--log ${cwd}/pip.log install --upgrade \$wheel_support_flag ${proxy_flag} ${source}", user => $owner, environment => $environment, path => ["/usr/local/bin","/usr/bin","/bin", "/usr/sbin"], @@ -115,7 +115,7 @@ define python::pip ( latest: { exec { "pip_install_${name}": - command => "$pip_env --log ${cwd}/pip.log install -U $install_args ${wheel_support_flag} ${proxy_flag} ${source}", + command => "$pip_env wheel --help && pip wheel --version || wheel_support_flag="--no-use-wheel"; $pip_env --log ${cwd}/pip.log install -U $install_args \$wheel_support_flag ${proxy_flag} ${source}", user => $owner, environment => $environment, } diff --git a/manifests/virtualenv.pp b/manifests/virtualenv.pp index 7b4b53c..7b39212 100644 --- a/manifests/virtualenv.pp +++ b/manifests/virtualenv.pp @@ -110,9 +110,10 @@ define python::virtualenv ( $system_pkgs_flag = '' } - # Python 2.6 and older don't support setuptools > 0.8 which is required - # for pip wheel support, pip therefor requires --no-use-wheel flag - if ( versioncmp($::python_version,'2.6') > 0 ) { + # Python 2.6 and older don't support setuptools/distribute > 0.8 which is required + # for pip wheel support, pip therefor requires --no-use-wheel flag if the + # version is newer than 1.4.1 when they added wheels + if (( versioncmp($::python_version,'2.6') > 0 and ( versioncmp($::pip_version,'1.4.1') > 0)) { $wheel_support_flag = '--no-use-wheel' } else { $wheel_support_flag = '' -- cgit v1.2.3 From a49582f22a71baf746ff06c10850a207a99a9750 Mon Sep 17 00:00:00 2001 From: Jarl Stefansson Date: Thu, 2 Jan 2014 15:32:51 -0500 Subject: Fix quoting of exec commands to use single quotes --- manifests/pip.pp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/manifests/pip.pp b/manifests/pip.pp index a818e23..6c0425e 100644 --- a/manifests/pip.pp +++ b/manifests/pip.pp @@ -96,7 +96,7 @@ define python::pip ( case $ensure { present: { exec { "pip_install_${name}": - command => "$pip_env wheel --help && pip wheel --version || wheel_support_flag="--no-use-wheel"; $pip_env --log ${cwd}/pip.log install $install_args \$wheel_support_flag ${proxy_flag} ${source}", + command => "$pip_env wheel --help && pip wheel --version || wheel_support_flag='--no-use-wheel'; $pip_env --log ${cwd}/pip.log install $install_args \$wheel_support_flag ${proxy_flag} ${source}", unless => "$pip_env freeze | grep -i -e ${grep_regex}", user => $owner, environment => $environment, @@ -106,7 +106,7 @@ define python::pip ( latest: { exec { "pip_install_${name}": - command => "$pip_env wheel --help && pip wheel --version || wheel_support_flag="--no-use-wheel"; $pip_env x--log ${cwd}/pip.log install --upgrade \$wheel_support_flag ${proxy_flag} ${source}", + command => "$pip_env wheel --help && pip wheel --version || wheel_support_flag='--no-use-wheel'; $pip_env x--log ${cwd}/pip.log install --upgrade \$wheel_support_flag ${proxy_flag} ${source}", user => $owner, environment => $environment, path => ["/usr/local/bin","/usr/bin","/bin", "/usr/sbin"], @@ -115,7 +115,7 @@ define python::pip ( latest: { exec { "pip_install_${name}": - command => "$pip_env wheel --help && pip wheel --version || wheel_support_flag="--no-use-wheel"; $pip_env --log ${cwd}/pip.log install -U $install_args \$wheel_support_flag ${proxy_flag} ${source}", + command => "$pip_env wheel --help && pip wheel --version || wheel_support_flag='--no-use-wheel'; $pip_env --log ${cwd}/pip.log install -U $install_args \$wheel_support_flag ${proxy_flag} ${source}", user => $owner, environment => $environment, } -- cgit v1.2.3 From 784a8bca85023490169bf9663740419caea776a0 Mon Sep 17 00:00:00 2001 From: Jarl Stefansson Date: Thu, 2 Jan 2014 15:44:44 -0500 Subject: Fix syntax error in conditional statement --- manifests/virtualenv.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/virtualenv.pp b/manifests/virtualenv.pp index 7b39212..3e61e1f 100644 --- a/manifests/virtualenv.pp +++ b/manifests/virtualenv.pp @@ -113,7 +113,7 @@ define python::virtualenv ( # Python 2.6 and older don't support setuptools/distribute > 0.8 which is required # for pip wheel support, pip therefor requires --no-use-wheel flag if the # version is newer than 1.4.1 when they added wheels - if (( versioncmp($::python_version,'2.6') > 0 and ( versioncmp($::pip_version,'1.4.1') > 0)) { + if (( versioncmp($::python_version,'2.6') > 0 ) and ( versioncmp($::pip_version,'1.4.1') > 0)) { $wheel_support_flag = '--no-use-wheel' } else { $wheel_support_flag = '' -- cgit v1.2.3 From 10633ecbde7bd269e0e02d1ae5ba5313bc00c24b Mon Sep 17 00:00:00 2001 From: Jarl Stefansson Date: Thu, 2 Jan 2014 15:56:38 -0500 Subject: Fix handling of wheel support for initial pip --- manifests/pip.pp | 6 +++--- manifests/virtualenv.pp | 18 ++++++++---------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/manifests/pip.pp b/manifests/pip.pp index 6c0425e..5849ca9 100644 --- a/manifests/pip.pp +++ b/manifests/pip.pp @@ -86,9 +86,9 @@ define python::pip ( default => "${url}#egg=${egg_name}", } - # Python 2.6 and older don't support setuptools/distribute > 0.8 which is required - # for pip wheel support, pip therefor requires --no-use-wheel flag if the - # pip version is more recent thatn 1.4.1 but using an old python or + # Python 2.6 and older does not support setuptools/distribute > 0.8 which + # is required for pip wheel support, pip therefor requires --no-use-wheel flag + # if the # pip version is more recent than 1.4.1 but using an old python or # setuputils/distribute version # To check for this we test for wheel parameter using help and then using # version, this makes sure we only use wheels if they are supported diff --git a/manifests/virtualenv.pp b/manifests/virtualenv.pp index 3e61e1f..94bbd15 100644 --- a/manifests/virtualenv.pp +++ b/manifests/virtualenv.pp @@ -110,15 +110,6 @@ define python::virtualenv ( $system_pkgs_flag = '' } - # Python 2.6 and older don't support setuptools/distribute > 0.8 which is required - # for pip wheel support, pip therefor requires --no-use-wheel flag if the - # version is newer than 1.4.1 when they added wheels - if (( versioncmp($::python_version,'2.6') > 0 ) and ( versioncmp($::pip_version,'1.4.1') > 0)) { - $wheel_support_flag = '--no-use-wheel' - } else { - $wheel_support_flag = '' - } - $distribute_pkg = $distribute ? { true => 'distribute', default => '', @@ -128,8 +119,15 @@ define python::virtualenv ( default => "-i ${index}", } + # Python 2.6 and older does not support setuptools/distribute > 0.8 which + # is required for pip wheel support, pip therefor requires --no-use-wheel flag + # if the # pip version is more recent than 1.4.1 but using an old python or + # setuputils/distribute version + # To check for this we test for wheel parameter using help and then using + # version, this makes sure we only use wheels if they are supported + exec { "python_virtualenv_${venv_dir}": - command => "mkdir -p ${venv_dir} ${proxy_command} && virtualenv ${system_pkgs_flag} -p ${python} ${venv_dir} && ${venv_dir}/bin/pip --log ${venv_dir}/pip.log install ${pypi_index} ${proxy_flag} ${wheel_support_flag} --upgrade pip ${distribute_pkg}", + command => "mkdir -p ${venv_dir} ${proxy_command} && virtualenv ${system_pkgs_flag} -p ${python} ${venv_dir} && ${venv_dir}/bin/pip $pip_env wheel --help && ${venv_dir}/bin/pip wheel --version || wheel_support_flag='--no-use-wheel'; ${venv_dir}/bin/pip --log ${venv_dir}/pip.log install ${pypi_index} ${proxy_flag} \$wheel_support_flag --upgrade pip ${distribute_pkg}", user => $owner, path => $path, cwd => "/tmp", -- cgit v1.2.3 From 44acbef424819e226bec875aabf3db44a06b7015 Mon Sep 17 00:00:00 2001 From: Jarl Stefansson Date: Thu, 2 Jan 2014 16:01:36 -0500 Subject: Fix simple typo --- manifests/pip.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/pip.pp b/manifests/pip.pp index 5849ca9..5e287f7 100644 --- a/manifests/pip.pp +++ b/manifests/pip.pp @@ -106,7 +106,7 @@ define python::pip ( latest: { exec { "pip_install_${name}": - command => "$pip_env wheel --help && pip wheel --version || wheel_support_flag='--no-use-wheel'; $pip_env x--log ${cwd}/pip.log install --upgrade \$wheel_support_flag ${proxy_flag} ${source}", + command => "$pip_env wheel --help && pip wheel --version || wheel_support_flag='--no-use-wheel'; $pip_env --log ${cwd}/pip.log install --upgrade \$wheel_support_flag ${proxy_flag} ${source}", user => $owner, environment => $environment, path => ["/usr/local/bin","/usr/bin","/bin", "/usr/sbin"], -- cgit v1.2.3 From f2266d7070a3c6f1a07b7746448c647e3bc37b88 Mon Sep 17 00:00:00 2001 From: Jarl Stefansson Date: Thu, 2 Jan 2014 16:14:57 -0500 Subject: Fix bash logic false positives --- manifests/pip.pp | 6 +++--- manifests/virtualenv.pp | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/manifests/pip.pp b/manifests/pip.pp index 5e287f7..5c218c5 100644 --- a/manifests/pip.pp +++ b/manifests/pip.pp @@ -96,7 +96,7 @@ define python::pip ( case $ensure { present: { exec { "pip_install_${name}": - command => "$pip_env wheel --help && pip wheel --version || wheel_support_flag='--no-use-wheel'; $pip_env --log ${cwd}/pip.log install $install_args \$wheel_support_flag ${proxy_flag} ${source}", + command => "$pip_env wheel --help && (pip wheel --version || wheel_support_flag='--no-use-wheel'); $pip_env --log ${cwd}/pip.log install $install_args \$wheel_support_flag ${proxy_flag} ${source}", unless => "$pip_env freeze | grep -i -e ${grep_regex}", user => $owner, environment => $environment, @@ -106,7 +106,7 @@ define python::pip ( latest: { exec { "pip_install_${name}": - command => "$pip_env wheel --help && pip wheel --version || wheel_support_flag='--no-use-wheel'; $pip_env --log ${cwd}/pip.log install --upgrade \$wheel_support_flag ${proxy_flag} ${source}", + command => "$pip_env wheel --help && (pip wheel --version || wheel_support_flag='--no-use-wheel'); $pip_env --log ${cwd}/pip.log install --upgrade \$wheel_support_flag ${proxy_flag} ${source}", user => $owner, environment => $environment, path => ["/usr/local/bin","/usr/bin","/bin", "/usr/sbin"], @@ -115,7 +115,7 @@ define python::pip ( latest: { exec { "pip_install_${name}": - command => "$pip_env wheel --help && pip wheel --version || wheel_support_flag='--no-use-wheel'; $pip_env --log ${cwd}/pip.log install -U $install_args \$wheel_support_flag ${proxy_flag} ${source}", + command => "$pip_env wheel --help && (pip wheel --version || wheel_support_flag='--no-use-wheel'); $pip_env --log ${cwd}/pip.log install -U $install_args \$wheel_support_flag ${proxy_flag} ${source}", user => $owner, environment => $environment, } diff --git a/manifests/virtualenv.pp b/manifests/virtualenv.pp index 94bbd15..9c9502d 100644 --- a/manifests/virtualenv.pp +++ b/manifests/virtualenv.pp @@ -127,7 +127,7 @@ define python::virtualenv ( # version, this makes sure we only use wheels if they are supported exec { "python_virtualenv_${venv_dir}": - command => "mkdir -p ${venv_dir} ${proxy_command} && virtualenv ${system_pkgs_flag} -p ${python} ${venv_dir} && ${venv_dir}/bin/pip $pip_env wheel --help && ${venv_dir}/bin/pip wheel --version || wheel_support_flag='--no-use-wheel'; ${venv_dir}/bin/pip --log ${venv_dir}/pip.log install ${pypi_index} ${proxy_flag} \$wheel_support_flag --upgrade pip ${distribute_pkg}", + command => "mkdir -p ${venv_dir} ${proxy_command} && virtualenv ${system_pkgs_flag} -p ${python} ${venv_dir} && ${venv_dir}/bin/pip $pip_env wheel --help && (${venv_dir}/bin/pip wheel --version || wheel_support_flag='--no-use-wheel'); ${venv_dir}/bin/pip --log ${venv_dir}/pip.log install ${pypi_index} ${proxy_flag} \$wheel_support_flag --upgrade pip ${distribute_pkg}", user => $owner, path => $path, cwd => "/tmp", -- cgit v1.2.3 From 0e72400bfd33df651c23f2f7c71c3c5cf8bfe815 Mon Sep 17 00:00:00 2001 From: Davide Mendolia Date: Thu, 2 Jan 2014 23:11:52 +0100 Subject: Replace operatingsystem test for osfamily to increase os support --- manifests/init.pp | 4 ++-- manifests/install.pp | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 9fe0420..54dae45 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -44,8 +44,8 @@ class python ( ) { # Module compatibility check - $compatible = [ 'Debian', 'Ubuntu', 'CentOS', 'RedHat', 'Scientific' ] - if ! ($::operatingsystem in $compatible) { + $compatible = [ 'debian', 'redhat'] + if ! ($::osfamily in $compatible) { fail("Module is not compatible with ${::operatingsystem}") } diff --git a/manifests/install.pp b/manifests/install.pp index bb5f090..dc9bd76 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -20,9 +20,9 @@ class python::install { default => "python${python::version}", } - $pythondev = $::operatingsystem ? { - /(?i:RedHat|CentOS|Fedora|Scientific)/ => "${python}-devel", - /(?i:Debian|Ubuntu)/ => "${python}-dev" + $pythondev = $::osfamily ? { + redhat => "${python}-devel", + debian => "${python}-dev" } $dev_ensure = $python::dev ? { -- cgit v1.2.3 From e165f319501eda83ca1e996fa2c4cd06341657f9 Mon Sep 17 00:00:00 2001 From: Davide Mendolia Date: Thu, 2 Jan 2014 23:49:12 +0100 Subject: Fixed osfamily name --- manifests/init.pp | 2 +- manifests/install.pp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 54dae45..451bdda 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -44,7 +44,7 @@ class python ( ) { # Module compatibility check - $compatible = [ 'debian', 'redhat'] + $compatible = [ 'Debian', 'RedHat'] if ! ($::osfamily in $compatible) { fail("Module is not compatible with ${::operatingsystem}") } diff --git a/manifests/install.pp b/manifests/install.pp index dc9bd76..b2debcc 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -21,8 +21,8 @@ class python::install { } $pythondev = $::osfamily ? { - redhat => "${python}-devel", - debian => "${python}-dev" + RedHat => "${python}-devel", + Debian => "${python}-dev" } $dev_ensure = $python::dev ? { -- cgit v1.2.3 From 1087abd3ba21bcb5b33f7c40f07724c1b9a093eb Mon Sep 17 00:00:00 2001 From: Jarl Stefansson Date: Fri, 3 Jan 2014 09:34:04 -0500 Subject: Further fixes for pip 1.5 and wheel handling --- manifests/pip.pp | 6 +++--- manifests/virtualenv.pp | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/manifests/pip.pp b/manifests/pip.pp index 5c218c5..e9ab7cd 100644 --- a/manifests/pip.pp +++ b/manifests/pip.pp @@ -96,7 +96,7 @@ define python::pip ( case $ensure { present: { exec { "pip_install_${name}": - command => "$pip_env wheel --help && (pip wheel --version || wheel_support_flag='--no-use-wheel'); $pip_env --log ${cwd}/pip.log install $install_args \$wheel_support_flag ${proxy_flag} ${source}", + command => "$pip_env wheel --help > /dev/null 2>&1 && { pip wheel --version > /dev/null 2>&1 || wheel_support_flag='--no-use-wheel'; } ; $pip_env --log ${cwd}/pip.log install $install_args \$wheel_support_flag ${proxy_flag} ${source}", unless => "$pip_env freeze | grep -i -e ${grep_regex}", user => $owner, environment => $environment, @@ -106,7 +106,7 @@ define python::pip ( latest: { exec { "pip_install_${name}": - command => "$pip_env wheel --help && (pip wheel --version || wheel_support_flag='--no-use-wheel'); $pip_env --log ${cwd}/pip.log install --upgrade \$wheel_support_flag ${proxy_flag} ${source}", + command => "$pip_env wheel --help > /dev/null 2>&1&& { pip wheel --version > /dev/null 2>&1 || wheel_support_flag='--no-use-wheel'; } ; $pip_env --log ${cwd}/pip.log install --upgrade \$wheel_support_flag ${proxy_flag} ${source}", user => $owner, environment => $environment, path => ["/usr/local/bin","/usr/bin","/bin", "/usr/sbin"], @@ -115,7 +115,7 @@ define python::pip ( latest: { exec { "pip_install_${name}": - command => "$pip_env wheel --help && (pip wheel --version || wheel_support_flag='--no-use-wheel'); $pip_env --log ${cwd}/pip.log install -U $install_args \$wheel_support_flag ${proxy_flag} ${source}", + command => "$pip_env wheel --help > /dev/null 2>&1&& { pip wheel --version > /dev/null 2>&1 || wheel_support_flag='--no-use-wheel'; } ; $pip_env --log ${cwd}/pip.log install -U $install_args \$wheel_support_flag ${proxy_flag} ${source}", user => $owner, environment => $environment, } diff --git a/manifests/virtualenv.pp b/manifests/virtualenv.pp index 9c9502d..7a548a6 100644 --- a/manifests/virtualenv.pp +++ b/manifests/virtualenv.pp @@ -127,7 +127,7 @@ define python::virtualenv ( # version, this makes sure we only use wheels if they are supported exec { "python_virtualenv_${venv_dir}": - command => "mkdir -p ${venv_dir} ${proxy_command} && virtualenv ${system_pkgs_flag} -p ${python} ${venv_dir} && ${venv_dir}/bin/pip $pip_env wheel --help && (${venv_dir}/bin/pip wheel --version || wheel_support_flag='--no-use-wheel'); ${venv_dir}/bin/pip --log ${venv_dir}/pip.log install ${pypi_index} ${proxy_flag} \$wheel_support_flag --upgrade pip ${distribute_pkg}", + command => "mkdir -p ${venv_dir} ${proxy_command} && virtualenv ${system_pkgs_flag} -p ${python} ${venv_dir} && ${venv_dir}/bin/pip $pip_env wheel --help > /dev/null 2>&1 && { ${venv_dir}/bin/pip wheel --version > /dev/null 2>&1 || wheel_support_flag='--no-use-wheel'; } ; ${venv_dir}/bin/pip --log ${venv_dir}/pip.log install ${pypi_index} ${proxy_flag} \$wheel_support_flag --upgrade pip ${distribute_pkg}", user => $owner, path => $path, cwd => "/tmp", -- cgit v1.2.3 From d8a72b218455de66b59af0229ebae2e708538e77 Mon Sep 17 00:00:00 2001 From: Jarl Stefansson Date: Fri, 3 Jan 2014 10:09:56 -0500 Subject: Fix testing for existing virtual environment --- manifests/virtualenv.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/virtualenv.pp b/manifests/virtualenv.pp index 7a548a6..f3ca1ce 100644 --- a/manifests/virtualenv.pp +++ b/manifests/virtualenv.pp @@ -132,7 +132,7 @@ define python::virtualenv ( path => $path, cwd => "/tmp", environment => $environment, - unless => "grep '^[ \t]*VIRTUAL_ENV=[\'\"]*/tmp[\"\']*[ \t]*$' ${venv_dir}/bin/activate", #Unless activate exists and VIRTUAL_ENV is correct we re-create the virtualenv + unless => "grep '^[ \t]*VIRTUAL_ENV=[\'\"]*${venv_dir}[\"\']*[ \t]*$' ${venv_dir}/bin/activate", #Unless activate exists and VIRTUAL_ENV is correct we re-create the virtualenv } if $requirements { -- cgit v1.2.3 From 7ae9495652889b69543c57869d181e4b479070b4 Mon Sep 17 00:00:00 2001 From: Jarl Stefansson Date: Fri, 3 Jan 2014 10:49:25 -0500 Subject: Fix grep for detecting if virtenv needs rebuild --- manifests/virtualenv.pp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manifests/virtualenv.pp b/manifests/virtualenv.pp index f3ca1ce..cee35fc 100644 --- a/manifests/virtualenv.pp +++ b/manifests/virtualenv.pp @@ -119,7 +119,7 @@ define python::virtualenv ( default => "-i ${index}", } - # Python 2.6 and older does not support setuptools/distribute > 0.8 which + # Python 2.6 and older does not support setuptools/distribute > 0.8 which # is required for pip wheel support, pip therefor requires --no-use-wheel flag # if the # pip version is more recent than 1.4.1 but using an old python or # setuputils/distribute version @@ -132,7 +132,7 @@ define python::virtualenv ( path => $path, cwd => "/tmp", environment => $environment, - unless => "grep '^[ \t]*VIRTUAL_ENV=[\'\"]*${venv_dir}[\"\']*[ \t]*$' ${venv_dir}/bin/activate", #Unless activate exists and VIRTUAL_ENV is correct we re-create the virtualenv + unless => "grep '^[\\t ]*VIRTUAL_ENV=[\\\\'\\\"]*${venv_dir}[\\\"\\\\'][\\t ]*$' ${venv_dir}/bin/activate", #Unless activate exists and VIRTUAL_ENV is correct we re-create the virtualenv } if $requirements { -- cgit v1.2.3 From 895eebf2a03a29959d0c4dbd613cfa345ac22b55 Mon Sep 17 00:00:00 2001 From: Jarl Stefansson Date: Fri, 3 Jan 2014 10:53:24 -0500 Subject: Cleanup for merge request --- manifests/pip.pp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/manifests/pip.pp b/manifests/pip.pp index e9ab7cd..f71cdcd 100644 --- a/manifests/pip.pp +++ b/manifests/pip.pp @@ -70,7 +70,6 @@ define python::pip ( default => "--proxy=${proxy}", } - $grep_regex = $name ? { /==/ => "^${name}\$", default => "^${name}==", @@ -123,7 +122,7 @@ define python::pip ( default: { exec { "pip_uninstall_${name}": - command => "echo y | $pip_env uninstall $uninstall_args ${wheel_support_flag} ${proxy_flag} ${name}", + command => "echo y | $pip_env uninstall $uninstall_args ${proxy_flag} ${name}", onlyif => "$pip_env freeze | grep -i -e ${grep_regex}", user => $owner, environment => $environment, -- cgit v1.2.3 From 223da1caddb69418fc1a6383dbb5ea65c9fcdf90 Mon Sep 17 00:00:00 2001 From: Jarl Stefansson Date: Fri, 3 Jan 2014 11:45:39 -0500 Subject: Fix wheel/pip1.5 handing with requirements --- manifests/virtualenv.pp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/manifests/virtualenv.pp b/manifests/virtualenv.pp index a779141..fc540a8 100644 --- a/manifests/virtualenv.pp +++ b/manifests/virtualenv.pp @@ -127,17 +127,17 @@ define python::virtualenv ( # version, this makes sure we only use wheels if they are supported exec { "python_virtualenv_${venv_dir}": - command => "mkdir -p ${venv_dir} ${proxy_command} && virtualenv ${system_pkgs_flag} -p ${python} ${venv_dir} && ${venv_dir}/bin/pip wheel --help > /dev/null 2>&1 && { ${venv_dir}/bin/pip wheel --version > /dev/null 2>&1 || wheel_support_flag='--no-use-wheel'; } ; ${venv_dir}/bin/pip --log ${venv_dir}/pip.log install ${pypi_index} ${proxy_flag} \$wheel_support_flag --upgrade pip ${distribute_pkg}", - user => $owner, - path => $path, - cwd => "/tmp", + command => "mkdir -p ${venv_dir} ${proxy_command} && virtualenv ${system_pkgs_flag} -p ${python} ${venv_dir} && ${venv_dir}/bin/pip wheel --help > /dev/null 2>&1 && { ${venv_dir}/bin/pip wheel --version > /dev/null 2>&1 || wheel_support_flag='--no-use-wheel'; } ; ${venv_dir}/bin/pip --log ${venv_dir}/pip.log install ${pypi_index} ${proxy_flag} \$wheel_support_flag --upgrade pip ${distribute_pkg}", + user => $owner, + path => $path, + cwd => "/tmp", environment => $environment, - unless => "grep '^[\\t ]*VIRTUAL_ENV=[\\\\'\\\"]*${venv_dir}[\\\"\\\\'][\\t ]*$' ${venv_dir}/bin/activate", #Unless activate exists and VIRTUAL_ENV is correct we re-create the virtualenv + unless => "grep '^[\\t ]*VIRTUAL_ENV=[\\\\'\\\"]*${venv_dir}[\\\"\\\\'][\\t ]*$' ${venv_dir}/bin/activate", #Unless activate exists and VIRTUAL_ENV is correct we re-create the virtualenv } if $requirements { exec { "python_requirements_initial_install_${requirements}_${venv_dir}": - command => "${venv_dir}/bin/pip --log ${venv_dir}/pip.log install ${pypi_index} ${proxy_flag} ${wheel_support_flag} -r ${requirements}", + command => "${venv_dir}/bin/pip wheel --help > /dev/null 2>&1 && { ${venv_dir}/bin/pip wheel --version > /dev/null 2>&1 || wheel_support_flag='--no-use-wheel'; } ; ${venv_dir}/bin/pip --log ${venv_dir}/pip.log install ${pypi_index} ${proxy_flag} \$wheel_support_flag -r ${requirements}", refreshonly => true, timeout => $timeout, user => $owner, -- cgit v1.2.3 From b5f48bc7cc5861dee404d43eed5a6d327d22c54e Mon Sep 17 00:00:00 2001 From: Jarl Stefansson Date: Fri, 3 Jan 2014 13:01:45 -0500 Subject: Fix working dir for virtualenv creation --- manifests/virtualenv.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/virtualenv.pp b/manifests/virtualenv.pp index fc540a8..7f7fbb4 100644 --- a/manifests/virtualenv.pp +++ b/manifests/virtualenv.pp @@ -130,7 +130,7 @@ define python::virtualenv ( command => "mkdir -p ${venv_dir} ${proxy_command} && virtualenv ${system_pkgs_flag} -p ${python} ${venv_dir} && ${venv_dir}/bin/pip wheel --help > /dev/null 2>&1 && { ${venv_dir}/bin/pip wheel --version > /dev/null 2>&1 || wheel_support_flag='--no-use-wheel'; } ; ${venv_dir}/bin/pip --log ${venv_dir}/pip.log install ${pypi_index} ${proxy_flag} \$wheel_support_flag --upgrade pip ${distribute_pkg}", user => $owner, path => $path, - cwd => "/tmp", + cwd => $venv_dir, environment => $environment, unless => "grep '^[\\t ]*VIRTUAL_ENV=[\\\\'\\\"]*${venv_dir}[\\\"\\\\'][\\t ]*$' ${venv_dir}/bin/activate", #Unless activate exists and VIRTUAL_ENV is correct we re-create the virtualenv } -- cgit v1.2.3 From 9d019a6cba04f95a14a8d57fc2510732e9a5b53e Mon Sep 17 00:00:00 2001 From: Sergey Stankevich Date: Sat, 4 Jan 2014 10:17:49 +0300 Subject: Version 1.5.0 --- Modulefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modulefile b/Modulefile index be19691..3e205cf 100644 --- a/Modulefile +++ b/Modulefile @@ -1,5 +1,5 @@ name 'stankevich-python' -version '1.4.0' +version '1.5.0' author 'Sergey Stankevich' license 'Apache License, Version 2.0' -- cgit v1.2.3 From e6b4b9417139c97414f940dd4450fce21cf9af24 Mon Sep 17 00:00:00 2001 From: Jarl Stefansson Date: Tue, 7 Jan 2014 13:20:27 -0500 Subject: Revert to using /tmp fir for cwd for virte inst. If the virtualenv target directory does not exist before running the virtualenv command the puppet command will fail if the cwd does not exist, hence revert back to using the /tmp directory for current working directory. --- manifests/virtualenv.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/virtualenv.pp b/manifests/virtualenv.pp index 7f7fbb4..fc540a8 100644 --- a/manifests/virtualenv.pp +++ b/manifests/virtualenv.pp @@ -130,7 +130,7 @@ define python::virtualenv ( command => "mkdir -p ${venv_dir} ${proxy_command} && virtualenv ${system_pkgs_flag} -p ${python} ${venv_dir} && ${venv_dir}/bin/pip wheel --help > /dev/null 2>&1 && { ${venv_dir}/bin/pip wheel --version > /dev/null 2>&1 || wheel_support_flag='--no-use-wheel'; } ; ${venv_dir}/bin/pip --log ${venv_dir}/pip.log install ${pypi_index} ${proxy_flag} \$wheel_support_flag --upgrade pip ${distribute_pkg}", user => $owner, path => $path, - cwd => $venv_dir, + cwd => "/tmp", environment => $environment, unless => "grep '^[\\t ]*VIRTUAL_ENV=[\\\\'\\\"]*${venv_dir}[\\\"\\\\'][\\t ]*$' ${venv_dir}/bin/activate", #Unless activate exists and VIRTUAL_ENV is correct we re-create the virtualenv } -- cgit v1.2.3 From fae8ae4476142112db877470fe6d374c0e63acc9 Mon Sep 17 00:00:00 2001 From: Jarl Stefansson Date: Tue, 7 Jan 2014 13:29:00 -0500 Subject: Silence facter by redirecting python -V stderr --- lib/facter/python_version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/facter/python_version.rb b/lib/facter/python_version.rb index a2bdb26..6b88ee9 100644 --- a/lib/facter/python_version.rb +++ b/lib/facter/python_version.rb @@ -14,7 +14,7 @@ end Facter.add("python_version") do has_weight 100 setcode do - /^.*(\d+\.\d+\.\d+)$/.match(Facter::Util::Resolution.exec('python -V'))[1] + /^.*(\d+\.\d+\.\d+)$/.match(Facter::Util::Resolution.exec('python -V 2>/dev/null'))[1] end end -- cgit v1.2.3 From 25d7203f8c7c152dcc4ecd75569effebee9ba25a Mon Sep 17 00:00:00 2001 From: Jarl Stefansson Date: Tue, 7 Jan 2014 14:25:42 -0500 Subject: Fix Python version detection, stderr to stdout --- lib/facter/python_version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/facter/python_version.rb b/lib/facter/python_version.rb index 6b88ee9..50fef72 100644 --- a/lib/facter/python_version.rb +++ b/lib/facter/python_version.rb @@ -14,7 +14,7 @@ end Facter.add("python_version") do has_weight 100 setcode do - /^.*(\d+\.\d+\.\d+)$/.match(Facter::Util::Resolution.exec('python -V 2>/dev/null'))[1] + /^.*(\d+\.\d+\.\d+)$/.match(Facter::Util::Resolution.exec('python -V 2>&1'))[1] end end -- cgit v1.2.3 From 743c57790affea2694f2553ff66920ef543411ac Mon Sep 17 00:00:00 2001 From: Sergey Stankevich Date: Wed, 8 Jan 2014 03:36:15 +0200 Subject: Version 1.6.1 --- Modulefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modulefile b/Modulefile index 4f2424b..048c5cd 100644 --- a/Modulefile +++ b/Modulefile @@ -1,5 +1,5 @@ name 'stankevich-python' -version '1.6.0' +version '1.6.1' author 'Sergey Stankevich' license 'Apache License, Version 2.0' -- cgit v1.2.3 From cfcc3781d49239834d7bb91e7c2ec3c08c982a13 Mon Sep 17 00:00:00 2001 From: Franz Pletz Date: Tue, 14 Jan 2014 15:25:38 +0100 Subject: Wheel support in pip needs current setuptools When virtualenvs are used without distribute and an old setuptools python package is installed in the system, upgrading pip in the virtualenv won't ensure setuptools > 0.8 is installed which is required by the pip wheel command. This patch upgrades setuptools if distribute isn't used. Signed-off-by: Franz Pletz --- manifests/virtualenv.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/virtualenv.pp b/manifests/virtualenv.pp index fc540a8..a7a2bcb 100644 --- a/manifests/virtualenv.pp +++ b/manifests/virtualenv.pp @@ -112,7 +112,7 @@ define python::virtualenv ( $distribute_pkg = $distribute ? { true => 'distribute', - default => '', + default => 'setuptools', } $pypi_index = $index ? { false => '', -- cgit v1.2.3 From 94f907ef6c0979ae72b8614e88640609baf74de8 Mon Sep 17 00:00:00 2001 From: Sergey Stankevich Date: Tue, 14 Jan 2014 09:37:17 -0500 Subject: Version 1.6.2 --- Modulefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modulefile b/Modulefile index 048c5cd..1cd9de1 100644 --- a/Modulefile +++ b/Modulefile @@ -1,5 +1,5 @@ name 'stankevich-python' -version '1.6.1' +version '1.6.2' author 'Sergey Stankevich' license 'Apache License, Version 2.0' -- cgit v1.2.3 From 05fc36b8d6f0a9eaeedd72a9dbbbe899aeeed8e2 Mon Sep 17 00:00:00 2001 From: Jarl Stefansson Date: Tue, 14 Jan 2014 17:02:38 -0500 Subject: Update documentation for python pip --- manifests/pip.pp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/manifests/pip.pp b/manifests/pip.pp index fb73ae7..367cdb3 100644 --- a/manifests/pip.pp +++ b/manifests/pip.pp @@ -85,12 +85,20 @@ define python::pip ( default => "${url}#egg=${egg_name}", } - # Python 2.6 and older does not support setuptools/distribute > 0.8 which - # is required for pip wheel support, pip therefor requires --no-use-wheel flag - # if the # pip version is more recent than 1.4.1 but using an old python or - # setuputils/distribute version + # We need to jump through hoops to make sure we issue the correct pip command + # depending on wheel support and versions. + # + # Pip does not support wheels prior to version 1.4.0 + # Pip wheels require setuptools/distribute > 0.8 + # Python 2.6 and older does not support setuptools/distribute > 0.8 + # Pip >= 1.5 tries to use wheels by default, even if wheel package is not + # installed, in this case the --no-use-wheel flag needs to be passed + # Versions prior to 1.5 don't support the --no-use-wheel flag + # # To check for this we test for wheel parameter using help and then using - # version, this makes sure we only use wheels if they are supported + # version, this makes sure we only use wheels if they are supported and + # installed + case $ensure { present: { -- cgit v1.2.3 From 4a0ad14203420a9d05db336bd48940dcd61876a6 Mon Sep 17 00:00:00 2001 From: Steffen Zieger Date: Thu, 16 Jan 2014 01:17:34 +0100 Subject: Add path to requirements exec --- manifests/requirements.pp | 1 + 1 file changed, 1 insertion(+) diff --git a/manifests/requirements.pp b/manifests/requirements.pp index 5fa6eb9..11c5f00 100644 --- a/manifests/requirements.pp +++ b/manifests/requirements.pp @@ -102,6 +102,7 @@ define python::requirements ( user => $owner, subscribe => File[$requirements], environment => $environment, + path => ['/usr/local/bin','/usr/bin','/bin', '/usr/sbin'], } } -- cgit v1.2.3 From dba29a61bda4ab44ec8c42a43583d0e51f3806d9 Mon Sep 17 00:00:00 2001 From: Steffen Zieger Date: Thu, 16 Jan 2014 01:19:41 +0100 Subject: remove duplicate pip_install exec for latest case --- manifests/pip.pp | 8 -------- 1 file changed, 8 deletions(-) diff --git a/manifests/pip.pp b/manifests/pip.pp index fb73ae7..4aacb31 100644 --- a/manifests/pip.pp +++ b/manifests/pip.pp @@ -112,14 +112,6 @@ define python::pip ( } } - 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 ${cwd}/pip.log install -U ${install_args} \$wheel_support_flag ${proxy_flag} ${source}", - user => $owner, - environment => $environment, - } - } - default: { exec { "pip_uninstall_${name}": command => "echo y | ${pip_env} uninstall ${uninstall_args} ${proxy_flag} ${name}", -- cgit v1.2.3 From 6e9f26a2e0ac360701876cb9cbac09efc2eeab75 Mon Sep 17 00:00:00 2001 From: Jarl Stefansson Date: Thu, 16 Jan 2014 10:32:30 -0500 Subject: Fix pip 1.5/1.4.1 handling --- manifests/virtualenv.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/virtualenv.pp b/manifests/virtualenv.pp index fc540a8..fa2e654 100644 --- a/manifests/virtualenv.pp +++ b/manifests/virtualenv.pp @@ -127,7 +127,7 @@ define python::virtualenv ( # version, this makes sure we only use wheels if they are supported exec { "python_virtualenv_${venv_dir}": - command => "mkdir -p ${venv_dir} ${proxy_command} && virtualenv ${system_pkgs_flag} -p ${python} ${venv_dir} && ${venv_dir}/bin/pip wheel --help > /dev/null 2>&1 && { ${venv_dir}/bin/pip wheel --version > /dev/null 2>&1 || wheel_support_flag='--no-use-wheel'; } ; ${venv_dir}/bin/pip --log ${venv_dir}/pip.log install ${pypi_index} ${proxy_flag} \$wheel_support_flag --upgrade pip ${distribute_pkg}", + command => "mkdir -p ${venv_dir} ${proxy_command} && virtualenv ${system_pkgs_flag} -p ${python} ${venv_dir} && ${venv_dir}/bin/pip wheel --help > /dev/null 2>&1 && { ${venv_dir}/bin/pip wheel --version > /dev/null 2>&1 || wheel_support_flag='--no-use-wheel'; } ; { ${venv_dir}/bin/pip --log ${venv_dir}/pip.log install ${pypi_index} ${proxy_flag} \$wheel_support_flag --upgrade pip ${distribute_pkg} || ${venv_dir}/bin/pip --log ${venv_dir}/pip.log install ${pypi_index} ${proxy_flag} --upgrade pip ${distribute_pkg} }", user => $owner, path => $path, cwd => "/tmp", -- cgit v1.2.3 From ad2a8ba8081ee05a5b2abfb8eb813e8c6f103826 Mon Sep 17 00:00:00 2001 From: Vlastimil Holer Date: Mon, 20 Jan 2014 14:30:49 +0100 Subject: Drop stderr in pip --version --- lib/facter/pip_version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/facter/pip_version.rb b/lib/facter/pip_version.rb index 131d1f9..bc725db 100644 --- a/lib/facter/pip_version.rb +++ b/lib/facter/pip_version.rb @@ -5,7 +5,7 @@ pkg = Puppet::Type.type(:package).new(:name => "python-pip") Facter.add("pip_version") do has_weight 100 setcode do - /^pip (\d+\.\d+\.?\d*).*$/.match(Facter::Util::Resolution.exec('pip --version'))[1] + /^pip (\d+\.\d+\.?\d*).*$/.match(Facter::Util::Resolution.exec('pip --version 2>/dev/null'))[1] end end -- cgit v1.2.3 From 97793765ee15a93fbde928aaf17397d0c397fa69 Mon Sep 17 00:00:00 2001 From: Jarl Stefansson Date: Mon, 20 Jan 2014 13:49:41 -0500 Subject: Fix syntax error with brace prioritization --- manifests/virtualenv.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/virtualenv.pp b/manifests/virtualenv.pp index fa2e654..8c240ed 100644 --- a/manifests/virtualenv.pp +++ b/manifests/virtualenv.pp @@ -127,7 +127,7 @@ define python::virtualenv ( # version, this makes sure we only use wheels if they are supported exec { "python_virtualenv_${venv_dir}": - command => "mkdir -p ${venv_dir} ${proxy_command} && virtualenv ${system_pkgs_flag} -p ${python} ${venv_dir} && ${venv_dir}/bin/pip wheel --help > /dev/null 2>&1 && { ${venv_dir}/bin/pip wheel --version > /dev/null 2>&1 || wheel_support_flag='--no-use-wheel'; } ; { ${venv_dir}/bin/pip --log ${venv_dir}/pip.log install ${pypi_index} ${proxy_flag} \$wheel_support_flag --upgrade pip ${distribute_pkg} || ${venv_dir}/bin/pip --log ${venv_dir}/pip.log install ${pypi_index} ${proxy_flag} --upgrade pip ${distribute_pkg} }", + command => "mkdir -p ${venv_dir} ${proxy_command} && virtualenv ${system_pkgs_flag} -p ${python} ${venv_dir} && ${venv_dir}/bin/pip wheel --help > /dev/null 2>&1 && { ${venv_dir}/bin/pip wheel --version > /dev/null 2>&1 || wheel_support_flag='--no-use-wheel'; } ; { ${venv_dir}/bin/pip --log ${venv_dir}/pip.log install ${pypi_index} ${proxy_flag} \$wheel_support_flag --upgrade pip ${distribute_pkg} || ${venv_dir}/bin/pip --log ${venv_dir}/pip.log install ${pypi_index} ${proxy_flag} --upgrade pip ${distribute_pkg} ;}", user => $owner, path => $path, cwd => "/tmp", -- cgit v1.2.3 From 2bb37cdbc62868f11de93c93853eea03bda513fd Mon Sep 17 00:00:00 2001 From: Sergey Stankevich Date: Sun, 2 Feb 2014 11:52:51 +0300 Subject: Version 1.6.3 --- Modulefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modulefile b/Modulefile index 1cd9de1..15e2fff 100644 --- a/Modulefile +++ b/Modulefile @@ -1,5 +1,5 @@ name 'stankevich-python' -version '1.6.2' +version '1.6.3' author 'Sergey Stankevich' license 'Apache License, Version 2.0' -- cgit v1.2.3 From cc60884faa51751a7c2f07d94bec192fb57b76b3 Mon Sep 17 00:00:00 2001 From: Steve Huff Date: Wed, 26 Feb 2014 12:04:54 -0500 Subject: prevent Facter error when packages not installed on RHEL systems, `pkg.retrieve[pkg.property(:ensure)]` returns `:absent` when a package is not installed; this can generate an unsightly error when running these facts on a RHEL system where the necessary OS packages are not installed: [root@gepeto ~]# facter -p osfamily RedHat [root@gepeto ~]# facter -p lsbmajdistrelease 5 [root@gepeto ~]# grep version /etc/puppet/modules/python/Modulefile version '1.6.3' [root@gepeto ~]# facter -p virtualenv_version pip_version Could not retrieve virtualenv_version: can't convert Symbol into String Could not retrieve pip_version: undefined method `[]' for nil:NilClass Could not retrieve pip_version: can't convert Symbol into String pip_version => virtualenv_version => Fixes #50 --- lib/facter/pip_version.rb | 2 +- lib/facter/python_version.rb | 4 ++-- lib/facter/virtualenv_version.rb | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/facter/pip_version.rb b/lib/facter/pip_version.rb index bc725db..46c50d9 100644 --- a/lib/facter/pip_version.rb +++ b/lib/facter/pip_version.rb @@ -12,7 +12,7 @@ end Facter.add("pip_version") do has_weight 50 setcode do - if pkg.retrieve[pkg.property(:ensure)] != 'purged' + unless [:absent,'purged'].include?(pkg.retrieve[pkg.property(:ensure)]) /^.*(\d+\.\d+\.\d+).*$/.match(pkg.retrieve[pkg.property(:ensure)])[1] end end diff --git a/lib/facter/python_version.rb b/lib/facter/python_version.rb index 50fef72..919fd89 100644 --- a/lib/facter/python_version.rb +++ b/lib/facter/python_version.rb @@ -5,7 +5,7 @@ pkg = Puppet::Type.type(:package).new(:name => "python") Facter.add("system_python_version") do setcode do - if pkg.retrieve[pkg.property(:ensure)] != 'purged' + unless [:absent,'purged'].include?(pkg.retrieve[pkg.property(:ensure)]) /^(\d+\.\d+\.\d+).*$/.match(pkg.retrieve[pkg.property(:ensure)])[1] end end @@ -21,7 +21,7 @@ end Facter.add("python_version") do has_weight 50 setcode do - if pkg.retrieve[pkg.property(:ensure)] != 'purged' + unless [:absent,'purged'].include?(pkg.retrieve[pkg.property(:ensure)]) /^.*(\d+\.\d+\.\d+).*$/.match(pkg.retrieve[pkg.property(:ensure)])[1] end end diff --git a/lib/facter/virtualenv_version.rb b/lib/facter/virtualenv_version.rb index c923b09..9a3b4b0 100644 --- a/lib/facter/virtualenv_version.rb +++ b/lib/facter/virtualenv_version.rb @@ -12,7 +12,7 @@ end Facter.add("virtualenv_version") do has_weight 50 setcode do - if pkg.retrieve[pkg.property(:ensure)] != 'purged' + unless [:absent,'purged'].include?(pkg.retrieve[pkg.property(:ensure)]) /^.*(\d+\.\d+\.\d+).*$/.match(pkg.retrieve[pkg.property(:ensure)])[1] end end -- cgit v1.2.3 From a29284170a6687669b00fbc574f1bdc5f9e5b404 Mon Sep 17 00:00:00 2001 From: Matt Callaway Date: Tue, 4 Mar 2014 15:14:08 -0600 Subject: Add begin/rescue/end to setcode block This silences these warnings: Could not retrieve pip_version: undefined method `[]' for nil:NilClass Could not retrieve pip_version: can't convert Symbol into String --- lib/facter/pip_version.rb | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/facter/pip_version.rb b/lib/facter/pip_version.rb index 46c50d9..ce32f98 100644 --- a/lib/facter/pip_version.rb +++ b/lib/facter/pip_version.rb @@ -5,15 +5,23 @@ pkg = Puppet::Type.type(:package).new(:name => "python-pip") Facter.add("pip_version") do has_weight 100 setcode do - /^pip (\d+\.\d+\.?\d*).*$/.match(Facter::Util::Resolution.exec('pip --version 2>/dev/null'))[1] + begin + /^pip (\d+\.\d+\.?\d*).*$/.match(Facter::Util::Resolution.exec('pip --version 2>/dev/null'))[1] + rescue + false + end end end Facter.add("pip_version") do has_weight 50 setcode do - unless [:absent,'purged'].include?(pkg.retrieve[pkg.property(:ensure)]) - /^.*(\d+\.\d+\.\d+).*$/.match(pkg.retrieve[pkg.property(:ensure)])[1] + begin + unless [:absent,'purged'].include?(pkg.retrieve[pkg.property(:ensure)]) + /^.*(\d+\.\d+\.\d+).*$/.match(pkg.retrieve[pkg.property(:ensure)])[1] + end + rescue + false end end end -- cgit v1.2.3 From c47678748b39c0d7b524e6cfb4b3aab2e8811c6b Mon Sep 17 00:00:00 2001 From: Matt Callaway Date: Tue, 4 Mar 2014 15:17:07 -0600 Subject: Add begin/rescue/end to setcode block This silences these warnings: Could not retrieve pip_version: undefined method `[]' for nil:NilClass Could not retrieve pip_version: can't convert Symbol into String --- lib/facter/python_version.rb | 22 +++++++++++++++++----- lib/facter/virtualenv_version.rb | 14 +++++++++++--- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/lib/facter/python_version.rb b/lib/facter/python_version.rb index 919fd89..bb9ec98 100644 --- a/lib/facter/python_version.rb +++ b/lib/facter/python_version.rb @@ -5,8 +5,12 @@ pkg = Puppet::Type.type(:package).new(:name => "python") Facter.add("system_python_version") do setcode do - unless [:absent,'purged'].include?(pkg.retrieve[pkg.property(:ensure)]) - /^(\d+\.\d+\.\d+).*$/.match(pkg.retrieve[pkg.property(:ensure)])[1] + begin + unless [:absent,'purged'].include?(pkg.retrieve[pkg.property(:ensure)]) + /^(\d+\.\d+\.\d+).*$/.match(pkg.retrieve[pkg.property(:ensure)])[1] + end + rescue + false end end end @@ -14,15 +18,23 @@ end Facter.add("python_version") do has_weight 100 setcode do - /^.*(\d+\.\d+\.\d+)$/.match(Facter::Util::Resolution.exec('python -V 2>&1'))[1] + begin + /^.*(\d+\.\d+\.\d+)$/.match(Facter::Util::Resolution.exec('python -V 2>&1'))[1] + rescue + false + end end end Facter.add("python_version") do has_weight 50 setcode do - unless [:absent,'purged'].include?(pkg.retrieve[pkg.property(:ensure)]) - /^.*(\d+\.\d+\.\d+).*$/.match(pkg.retrieve[pkg.property(:ensure)])[1] + begin + unless [:absent,'purged'].include?(pkg.retrieve[pkg.property(:ensure)]) + /^.*(\d+\.\d+\.\d+).*$/.match(pkg.retrieve[pkg.property(:ensure)])[1] + end + rescue + false end end end diff --git a/lib/facter/virtualenv_version.rb b/lib/facter/virtualenv_version.rb index 9a3b4b0..04736ed 100644 --- a/lib/facter/virtualenv_version.rb +++ b/lib/facter/virtualenv_version.rb @@ -5,15 +5,23 @@ pkg = Puppet::Type.type(:package).new(:name => "virtualenv") Facter.add("virtualenv_version") do has_weight 100 setcode do - Facter::Util::Resolution.exec('virtualenv --version') + begin + Facter::Util::Resolution.exec('virtualenv --version') + rescue + false + end end end Facter.add("virtualenv_version") do has_weight 50 setcode do - unless [:absent,'purged'].include?(pkg.retrieve[pkg.property(:ensure)]) - /^.*(\d+\.\d+\.\d+).*$/.match(pkg.retrieve[pkg.property(:ensure)])[1] + begin + unless [:absent,'purged'].include?(pkg.retrieve[pkg.property(:ensure)]) + /^.*(\d+\.\d+\.\d+).*$/.match(pkg.retrieve[pkg.property(:ensure)])[1] + end + rescue + false end end end -- cgit v1.2.3 From 661c14e22109ccbe1d9da695b8eb05031b1e4d72 Mon Sep 17 00:00:00 2001 From: Sergey Stankevich Date: Thu, 6 Mar 2014 08:18:00 -0500 Subject: Release 1.6.4 --- Modulefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modulefile b/Modulefile index 15e2fff..432c8cb 100644 --- a/Modulefile +++ b/Modulefile @@ -1,5 +1,5 @@ name 'stankevich-python' -version '1.6.3' +version '1.6.4' author 'Sergey Stankevich' license 'Apache License, Version 2.0' -- cgit v1.2.3 From c298a80bc32e3dda2e6b0d1deb839cc2831f646e Mon Sep 17 00:00:00 2001 From: Marcin Zaremba Date: Thu, 6 Mar 2014 15:33:02 +0100 Subject: adds external pkgname variable --- manifests/pip.pp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/manifests/pip.pp b/manifests/pip.pp index 4f91e59..7e332fe 100644 --- a/manifests/pip.pp +++ b/manifests/pip.pp @@ -4,6 +4,12 @@ # # === Parameters # +# [*name] +# must be unique +# +# [*pkgname] +# name of the package. +# # [*ensure*] # present|absent. Default: present # @@ -35,6 +41,7 @@ # Fotis Gimian # define python::pip ( + $pkgname = undef, $ensure = present, $virtualenv = 'system', $url = false, @@ -70,18 +77,18 @@ define python::pip ( default => "--proxy=${proxy}", } - $grep_regex = $name ? { - /==/ => "^${name}\$", - default => "^${name}==", + $grep_regex = $pkgname ? { + /==/ => "^${pkgname}\$", + default => "^${pkgname}==", } $egg_name = $egg ? { - false => $name, + false => $pkgname, default => $egg } $source = $url ? { - false => $name, + false => $pkgname, default => "${url}#egg=${egg_name}", } @@ -122,7 +129,7 @@ define python::pip ( default: { exec { "pip_uninstall_${name}": - command => "echo y | ${pip_env} uninstall ${uninstall_args} ${proxy_flag} ${name}", + command => "echo y | ${pip_env} uninstall ${uninstall_args} ${proxy_flag} ${pkgname}", onlyif => "${pip_env} freeze | grep -i -e ${grep_regex}", user => $owner, environment => $environment, -- cgit v1.2.3 From 86c142afac34dde4a6d738fd27f94ffbd4ad762b Mon Sep 17 00:00:00 2001 From: Sergey Stankevich Date: Thu, 6 Mar 2014 09:38:54 -0500 Subject: Release 1.6.5 --- Modulefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modulefile b/Modulefile index 432c8cb..4e41df0 100644 --- a/Modulefile +++ b/Modulefile @@ -1,5 +1,5 @@ name 'stankevich-python' -version '1.6.4' +version '1.6.5' author 'Sergey Stankevich' license 'Apache License, Version 2.0' -- cgit v1.2.3 From 2dde12a6bb58d84eff90fb13e120303ac61f8f49 Mon Sep 17 00:00:00 2001 From: Sergey Stankevich Date: Thu, 6 Mar 2014 09:40:15 -0500 Subject: Release 1.6.6 --- Modulefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modulefile b/Modulefile index 4e41df0..7ba4da7 100644 --- a/Modulefile +++ b/Modulefile @@ -1,5 +1,5 @@ name 'stankevich-python' -version '1.6.5' +version '1.6.6' author 'Sergey Stankevich' license 'Apache License, Version 2.0' -- cgit v1.2.3 From 4859c8968d41380a094c911c7d2db8aad234b480 Mon Sep 17 00:00:00 2001 From: Ezekiel Smithburg Date: Fri, 14 Mar 2014 16:21:37 -0700 Subject: Document newly required pkgname option for pip. --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 6aa0c98..444b3b7 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,8 @@ Installs and manages python, python-dev, python-virtualenv and Gunicorn. Installs and manages packages from pip. +**pkgname** - the name of the package to install. Required. + **ensure** - present/latest/absent. Default: present **virtualenv** - virtualenv to run pip in. Default: system (no virtualenv) @@ -69,6 +71,7 @@ Installs and manages packages from pip. **uninstall_args** - Array of additional flags to pass to pip during uninstall. Default: none python::pip { 'cx_Oracle': + pkgname => 'cx_Oracle', virtualenv => '/var/www/project1', owner => 'appuser', proxy => 'http://proxy.domain.com:3128', -- cgit v1.2.3 From 066a10ea68c340773a94d19769ff77c02c39f128 Mon Sep 17 00:00:00 2001 From: Nathan Sullivan Date: Tue, 18 Mar 2014 13:15:32 +1000 Subject: add support for explicit version handling with ensure parameter for pip packages --- manifests/pip.pp | 38 ++++++++++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/manifests/pip.pp b/manifests/pip.pp index 7e332fe..cbd2ed8 100644 --- a/manifests/pip.pp +++ b/manifests/pip.pp @@ -77,18 +77,29 @@ define python::pip ( default => "--proxy=${proxy}", } - $grep_regex = $pkgname ? { - /==/ => "^${pkgname}\$", - default => "^${pkgname}==", + # If pkgname is not specified, use name (title) instead. + $use_pkgname = $pkgname ? { + undef => $name, + default => $pkgname + } + + # Check if searching by explicit version. + if $ensure =~ /^((19|20)[0-9][0-9]-(0[1-9]|1[1-2])-([0-2][1-9]|3[0-1])|[0-9]+\.[0-9]+(\.[0-9]+)?)$/ { + $grep_regex = "^${use_pkgname}==${ensure}\$" + } else { + $grep_regex = $use_pkgname ? { + /==/ => "^${use_pkgname}\$", + default => "^${use_pkgname}==", + } } $egg_name = $egg ? { - false => $pkgname, + false => $use_pkgname, default => $egg } $source = $url ? { - false => $pkgname, + false => $use_pkgname, default => "${url}#egg=${egg_name}", } @@ -108,7 +119,20 @@ define python::pip ( case $ensure { + /^((19|20)[0-9][0-9]-(0[1-9]|1[1-2])-([0-2][1-9]|3[0-1])|[0-9]+\.[0-9]+(\.[0-9]+)?)$/: { + # Version formats as per http://guide.python-distribute.org/specification.html#standard-versioning-schemes + # Explicit version. + 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 ${cwd}/pip.log install ${install_args} \$wheel_support_flag ${proxy_flag} ${source}==${ensure}", + unless => "${pip_env} freeze | grep -i -e ${grep_regex}", + user => $owner, + environment => $environment, + path => ['/usr/local/bin','/usr/bin','/bin', '/usr/sbin'], + } + } + present: { + # Whatever version is available. 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 ${cwd}/pip.log install ${install_args} \$wheel_support_flag ${proxy_flag} ${source}", unless => "${pip_env} freeze | grep -i -e ${grep_regex}", @@ -119,6 +143,7 @@ define python::pip ( } latest: { + # Latest version. 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 ${cwd}/pip.log install --upgrade \$wheel_support_flag ${proxy_flag} ${source}", user => $owner, @@ -128,8 +153,9 @@ define python::pip ( } default: { + # Anti-action, uninstall. exec { "pip_uninstall_${name}": - command => "echo y | ${pip_env} uninstall ${uninstall_args} ${proxy_flag} ${pkgname}", + command => "echo y | ${pip_env} uninstall ${uninstall_args} ${proxy_flag} ${use_pkgname}", onlyif => "${pip_env} freeze | grep -i -e ${grep_regex}", user => $owner, environment => $environment, -- cgit v1.2.3 From 0ce45d0b9a82bba68c4fd19c3b95551ede848dfc Mon Sep 17 00:00:00 2001 From: Giacomo Vacca Date: Tue, 18 Mar 2014 11:14:29 +0000 Subject: Don't try to reinstall pip packages on every Puppet run #59; Even if ensure latest, do not install if already latest --- manifests/pip.pp | 1 + 1 file changed, 1 insertion(+) diff --git a/manifests/pip.pp b/manifests/pip.pp index 7e332fe..47e9732 100644 --- a/manifests/pip.pp +++ b/manifests/pip.pp @@ -121,6 +121,7 @@ define python::pip ( 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 ${cwd}/pip.log install --upgrade \$wheel_support_flag ${proxy_flag} ${source}", + unless => "${pip_env} search ${source} | grep -i INSTALLED | grep -i latest", user => $owner, environment => $environment, path => ['/usr/local/bin','/usr/bin','/bin', '/usr/sbin'], -- cgit v1.2.3 From f3dc9dd4fe59c06dd32b4951d0e796ea0b37fa49 Mon Sep 17 00:00:00 2001 From: Sergey Stankevich Date: Tue, 18 Mar 2014 08:38:33 -0400 Subject: Release 1.7.0 --- Modulefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modulefile b/Modulefile index 7ba4da7..3aa9846 100644 --- a/Modulefile +++ b/Modulefile @@ -1,5 +1,5 @@ name 'stankevich-python' -version '1.6.6' +version '1.7.0' author 'Sergey Stankevich' license 'Apache License, Version 2.0' -- cgit v1.2.3 From 846844259b042a8ce3444e21aed880be299760ef Mon Sep 17 00:00:00 2001 From: Robert Deaton Date: Tue, 25 Mar 2014 12:32:55 -0700 Subject: Add pypy support --- manifests/install.pp | 1 + manifests/virtualenv.pp | 1 + 2 files changed, 2 insertions(+) diff --git a/manifests/install.pp b/manifests/install.pp index c4914f7..1c2cb0b 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -17,6 +17,7 @@ class python::install { $python = $python::version ? { 'system' => 'python', + 'pypy' => 'pypy', default => "python${python::version}", } diff --git a/manifests/virtualenv.pp b/manifests/virtualenv.pp index b9cd689..2faa809 100644 --- a/manifests/virtualenv.pp +++ b/manifests/virtualenv.pp @@ -85,6 +85,7 @@ define python::virtualenv ( $python = $version ? { 'system' => 'python', + 'pypy' => 'pypy', default => "python${version}", } -- cgit v1.2.3 From d9adcb640e078b43d41d2940c07f68c6cc83de92 Mon Sep 17 00:00:00 2001 From: Sergey Stankevich Date: Tue, 25 Mar 2014 16:54:00 -0400 Subject: Release 1.7.1 --- Modulefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modulefile b/Modulefile index 3aa9846..ac98278 100644 --- a/Modulefile +++ b/Modulefile @@ -1,5 +1,5 @@ name 'stankevich-python' -version '1.7.0' +version '1.7.1' author 'Sergey Stankevich' license 'Apache License, Version 2.0' -- cgit v1.2.3 From 7c7afae3abdb0924fdc362a42ad3cd60644b910e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Igor=20Gali=C4=87?= Date: Sun, 6 Apr 2014 12:40:46 +0200 Subject: simplify pkgname default rather than having a rather ugly if and an unhandy case new variable, we can simplify this by making the default $name, in the parameter list. --- manifests/pip.pp | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/manifests/pip.pp b/manifests/pip.pp index bf987a4..0c78903 100644 --- a/manifests/pip.pp +++ b/manifests/pip.pp @@ -8,7 +8,7 @@ # must be unique # # [*pkgname] -# name of the package. +# name of the package. If pkgname is not specified, use name (title) instead. # # [*ensure*] # present|absent. Default: present @@ -41,7 +41,7 @@ # Fotis Gimian # define python::pip ( - $pkgname = undef, + $pkgname = $name, $ensure = present, $virtualenv = 'system', $url = false, @@ -77,29 +77,23 @@ define python::pip ( default => "--proxy=${proxy}", } - # If pkgname is not specified, use name (title) instead. - $use_pkgname = $pkgname ? { - undef => $name, - default => $pkgname - } - # Check if searching by explicit version. if $ensure =~ /^((19|20)[0-9][0-9]-(0[1-9]|1[1-2])-([0-2][1-9]|3[0-1])|[0-9]+\.[0-9]+(\.[0-9]+)?)$/ { - $grep_regex = "^${use_pkgname}==${ensure}\$" + $grep_regex = "^${pkgname}==${ensure}\$" } else { - $grep_regex = $use_pkgname ? { - /==/ => "^${use_pkgname}\$", - default => "^${use_pkgname}==", + $grep_regex = $pkgname ? { + /==/ => "^${pkgname}\$", + default => "^${pkgname}==", } } $egg_name = $egg ? { - false => $use_pkgname, + false => $pkgname, default => $egg } $source = $url ? { - false => $use_pkgname, + false => $pkgname, default => "${url}#egg=${egg_name}", } -- cgit v1.2.3