Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,25 @@ Creates Python virtualenv.
timeout => 0,
}

### python::virtualenv_exec

Creates Python virtualenv_exec.

**environment** - Additional environment variables required to install the packages. Default: none

**path** - Specifies the PATH variable. Default: [ '/bin', '/usr/bin', '/usr/sbin' ]

**cwd** - The directory from which to run the "pip install" command. Default: /tmp

**command** - The command you want to run in the virtualenv

**exec_unless** - Do not execute the command if eval is true. Default false

python::virtualenv_exec { '/var/www/project1':
command => 'django-admin.py collectstatic --settings=peer.settings',
exec_unless => 'ls /tmp/foo >/dev/null',
}

### python::gunicorn

Manages Gunicorn virtual hosts.
Expand Down
51 changes: 51 additions & 0 deletions manifests/virtualenv_exec.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# == Define: python::virtualenv_exec
#
# Creates Python virtualenv_exec.
#
# === Parameters
#
# [*environment*]
# Additional environment variables required to install the packages. Default: none
#
# [*path*]
# Specifies the PATH variable. Default: [ '/bin', '/usr/bin', '/usr/sbin' ]
#
# [*cwd*]
# The directory from which to run the "pip install" command. Default: /tmp
#
# [*command*]
# The command you want to run in the virtualenv
#
# [*exec_unless*]
# Do not execute the command if eval is true. Default false
#
# === Examples
#
# python::virtualenv { '/var/www/project1':
# command => 'django-admin.py collectstatic --settings=peer.settings',
# exec_unless => 'ls /tmp/foo >/dev/null 2>&1',
# }
#
# === Authors
#
# Anders Lördal

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aren't you the only author of this function?

#
define python::virtualenv_exec (
$environment = [],
$path = [ '/bin', '/usr/bin', '/usr/sbin','/usr/local/bin' ],
$cwd = "/tmp",
$command = '',
$exec_unless = 'false',
) {

$venv_dir = $name

exec { "python_virtualenv_exec_${venv_dir}":
command => "/bin/bash -lic 'source ${venv_dir}/bin/activate && ${command}'",
user => $owner,
path => $path,
cwd => $cwd,
environment => $environment,
unless => $exec_unless,
}
}