From 0132b8fb2abe798f2f27541816bdc71a9289b0ba Mon Sep 17 00:00:00 2001 From: schacki Date: Mon, 20 May 2013 15:17:03 +0200 Subject: Removed SHA calculation from requirements and applied the audit option the requirements file resource which should do exaxtly the same out of the box --- manifests/requirements.pp | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) (limited to 'manifests/requirements.pp') diff --git a/manifests/requirements.pp b/manifests/requirements.pp index 67d24ce..8b94839 100644 --- a/manifests/requirements.pp +++ b/manifests/requirements.pp @@ -48,8 +48,6 @@ define python::requirements ( default => "--proxy=${proxy}", } - $req_crc = "${requirements}.sha1" - # This will ensure multiple python::virtualenv definitions can share the # the same requirements file. if !defined(File[$requirements]) { @@ -58,28 +56,20 @@ define python::requirements ( mode => '0644', owner => $owner, group => $group, + audit => content, replace => false, content => '# Puppet will install and/or update pip packages listed here', } } - # SHA1 checksum to detect changes - exec { "python_requirements_check_${name}": - provider => shell, - command => "sha1sum ${requirements} > ${req_crc}", - unless => "sha1sum -c ${req_crc}", - user => $owner, - require => File[$requirements], - } - - exec { "python_requirements_update_${name}": + exec { "python_requirements${name}": provider => shell, - command => "${pip_env} install ${proxy_flag} -Ur ${requirements}", + command => "${pip_env} install ${proxy_flag} -r ${requirements}", cwd => $cwd, refreshonly => true, timeout => 1800, user => $owner, - subscribe => Exec["python_requirements_check_${name}"], + subscribe => File[$requirements], } } -- cgit v1.2.3 From 1aaef848f4a52d83a6b44eeb4cffd9b61a665c41 Mon Sep 17 00:00:00 2001 From: Fotis Gimian Date: Mon, 3 Jun 2013 23:13:50 +1000 Subject: Made system virtualenv more robust and ensured that pip logging would occur in an appropriate directory upon failure to avoid errors --- manifests/requirements.pp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'manifests/requirements.pp') diff --git a/manifests/requirements.pp b/manifests/requirements.pp index 8b94839..3019a46 100644 --- a/manifests/requirements.pp +++ b/manifests/requirements.pp @@ -33,9 +33,13 @@ define python::requirements ( $group = 'root' ) { + if $virtualenv == 'system' and ($owner != 'root' or $group != 'root') { + fail('python::pip: root user must be used when virtualenv is system') + } + $cwd = $virtualenv ? { 'system' => '/', - default => "${virtualenv}/bin/", + default => "${virtualenv}", } $pip_env = $virtualenv ? { @@ -64,8 +68,7 @@ define python::requirements ( exec { "python_requirements${name}": provider => shell, - command => "${pip_env} install ${proxy_flag} -r ${requirements}", - cwd => $cwd, + command => "${pip_env} --log-file ${cwd}/pip.log install ${proxy_flag} -r ${requirements}", refreshonly => true, timeout => 1800, user => $owner, -- cgit v1.2.3 From 01bf2791ecadfbb954b947fefa8b15ca0c0b9947 Mon Sep 17 00:00:00 2001 From: Fotis Gimian Date: Tue, 4 Jun 2013 09:36:33 +1000 Subject: Amended all documentation and updated version to 1.1.0 --- manifests/requirements.pp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'manifests/requirements.pp') diff --git a/manifests/requirements.pp b/manifests/requirements.pp index 3019a46..789c0d3 100644 --- a/manifests/requirements.pp +++ b/manifests/requirements.pp @@ -13,6 +13,12 @@ # [*proxy*] # Proxy server to use for outbound connections. Default: none # +# [*owner*] +# The owner of the virtualenv being manipulated. Default: root +# +# [*group*] +# The group relating to the virtualenv being manipulated. Default: root +# # === Examples # # python::requirements { '/var/www/project1/requirements.txt': @@ -24,6 +30,7 @@ # # Sergey Stankevich # Ashley Penney +# Fotis Gimian # define python::requirements ( $requirements = $name, -- cgit v1.2.3 From 8608958fe1bb7fec4bb75c65bd6b1f1e236e88bd Mon Sep 17 00:00:00 2001 From: Fotis Gimian Date: Tue, 4 Jun 2013 11:25:48 +1000 Subject: Removed unnecessary which commands for obtaining the pip and python executables --- manifests/requirements.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'manifests/requirements.pp') diff --git a/manifests/requirements.pp b/manifests/requirements.pp index 789c0d3..ba16d1e 100644 --- a/manifests/requirements.pp +++ b/manifests/requirements.pp @@ -50,7 +50,7 @@ define python::requirements ( } $pip_env = $virtualenv ? { - 'system' => '`which pip`', + 'system' => 'pip', default => "${virtualenv}/bin/pip", } -- cgit v1.2.3 From d3d69488a9a9f2bf2edd170ea6db31830690e8d9 Mon Sep 17 00:00:00 2001 From: Fotis Gimian Date: Tue, 4 Jun 2013 11:55:04 +1000 Subject: Added environment parameter to requirements and virtualenv classes and incremented version to 1.1.3 --- manifests/requirements.pp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'manifests/requirements.pp') diff --git a/manifests/requirements.pp b/manifests/requirements.pp index ba16d1e..67906fc 100644 --- a/manifests/requirements.pp +++ b/manifests/requirements.pp @@ -10,15 +10,18 @@ # [*virtualenv*] # virtualenv to run pip in. Default: system-wide # -# [*proxy*] -# Proxy server to use for outbound connections. Default: none -# # [*owner*] # The owner of the virtualenv being manipulated. Default: root # # [*group*] # The group relating to the virtualenv being manipulated. Default: root # +# [*proxy*] +# Proxy server to use for outbound connections. Default: none +# +# [*environment*] +# Additional environment variables required to install the packages. Default: none +# # === Examples # # python::requirements { '/var/www/project1/requirements.txt': @@ -35,9 +38,10 @@ define python::requirements ( $requirements = $name, $virtualenv = 'system', - $proxy = false, $owner = 'root', - $group = 'root' + $group = 'root', + $proxy = false, + $environment = [] ) { if $virtualenv == 'system' and ($owner != 'root' or $group != 'root') { @@ -80,6 +84,7 @@ define python::requirements ( timeout => 1800, user => $owner, subscribe => File[$requirements], + environment => $environment, } } -- cgit v1.2.3 From 4f2c04b70452249e6917859fdbf02bd90ec3af79 Mon Sep 17 00:00:00 2001 From: Antonis Christofides Date: Tue, 8 Oct 2013 17:59:17 +0300 Subject: Added src parameter for pip in python::requirements A requirements file can have --editable resources; in such a case the pip default is to install them in ~/src/, which can be unsuitable; for example, if run by root, /root/src/ is usually unreadable by other users. pip provides an --src parameter to specify an alternative directory. This is useful for installing requirements systemwide, outside a virtualenv. --- manifests/requirements.pp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'manifests/requirements.pp') diff --git a/manifests/requirements.pp b/manifests/requirements.pp index 67906fc..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-file ${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, -- 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 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'manifests/requirements.pp') 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, -- 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(-) (limited to 'manifests/requirements.pp') 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 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(+) (limited to 'manifests/requirements.pp') 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 2865f4fb87ea7e5831ed497ddb90999f83913b7e Mon Sep 17 00:00:00 2001 From: wimh Date: Fri, 18 Jul 2014 18:46:27 +0200 Subject: allow to specify directory from which to run the "pip install" command --- manifests/requirements.pp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'manifests/requirements.pp') diff --git a/manifests/requirements.pp b/manifests/requirements.pp index 11c5f00..2373337 100644 --- a/manifests/requirements.pp +++ b/manifests/requirements.pp @@ -32,6 +32,9 @@ # requirements file - Useful for when the requirements file is written as part of a # resource other than file (E.g vcsrepo) # +# [*cwd*] +# The directory from which to run the "pip install" command. Default: undef +# # === Examples # # python::requirements { '/var/www/project1/requirements.txt': @@ -54,13 +57,14 @@ define python::requirements ( $src = false, $environment = [], $forceupdate = false, + $cwd = undef, ) { if $virtualenv == 'system' and ($owner != 'root' or $group != 'root') { fail('python::pip: root user must be used when virtualenv is system') } - $cwd = $virtualenv ? { + $rootdir = $virtualenv ? { 'system' => '/', default => $virtualenv, } @@ -96,9 +100,10 @@ define python::requirements ( exec { "python_requirements${name}": provider => shell, - command => "${pip_env} --log ${cwd}/pip.log install ${proxy_flag} ${src_flag} -r ${requirements}", + command => "${pip_env} --log ${rootdir}/pip.log install ${proxy_flag} ${src_flag} -r ${requirements}", refreshonly => !$forceupdate, timeout => 1800, + cwd => $cwd, user => $owner, subscribe => File[$requirements], environment => $environment, -- cgit v1.2.3 From abf49f05202f3c10b3a60c15ae3c0d9bfe1eb65c Mon Sep 17 00:00:00 2001 From: Ray Lehtiniemi Date: Thu, 24 Jul 2014 09:32:52 -0600 Subject: Don't override PATH while installing requirements.txt Setting the path here causes installation failures if some package in requirements.txt needs tools which happen to be installed in a non-system location. Leave path alone so caller can use Exec { path=>[...] } or similar to locate the desired tools. Signed-off-by: Ray Lehtiniemi --- manifests/requirements.pp | 1 - 1 file changed, 1 deletion(-) (limited to 'manifests/requirements.pp') diff --git a/manifests/requirements.pp b/manifests/requirements.pp index 2373337..d9b6242 100644 --- a/manifests/requirements.pp +++ b/manifests/requirements.pp @@ -107,7 +107,6 @@ define python::requirements ( user => $owner, subscribe => File[$requirements], environment => $environment, - path => ['/usr/local/bin','/usr/bin','/bin', '/usr/sbin'], } } -- cgit v1.2.3