## puppet_cd::server::service.pp
# Module name: puppet_cd
# Author: Arne Teuke (arne_teuke@confdroid)
# @summary  Class manages the puppet server service for the puppet_cd module.
###############################################################################
class puppet_cd::server::service (

) inherits puppet_cd::params {
  require puppet_cd::main::files

  # manage agent service on all nodes
  service { $pt_agent_service:
    ensure     => running,
    hasstatus  => true,
    hasrestart => true,
    enable     => true,
  }

  # manage puppet server service
  if $fqdn == $pt_pm_fqdn {
    require puppet_cd::firewall::iptables
    require puppet_cd::main::user

    service { $pt_server_service:
      ensure     => running,
      hasstatus  => true,
      hasrestart => true,
      enable     => true,
    }
  }

  # manage puppetdb service
  if $fqdn == $pt_db_fqdn {
    require puppet_cd::firewall::iptables

    service { $pt_db_service:
      ensure     => running,
      hasstatus  => true,
      hasrestart => true,
      enable     => true,
    }
  }
}
