class puppet_dashboard_apache {
        class {'apache':
                default_vhost => false,
                default_mods => false,
                server_signature => "Off",
                server_tokens => "Prod",
        }
        apache::vhost { "$fqdn":
                port    => '443',
                docroot => "/var/www/html",
                options => "None",
                ssl     => true,
		default_vhost => true,
#		proxy_dest => "http://localhost:3000"
		proxy_pass => [
		    { 'path' => '/', 'url' => 'http://localhost:3000/' },
  		],
	}
}

class puppet_server {
	include puppet_dashboard_apache
	# http://lanopuljic.com/articles/installing-puppet-dashboard/
	package {"puppet-server": }
	service { "puppetmaster":
		ensure => "running",
		enable => "true",
		require => Package["puppet-server"],
	}
	augeas{"master-report" :
		context => "/files/etc/puppet/puppet.conf",
		changes => "set master/reports store,http",
		notify => Service["puppetmaster"],
	}
	augeas{"master-reporturl" :
		context => "/files/etc/puppet/puppet.conf",
		changes => "set master/reporturl http://puppet.$domain:3000/reports/upload",
		notify => Service["puppetmaster"],
	}
	include '::mysql::server'
	package {"puppet-dashboard":}
	service { "puppet-dashboard":
		ensure => "running",
		enable => "true",
		require => Package["puppet-dashboard"],
	}
	# /usr/share/puppet-dashboard/config/settings.yml: enable_inventory_service: true
}

class puppet_agent {
	# TODO Windows support, augeas is not supported there
	# https://tickets.puppetlabs.com/browse/ENTERPRISE-45
	if ($kernel == "Linux") {
		augeas{"agent-report" :
			context => "/files/etc/puppet/puppet.conf",
			changes => "set agent/report true",
		}
	}
	service { "puppet":
		ensure => "running",
		enable => "true",
	}
}

