gunicorn.pp 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. # == Define: python::gunicorn
  2. #
  3. # Manages Gunicorn virtual hosts.
  4. #
  5. # === Parameters
  6. #
  7. # [*ensure*]
  8. # present|absent. Default: present
  9. #
  10. # [*virtualenv*]
  11. # Run in virtualenv, specify directory. Default: disabled
  12. #
  13. # [*mode*]
  14. # Gunicorn mode.
  15. # wsgi|django. Default: wsgi
  16. #
  17. # [*dir*]
  18. # Application directory.
  19. #
  20. # [*bind*]
  21. # Bind on: 'HOST', 'HOST:PORT', 'unix:PATH'.
  22. # Default: system-wide: unix:/tmp/gunicorn-$name.socket
  23. # virtualenv: unix:${virtualenv}/${name}.socket
  24. #
  25. # [*environment*]
  26. # Set ENVIRONMENT variable. Default: none
  27. #
  28. # [*template*]
  29. # Which ERB template to use. Default: python/gunicorn.erb
  30. #
  31. # === Examples
  32. #
  33. # python::gunicorn { 'vhost':
  34. # ensure => present,
  35. # virtualenv => '/var/www/project1',
  36. # mode => 'wsgi',
  37. # dir => '/var/www/project1/current',
  38. # bind => 'unix:/tmp/gunicorn.socket',
  39. # environment => 'prod',
  40. # template => 'python/gunicorn.erb',
  41. # }
  42. #
  43. # === Authors
  44. #
  45. # Sergey Stankevich
  46. # Ashley Penney
  47. # Marc Fournier
  48. #
  49. define python::gunicorn (
  50. $ensure = present,
  51. $virtualenv = false,
  52. $mode = 'wsgi',
  53. $dir = false,
  54. $bind = false,
  55. $environment = false,
  56. $template = 'python/gunicorn.erb',
  57. ) {
  58. # Parameter validation
  59. if ! $dir {
  60. fail('python::gunicorn: dir parameter must not be empty')
  61. }
  62. file { "/etc/gunicorn.d/${name}":
  63. ensure => $ensure,
  64. mode => '0644',
  65. owner => 'root',
  66. group => 'root',
  67. content => template($template),
  68. }
  69. }