2015-10-30 20:04:42 +00:00
|
|
|
class profile::puppetmaster (
|
|
|
|
$webhook_username,
|
|
|
|
$webhook_password
|
|
|
|
) {
|
2015-08-03 21:44:35 +00:00
|
|
|
|
|
|
|
class { 'hiera':
|
|
|
|
hierarchy => [
|
2015-08-18 21:01:20 +00:00
|
|
|
'virtual/%{::virtual}',
|
2015-08-14 00:10:55 +00:00
|
|
|
'nodes/%{::trusted.certname}',
|
|
|
|
'common',
|
2015-08-03 21:44:35 +00:00
|
|
|
],
|
|
|
|
hiera_yaml => '/etc/puppetlabs/code/hiera.yaml',
|
2015-08-14 17:41:03 +00:00
|
|
|
datadir => '/etc/puppetlabs/code/environments/%{environment}/hieradata',
|
2015-11-17 22:10:45 +00:00
|
|
|
owner => 'pe-puppet',
|
|
|
|
group => 'pe-puppet',
|
2015-10-15 19:22:45 +00:00
|
|
|
notify => Service['pe-puppetserver'],
|
2015-08-03 21:44:35 +00:00
|
|
|
}
|
2015-08-14 23:17:25 +00:00
|
|
|
|
|
|
|
#BEGIN - Generate an SSH key for r10k to connect to git
|
|
|
|
$r10k_ssh_key_file = '/root/.ssh/r10k_rsa'
|
|
|
|
exec { 'create r10k ssh key' :
|
|
|
|
command => "/usr/bin/ssh-keygen -t rsa -b 2048 -C 'r10k' -f ${r10k_ssh_key_file} -q -N ''",
|
|
|
|
creates => $r10k_ssh_key_file,
|
|
|
|
}
|
|
|
|
#END - Generate an SSH key for r10k to connect to git
|
2015-10-30 20:42:33 +00:00
|
|
|
|
2015-08-17 21:00:21 +00:00
|
|
|
#BEGIN - Add deploy key and webook to git management system
|
2015-08-14 23:17:25 +00:00
|
|
|
$git_management_system = hiera('git_management_system', '')
|
|
|
|
|
|
|
|
if $git_management_system in ['gitlab', 'github'] {
|
2015-10-30 20:42:33 +00:00
|
|
|
|
2015-10-28 20:16:36 +00:00
|
|
|
git_deploy_key { "add_deploy_key_to_puppet_control-${::fqdn}":
|
2015-10-30 20:42:33 +00:00
|
|
|
ensure => present,
|
|
|
|
name => $::fqdn,
|
|
|
|
path => "${r10k_ssh_key_file}.pub",
|
|
|
|
token => hiera('gms_api_token'),
|
|
|
|
project_name => 'puppet/control-repo',
|
|
|
|
server_url => hiera('gms_server_url'),
|
|
|
|
provider => $git_management_system,
|
2015-08-14 23:17:25 +00:00
|
|
|
}
|
|
|
|
|
2015-10-28 20:16:36 +00:00
|
|
|
git_webhook { "web_post_receive_webhook-${::fqdn}" :
|
2015-10-28 17:37:59 +00:00
|
|
|
ensure => present,
|
2015-10-30 20:04:42 +00:00
|
|
|
webhook_url => "https://${webhook_username}:${webhook_password}@${::fqdn}:8088/payload",
|
2015-10-28 17:37:59 +00:00
|
|
|
token => hiera('gms_api_token'),
|
|
|
|
project_name => 'puppet/control-repo',
|
|
|
|
server_url => hiera('gms_server_url'),
|
|
|
|
provider => $git_management_system,
|
|
|
|
disable_ssl_verify => true,
|
2015-08-17 21:00:21 +00:00
|
|
|
}
|
|
|
|
|
2015-08-14 23:17:25 +00:00
|
|
|
}
|
2015-08-17 21:00:21 +00:00
|
|
|
#END - Add deploy key and webhook to git management system
|
2015-08-14 23:17:25 +00:00
|
|
|
|
2015-10-26 21:59:20 +00:00
|
|
|
#Lay down update-classes.sh for use in r10k postrun_command
|
|
|
|
#This is configured via the pe_r10k::postrun key in hiera
|
|
|
|
file { '/usr/local/bin/update-classes.sh' :
|
|
|
|
ensure => file,
|
2015-10-26 22:12:39 +00:00
|
|
|
source => 'puppet:///modules/profile/puppetmaster/update-classes.sh',
|
2015-10-30 20:42:33 +00:00
|
|
|
mode => '0755',
|
2015-10-26 21:59:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#https://docs.puppetlabs.com/puppet/latest/reference/config_file_environment.html#environmenttimeout
|
2015-10-30 20:42:33 +00:00
|
|
|
ini_setting { 'environment_timeout = unlimited':
|
2015-10-26 21:59:20 +00:00
|
|
|
ensure => present,
|
|
|
|
path => '/etc/puppetlabs/puppet/puppet.conf',
|
|
|
|
section => 'main',
|
|
|
|
setting => 'environment_timeout',
|
|
|
|
value => 'unlimited',
|
2015-10-28 17:37:59 +00:00
|
|
|
notify => Service['pe-puppetserver'],
|
2015-10-26 21:59:20 +00:00
|
|
|
}
|
|
|
|
|
2015-08-03 21:44:35 +00:00
|
|
|
}
|