Skip to content

Commit 0ee4d8d

Browse files
author
Oded Simon
committed
add -i <address option to install pip packages to the exec commands
1 parent cd190e9 commit 0ee4d8d

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

manifests/virtualenv.pp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
# requirements => '/var/www/project1/requirements.txt',
3131
# proxy => 'http://proxy.domain.com:3128',
3232
# systempkgs => true,
33+
# index => 'http://www.example.com/simple/'
3334
# }
3435
#
3536
# === Authors
@@ -47,6 +48,7 @@
4748
$distribute = true,
4849
$owner = 'root',
4950
$group = 'root'
51+
$index = false,
5052
) {
5153

5254
$venv_dir = $name
@@ -77,12 +79,17 @@
7779
true => 'distribute',
7880
default => '',
7981
}
82+
$pypi_index = $index ? {
83+
false => '',
84+
default => "-i ${index}",
85+
}
86+
8087

8188
exec { "python_virtualenv_${venv_dir}":
8289
command => "mkdir -p ${venv_dir} \
8390
${proxy_command} \
8491
&& virtualenv -p `which ${python}` ${system_pkgs_flag} ${venv_dir} \
85-
&& ${venv_dir}/bin/pip install ${proxy_flag} --upgrade ${distribute_pkg} pip",
92+
&& ${venv_dir}/bin/pip install ${pypi_index} ${proxy_flag} --upgrade ${distribute_pkg} pip",
8693
user => $owner,
8794
creates => $venv_dir,
8895
path => [ '/bin', '/usr/bin', '/usr/sbin' ],
@@ -98,7 +105,7 @@
98105

99106
if $requirements {
100107
exec { "python_requirements_initial_install_${requirements}_${venv_dir}":
101-
command => "${venv_dir}/bin/pip install ${proxy_flag} --requirement ${requirements}",
108+
command => "${venv_dir}/bin/pip install ${pypi_index} ${proxy_flag} --requirement ${requirements}",
102109
refreshonly => true,
103110
timeout => 1800,
104111
user => $owner,

0 commit comments

Comments
 (0)