summaryrefslogtreecommitdiff
path: root/manifests/install.pp
blob: cf0f78a5470dae5d3c342d6a27c5be998b8c76ee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
class python::install {

  $python = $python::version ? {
    'system' => 'python',
    default  => "python${python::version}",
  }

  $pythondev = $::operatingsystem ? {
    /(?i:RedHat|CentOS|Fedora)/ => "${python}-devel",
    /(?i:Debian|Ubuntu)/        => "${python}-dev"
  }

  package { $python: ensure => present }

  $dev_ensure = $python::dev ? {
    true    => present,
    default => absent,
  }

  $pip_ensure = $python::pip ? {
    true    => present,
    default => absent,
  }

  package { $pythondev: ensure => $dev_ensure }
  package { 'python-pip': ensure => $pip_ensure }

  $venv_ensure = $python::virtualenv ? {
    true    => present,
    default => absent,
    pip => absent,
  }

  case $python::virtualenv {
    'pip': {
      exec { "pip-virtualenv":
        command => "pip install --upgrade virtualenv",
        cwd => $cwd,
        user => $run_as_user,
        timeout => 0,
        path => ["/usr/local/bin","/usr/bin","/bin", "/usr/sbin"],
        require => Package['python-pip']
      }
    }
    default: {
      package { 'python-virtualenv': ensure => $venv_ensure }
    }
  }

  $gunicorn_ensure = $python::gunicorn ? {
    true    => present,
    default => absent,
  }

  package { 'gunicorn': ensure => $gunicorn_ensure }

}