Skip to content

Commit ce3562f

Browse files
author
Jarl Stefansson
committed
Conflicts: manifests/pip.pp manifests/virtualenv.pp Merge curly braces around variable names
2 parents 895eebf + 2bab9c9 commit ce3562f

9 files changed

Lines changed: 63 additions & 24 deletions

File tree

Modulefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name 'stankevich-python'
2-
version '1.2.1'
2+
version '1.4.0'
33

44
author 'Sergey Stankevich'
55
license 'Apache License, Version 2.0'

manifests/config.pp

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
# == Define: python::config
2+
#
3+
# Optionally installs the gunicorn service
4+
#
5+
# === Examples
6+
#
7+
# include python::config
8+
#
9+
# === Authors
10+
#
11+
# Sergey Stankevich
12+
# Ashley Penney
13+
# Fotis Gimian
14+
#
15+
116
class python::config {
217

318
Class['python::install'] -> Python::Pip <| |>
@@ -19,5 +34,4 @@
1934
pattern => '/usr/bin/gunicorn',
2035
}
2136
}
22-
23-
}
37+
}

manifests/gunicorn.pp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
# dir => '/var/www/project1/current',
3838
# bind => 'unix:/tmp/gunicorn.socket',
3939
# environment => 'prod',
40+
# owner => 'www-data',
41+
# group => 'www-data',
4042
# template => 'python/gunicorn.erb',
4143
# }
4244
#
@@ -53,6 +55,8 @@
5355
$dir = false,
5456
$bind = false,
5557
$environment = false,
58+
$owner = 'www-data',
59+
$group = 'www-data',
5660
$template = 'python/gunicorn.erb',
5761
) {
5862

manifests/init.pp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@
4444
) {
4545

4646
# Module compatibility check
47-
$compatible = [ 'Debian', 'Ubuntu', 'CentOS', 'RedHat', 'Scientific' ]
48-
if ! ($::operatingsystem in $compatible) {
47+
$compatible = [ 'Debian', 'RedHat']
48+
if ! ($::osfamily in $compatible) {
4949
fail("Module is not compatible with ${::operatingsystem}")
5050
}
5151

manifests/install.pp

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,28 @@
1+
# == Define: python::install
2+
#
3+
# Installs core python packages
4+
#
5+
# === Examples
6+
#
7+
# include python::install
8+
#
9+
# === Authors
10+
#
11+
# Sergey Stankevich
12+
# Ashley Penney
13+
# Fotis Gimian
14+
#
15+
116
class python::install {
217

318
$python = $python::version ? {
419
'system' => 'python',
520
default => "python${python::version}",
621
}
722

8-
$pythondev = $::operatingsystem ? {
9-
/(?i:RedHat|CentOS|Fedora|Scientific)/ => "${python}-devel",
10-
/(?i:Debian|Ubuntu)/ => "${python}-dev"
23+
$pythondev = $::osfamily ? {
24+
RedHat => "${python}-devel",
25+
Debian => "${python}-dev"
1126
}
1227

1328
$dev_ensure = $python::dev ? {

manifests/pip.pp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757

5858
$cwd = $virtualenv ? {
5959
'system' => '/',
60-
default => "${virtualenv}",
60+
default => $virtualenv,
6161
}
6262

6363
$pip_env = $virtualenv ? {
@@ -95,38 +95,38 @@
9595
case $ensure {
9696
present: {
9797
exec { "pip_install_${name}":
98-
command => "$pip_env wheel --help > /dev/null 2>&1 && { pip wheel --version > /dev/null 2>&1 || wheel_support_flag='--no-use-wheel'; } ; $pip_env --log ${cwd}/pip.log install $install_args \$wheel_support_flag ${proxy_flag} ${source}",
99-
unless => "$pip_env freeze | grep -i -e ${grep_regex}",
98+
command => "${pip_env} wheel --help > /dev/null 2>&1 && { ${pip_env} wheel --version > /dev/null 2>&1 || wheel_support_flag='--no-use-wheel'; } ; ${pip_env} --log ${cwd}/pip.log install ${install_args} \$wheel_support_flag ${proxy_flag} ${source}",
99+
unless => "${pip_env} freeze | grep -i -e ${grep_regex}",
100100
user => $owner,
101101
environment => $environment,
102-
path => ["/usr/local/bin","/usr/bin","/bin", "/usr/sbin"],
102+
path => ['/usr/local/bin','/usr/bin','/bin', '/usr/sbin'],
103103
}
104104
}
105105

106106
latest: {
107107
exec { "pip_install_${name}":
108-
command => "$pip_env wheel --help > /dev/null 2>&1&& { pip wheel --version > /dev/null 2>&1 || wheel_support_flag='--no-use-wheel'; } ; $pip_env --log ${cwd}/pip.log install --upgrade \$wheel_support_flag ${proxy_flag} ${source}",
108+
command => "${pip_env} wheel --help > /dev/null 2>&1 && { ${pip_env} wheel --version > /dev/null 2>&1 || wheel_support_flag='--no-use-wheel'; } ; ${pip_env} --log ${cwd}/pip.log install --upgrade \$wheel_support_flag ${proxy_flag} ${source}",
109109
user => $owner,
110110
environment => $environment,
111-
path => ["/usr/local/bin","/usr/bin","/bin", "/usr/sbin"],
111+
path => ['/usr/local/bin','/usr/bin','/bin', '/usr/sbin'],
112112
}
113113
}
114114

115115
latest: {
116116
exec { "pip_install_${name}":
117-
command => "$pip_env wheel --help > /dev/null 2>&1&& { pip wheel --version > /dev/null 2>&1 || wheel_support_flag='--no-use-wheel'; } ; $pip_env --log ${cwd}/pip.log install -U $install_args \$wheel_support_flag ${proxy_flag} ${source}",
117+
command => "${pip_env} wheel --help > /dev/null 2>&1 && { ${pip_env} wheel --version > /dev/null 2>&1 || wheel_support_flag='--no-use-wheel'; } ; ${pip_env} --log ${cwd}/pip.log install -U ${install_args} \$wheel_support_flag ${proxy_flag} ${source}",
118118
user => $owner,
119119
environment => $environment,
120120
}
121121
}
122122

123123
default: {
124124
exec { "pip_uninstall_${name}":
125-
command => "echo y | $pip_env uninstall $uninstall_args ${proxy_flag} ${name}",
126-
onlyif => "$pip_env freeze | grep -i -e ${grep_regex}",
125+
command => "echo y | ${pip_env} uninstall ${uninstall_args} ${proxy_flag} ${name}",
126+
onlyif => "${pip_env} freeze | grep -i -e ${grep_regex}",
127127
user => $owner,
128128
environment => $environment,
129-
path => ["/usr/local/bin","/usr/bin","/bin", "/usr/sbin"],
129+
path => ['/usr/local/bin','/usr/bin','/bin', '/usr/sbin'],
130130
}
131131
}
132132
}

manifests/requirements.pp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@
2727
# [*environment*]
2828
# Additional environment variables required to install the packages. Default: none
2929
#
30+
# [*forceupdate*]
31+
# Run a pip install requirements even if we don't receive an event from the
32+
# requirements file - Useful for when the requirements file is written as part of a
33+
# resource other than file (E.g vcsrepo)
34+
#
3035
# === Examples
3136
#
3237
# python::requirements { '/var/www/project1/requirements.txt':
@@ -47,7 +52,8 @@
4752
$group = 'root',
4853
$proxy = false,
4954
$src = false,
50-
$environment = []
55+
$environment = [],
56+
$forceupdate = false,
5157
) {
5258

5359
if $virtualenv == 'system' and ($owner != 'root' or $group != 'root') {
@@ -56,7 +62,7 @@
5662

5763
$cwd = $virtualenv ? {
5864
'system' => '/',
59-
default => "${virtualenv}",
65+
default => $virtualenv,
6066
}
6167

6268
$pip_env = $virtualenv ? {
@@ -91,7 +97,7 @@
9197
exec { "python_requirements${name}":
9298
provider => shell,
9399
command => "${pip_env} --log ${cwd}/pip.log install ${proxy_flag} ${src_flag} -r ${requirements}",
94-
refreshonly => true,
100+
refreshonly => !$forceupdate,
95101
timeout => 1800,
96102
user => $owner,
97103
subscribe => File[$requirements],

manifests/virtualenv.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@
127127
# version, this makes sure we only use wheels if they are supported
128128

129129
exec { "python_virtualenv_${venv_dir}":
130-
command => "mkdir -p ${venv_dir} ${proxy_command} && virtualenv ${system_pkgs_flag} -p ${python} ${venv_dir} && ${venv_dir}/bin/pip $pip_env wheel --help > /dev/null 2>&1 && { ${venv_dir}/bin/pip wheel --version > /dev/null 2>&1 || wheel_support_flag='--no-use-wheel'; } ; ${venv_dir}/bin/pip --log ${venv_dir}/pip.log install ${pypi_index} ${proxy_flag} \$wheel_support_flag --upgrade pip ${distribute_pkg}",
130+
command => "mkdir -p ${venv_dir} ${proxy_command} && virtualenv ${system_pkgs_flag} -p ${python} ${venv_dir} && ${venv_dir}/bin/pip wheel --help > /dev/null 2>&1 && { ${venv_dir}/bin/pip wheel --version > /dev/null 2>&1 || wheel_support_flag='--no-use-wheel'; } ; ${venv_dir}/bin/pip --log ${venv_dir}/pip.log install ${pypi_index} ${proxy_flag} \$wheel_support_flag --upgrade pip ${distribute_pkg}",
131131
user => $owner,
132132
path => $path,
133133
cwd => "/tmp",

templates/gunicorn.erb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ CONFIG = {
1313
},
1414
<% end -%>
1515
'working_dir': '<%= @dir %>',
16-
'user': 'www-data',
17-
'group': 'www-data',
16+
'user': '<%= @owner %>',
17+
'group': '<%= @group %>',
1818
<% if @virtualenv -%>
1919
'python': '<%= @virtualenv %>/bin/python',
2020
<% else -%>

0 commit comments

Comments
 (0)