summaryrefslogtreecommitdiff
path: root/manifests
diff options
context:
space:
mode:
authorJarl Stefansson <jarl@sdelements.com>2013-12-13 15:51:45 -0500
committerJarl Stefansson <jarl@sdelements.com>2013-12-13 15:51:45 -0500
commit6c6d58a0f3f286ae7994cc54c05416c7efd6b87a (patch)
tree195a672b6a550b7735c81db9b1db5d72c88c1f1d /manifests
parentf7801a4b0d9ae58187891d124c21d269eae19ba5 (diff)
parent44ea60543b37ce5ddb9ff9b7411dbf7a0330f0e6 (diff)
Merge branch 'master' of github.com:jalli/puppet-python
Conflicts: manifests/pip.pp manifests/requirements.pp manifests/virtualenv.pp
Diffstat (limited to 'manifests')
-rw-r--r--manifests/init.pp2
-rw-r--r--manifests/install.pp4
-rw-r--r--manifests/pip.pp34
-rw-r--r--manifests/requirements.pp13
-rw-r--r--manifests/virtualenv.pp14
5 files changed, 50 insertions, 17 deletions
diff --git a/manifests/init.pp b/manifests/init.pp
index 889d9c6..9fe0420 100644
--- a/manifests/init.pp
+++ b/manifests/init.pp
@@ -44,7 +44,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 8bc1b49..0d16659 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"
}
$dev_ensure = $python::dev ? {
diff --git a/manifests/pip.pp b/manifests/pip.pp
index 0bed6dc..bcb7911 100644
--- a/manifests/pip.pp
+++ b/manifests/pip.pp
@@ -35,12 +35,15 @@
# Fotis Gimian
#
define python::pip (
- $ensure = present,
- $virtualenv = 'system',
- $url = false,
- $owner = 'root',
- $proxy = false,
- $environment = []
+ $ensure = present,
+ $virtualenv = 'system',
+ $url = false,
+ $owner = 'root',
+ $proxy = false,
+ $egg = false,
+ $environment = [],
+ $install_args = '',
+ $uninstall_args = '',
) {
# Parameter validation
@@ -72,15 +75,20 @@ define python::pip (
default => "^${name}==",
}
+ $egg_name = $egg ? {
+ false => $name,
+ default => $egg
+ }
+
$source = $url ? {
false => $name,
- default => "${url}#egg=${name}",
+ default => "${url}#egg=${egg_name}",
}
case $ensure {
present: {
exec { "pip_install_${name}":
- command => "$pip_env --log ${cwd}/pip.log install ${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,
@@ -97,9 +105,17 @@ 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 ${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,
diff --git a/manifests/requirements.pp b/manifests/requirements.pp
index af84707..60c5b6c 100644
--- a/manifests/requirements.pp
+++ b/manifests/requirements.pp
@@ -19,6 +19,11 @@
# [*proxy*]
# Proxy server to use for outbound connections. Default: none
#
+# [*src*]
+# Pip --src parameter; if the requirements file contains --editable resources,
+# this parameter specifies where they will be installed. See the pip
+# documentation for more. Default: none (i.e. use the pip default).
+#
# [*environment*]
# Additional environment variables required to install the packages. Default: none
#
@@ -41,6 +46,7 @@ define python::requirements (
$owner = 'root',
$group = 'root',
$proxy = false,
+ $src = false,
$environment = []
) {
@@ -63,6 +69,11 @@ define python::requirements (
default => "--proxy=${proxy}",
}
+ $src_flag = $src ? {
+ false => '',
+ default => "--src=${src}",
+ }
+
# This will ensure multiple python::virtualenv definitions can share the
# the same requirements file.
if !defined(File[$requirements]) {
@@ -79,7 +90,7 @@ define python::requirements (
exec { "python_requirements${name}":
provider => shell,
- command => "${pip_env} --log ${cwd}/pip.log install ${proxy_flag} -r ${requirements}",
+ command => "${pip_env} --log-file ${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 1a2b093..1fb55d6 100644
--- a/manifests/virtualenv.pp
+++ b/manifests/virtualenv.pp
@@ -39,6 +39,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':
@@ -69,6 +75,8 @@ define python::virtualenv (
$proxy = false,
$environment = [],
$path = [ '/bin', '/usr/bin', '/usr/sbin','/usr/local/bin' ]
+ $cwd = undef,
+ $timeout = 1800
) {
$venv_dir = $name
@@ -124,10 +132,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}":
@@ -139,7 +148,6 @@ define python::virtualenv (
require => Exec["python_virtualenv_${venv_dir}"],
}
}
-
} elsif $ensure == 'absent' {
file { $venv_dir:
@@ -148,7 +156,5 @@ define python::virtualenv (
recurse => true,
purge => true,
}
-
}
-
}