From 432f96236f37c0e3805a8d8878608731a1b624f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20L=C3=B6rdal?= Date: Mon, 13 Oct 2014 10:58:38 +0200 Subject: [PATCH 1/4] Added virtualenv_exec.pp --- manifests/virtualenv_exec.pp | 55 ++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 manifests/virtualenv_exec.pp diff --git a/manifests/virtualenv_exec.pp b/manifests/virtualenv_exec.pp new file mode 100644 index 00000000..fd5239b3 --- /dev/null +++ b/manifests/virtualenv_exec.pp @@ -0,0 +1,55 @@ +# == 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', +# } +# +# === Authors +# +# Sergey Stankevich +# Ashley Penney +# Marc Fournier +# Fotis Gimian +# Anders Lördal +# +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, + } +} From ba93756be35814f2a334507b1df49297510c9e00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20L=C3=B6rdal?= Date: Mon, 13 Oct 2014 11:04:48 +0200 Subject: [PATCH 2/4] Added documentation in readme --- README.md | 19 +++++++++++++++++++ manifests/virtualenv_exec.pp | 4 ++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6aa0c986..61362bce 100644 --- a/README.md +++ b/README.md @@ -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 + +**execunless** - Do not execute the command if eval is true. Default false + + python::virtualenv { '/var/www/project1': + command => 'django-admin.py collectstatic --settings=peer.settings', + execunless => 'ls /tmp/foo >/dev/null', + } + ### python::gunicorn Manages Gunicorn virtual hosts. diff --git a/manifests/virtualenv_exec.pp b/manifests/virtualenv_exec.pp index fd5239b3..4d378b1d 100644 --- a/manifests/virtualenv_exec.pp +++ b/manifests/virtualenv_exec.pp @@ -39,7 +39,7 @@ $path = [ '/bin', '/usr/bin', '/usr/sbin','/usr/local/bin' ], $cwd = "/tmp", $command = '', - $exec_unless = 'false', + $execunless = 'false', ) { $venv_dir = $name @@ -50,6 +50,6 @@ path => $path, cwd => $cwd, environment => $environment, - unless => $exec_unless, + unless => $execunless, } } From 38a27e725087fd67e377e7ef62d4bd07c1b8efb6 Mon Sep 17 00:00:00 2001 From: Weazl Date: Mon, 13 Oct 2014 19:24:21 +0200 Subject: [PATCH 3/4] Corrected typos --- README.md | 2 +- manifests/virtualenv_exec.pp | 8 ++------ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 61362bce..dc689a4a 100644 --- a/README.md +++ b/README.md @@ -150,7 +150,7 @@ Creates Python virtualenv_exec. **execunless** - Do not execute the command if eval is true. Default false - python::virtualenv { '/var/www/project1': + python::virtualenv_exec { '/var/www/project1': command => 'django-admin.py collectstatic --settings=peer.settings', execunless => 'ls /tmp/foo >/dev/null', } diff --git a/manifests/virtualenv_exec.pp b/manifests/virtualenv_exec.pp index 4d378b1d..de5eca5b 100644 --- a/manifests/virtualenv_exec.pp +++ b/manifests/virtualenv_exec.pp @@ -16,22 +16,18 @@ # [*command*] # The command you want to run in the virtualenv # -# [*exec_unless*] +# [*execunless*] # 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', +# execunless => 'ls /tmp/foo >/dev/null 2>&1', # } # # === Authors # -# Sergey Stankevich -# Ashley Penney -# Marc Fournier -# Fotis Gimian # Anders Lördal # define python::virtualenv_exec ( From e6de6ee1460e94ec9a46b5f2fe98f0138bc29c7f Mon Sep 17 00:00:00 2001 From: Weazl Date: Mon, 13 Oct 2014 19:27:59 +0200 Subject: [PATCH 4/4] Renamed variable --- README.md | 4 ++-- manifests/virtualenv_exec.pp | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index dc689a4a..f3b6d6ba 100644 --- a/README.md +++ b/README.md @@ -148,11 +148,11 @@ Creates Python virtualenv_exec. **command** - The command you want to run in the virtualenv -**execunless** - Do not execute the command if eval is true. Default false +**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', - execunless => 'ls /tmp/foo >/dev/null', + exec_unless => 'ls /tmp/foo >/dev/null', } ### python::gunicorn diff --git a/manifests/virtualenv_exec.pp b/manifests/virtualenv_exec.pp index de5eca5b..43afb275 100644 --- a/manifests/virtualenv_exec.pp +++ b/manifests/virtualenv_exec.pp @@ -16,14 +16,14 @@ # [*command*] # The command you want to run in the virtualenv # -# [*execunless*] +# [*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', -# execunless => 'ls /tmp/foo >/dev/null 2>&1', +# exec_unless => 'ls /tmp/foo >/dev/null 2>&1', # } # # === Authors @@ -35,7 +35,7 @@ $path = [ '/bin', '/usr/bin', '/usr/sbin','/usr/local/bin' ], $cwd = "/tmp", $command = '', - $execunless = 'false', + $exec_unless = 'false', ) { $venv_dir = $name @@ -46,6 +46,6 @@ path => $path, cwd => $cwd, environment => $environment, - unless => $execunless, + unless => $exec_unless, } }