service.pp 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. # Class: nginx::service
  2. #
  3. # This module manages NGINX service management and vhost rebuild
  4. #
  5. # Parameters:
  6. #
  7. # There are no default parameters for this class.
  8. #
  9. # Actions:
  10. #
  11. # Requires:
  12. #
  13. # Sample Usage:
  14. #
  15. # This class file is not called directly
  16. class nginx::service(
  17. $configtest_enable = $nginx::params::nx_configtest_enable,
  18. $service_restart = $nginx::params::nx_service_restart
  19. ) {
  20. exec { 'rebuild-nginx-vhosts':
  21. command => "/bin/cat ${nginx::params::nx_temp_dir}/nginx.d/* > ${nginx::params::nx_conf_dir}/conf.d/vhost_autogen.conf",
  22. refreshonly => true,
  23. unless => "/usr/bin/test ! -f ${nginx::params::nx_temp_dir}/nginx.d/*",
  24. subscribe => File["${nginx::params::nx_temp_dir}/nginx.d"],
  25. }
  26. exec { 'rebuild-nginx-mailhosts':
  27. command => "/bin/cat ${nginx::params::nx_temp_dir}/nginx.mail.d/* > ${nginx::params::nx_conf_dir}/conf.mail.d/vhost_autogen.conf",
  28. refreshonly => true,
  29. unless => "/usr/bin/test ! -f ${nginx::params::nx_temp_dir}/nginx.mail.d/*",
  30. subscribe => File["${nginx::params::nx_temp_dir}/nginx.mail.d"],
  31. }
  32. service { "nginx":
  33. ensure => running,
  34. enable => true,
  35. hasstatus => true,
  36. hasrestart => true,
  37. subscribe => Exec['rebuild-nginx-vhosts', 'rebuild-nginx-mailhosts'],
  38. }
  39. if $configtest_enable == true {
  40. Service["nginx"] {
  41. restart => $service_restart,
  42. }
  43. }
  44. }