From 3149d9707f2882bdd4bc499a2bc65fb6dff36bf9 Mon Sep 17 00:00:00 2001 From: Nick Walker Date: Fri, 30 Oct 2015 13:42:33 -0700 Subject: [PATCH] Refactor webhook profiles into one profile with a parameter Previously there was a mcollective and no_mcollective version of the webhook profile. They were almost identical so I merged them and manage the difference with a "use_mcollective" parameter. I renamed the webhook profile to zack_r10k_webhook. --- site/profile/manifests/puppetmaster.pp | 22 +++++++++---------- site/profile/manifests/webhook_mcollective.pp | 15 ------------- ...no_mcollective.pp => zack_r10k_webhook.pp} | 15 ++++++++++--- site/role/manifests/all_in_one_pe.pp | 2 +- 4 files changed, 24 insertions(+), 30 deletions(-) delete mode 100644 site/profile/manifests/webhook_mcollective.pp rename site/profile/manifests/{webhook_no_mcollective.pp => zack_r10k_webhook.pp} (57%) diff --git a/site/profile/manifests/puppetmaster.pp b/site/profile/manifests/puppetmaster.pp index d3f1a87..1a199cd 100644 --- a/site/profile/manifests/puppetmaster.pp +++ b/site/profile/manifests/puppetmaster.pp @@ -23,20 +23,20 @@ class profile::puppetmaster ( creates => $r10k_ssh_key_file, } #END - Generate an SSH key for r10k to connect to git - + #BEGIN - Add deploy key and webook to git management system $git_management_system = hiera('git_management_system', '') if $git_management_system in ['gitlab', 'github'] { - + git_deploy_key { "add_deploy_key_to_puppet_control-${::fqdn}": - 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, + 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, } git_webhook { "web_post_receive_webhook-${::fqdn}" : @@ -57,11 +57,11 @@ class profile::puppetmaster ( file { '/usr/local/bin/update-classes.sh' : ensure => file, source => 'puppet:///modules/profile/puppetmaster/update-classes.sh', - mode => '755', + mode => '0755', } #https://docs.puppetlabs.com/puppet/latest/reference/config_file_environment.html#environmenttimeout - ini_setting { "environment_timeout = unlimited": + ini_setting { 'environment_timeout = unlimited': ensure => present, path => '/etc/puppetlabs/puppet/puppet.conf', section => 'main', diff --git a/site/profile/manifests/webhook_mcollective.pp b/site/profile/manifests/webhook_mcollective.pp deleted file mode 100644 index 395cc7a..0000000 --- a/site/profile/manifests/webhook_mcollective.pp +++ /dev/null @@ -1,15 +0,0 @@ -class profile::webhook_mcollective { - - class { 'r10k::mcollective': - notify => Service['mcollective'], - } - - include r10k::webhook::config - - class {'r10k::webhook': - user => 'root', - group => '0', - require => Class['r10k::webhook::config'], - } - -} diff --git a/site/profile/manifests/webhook_no_mcollective.pp b/site/profile/manifests/zack_r10k_webhook.pp similarity index 57% rename from site/profile/manifests/webhook_no_mcollective.pp rename to site/profile/manifests/zack_r10k_webhook.pp index dc7b1aa..7e0bd40 100644 --- a/site/profile/manifests/webhook_no_mcollective.pp +++ b/site/profile/manifests/zack_r10k_webhook.pp @@ -1,14 +1,23 @@ -class profile::webhook_no_mcollective ( +class profile::zack_r10k_webhook ( $username, - $password + $password, + $use_mcollective = false, ) { + if $use_mcollective { + + class { 'r10k::mcollective': + notify => Service['mcollective'], + } + + } + class {'r10k::webhook::config': enable_ssl => true, protected => true, user => $username, pass => $password, - use_mcollective => false, + use_mcollective => $use_mcollective, } class {'r10k::webhook': diff --git a/site/role/manifests/all_in_one_pe.pp b/site/role/manifests/all_in_one_pe.pp index 3762325..6bc2eb3 100644 --- a/site/role/manifests/all_in_one_pe.pp +++ b/site/role/manifests/all_in_one_pe.pp @@ -8,7 +8,7 @@ class role::all_in_one_pe { webhook_password => $webhook_password, } - class { 'profile::webhook_no_mcollective' : + class { 'profile::zack_r10k_webhook' : username => $webhook_username, password => $webhook_password, }