From 58e2182015db0cc8b42c950eb0811bba4c0b6ede Mon Sep 17 00:00:00 2001 From: Americas Date: Fri, 7 Nov 2014 14:50:57 +0000 Subject: [PATCH 01/11] added new define git::config to setup github configurations --- manifests/config.pp | 62 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 manifests/config.pp diff --git a/manifests/config.pp b/manifests/config.pp new file mode 100644 index 0000000..9c1c5b6 --- /dev/null +++ b/manifests/config.pp @@ -0,0 +1,62 @@ +# = Define a git config +# +# This sets configuration paramenters for github +# It can be used to set system wide configs or user specific configs +# +# == Parameters: +# +# [*section*] +# The section of the config +# [*key*] +# The name of the config +# [*value*] +# The value for the config +# [*user*] +# The user to save the config (defaults to system config) +# +# == Examples: +# +# - Minimal setup for system config +# github::config { 'color.status' : +# value => 'auto' +# } +# +# - Full setup for user specific config +# github::config { 'color-status' : +# section => 'color', +# key => 'status', +# value => 'auto', +# user => $::id +# } + +define git::config( + $section = '', + $key = '', + $value, + $user = '' +) { + + include git + + if empty($user) { + $real_command = "git config --system" + } + else { + validate_string($user) + $real_command = "sudo -u ${user} git config --global" + } + + if empty($section) and empty($key) { + validate_re($name, '^\w+\.\w+$') + $real_section_key = $name + } + else { + $real_section_key = "${section}.${key}" + } + + exec { $real_section_key: + command => "${real_command} ${real_section_key} \"$value\"", + unless => "test \"`${real_command} ${real_section_key}`\" = \"${value}\"", + require => Package['git'], + } +} \ No newline at end of file From 69d9d37034f0ccc4ccfb5549b11c86260e468e59 Mon Sep 17 00:00:00 2001 From: Americas Date: Mon, 10 Nov 2014 12:17:06 +0000 Subject: [PATCH 02/11] unless to onlyif --- manifests/config.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/config.pp b/manifests/config.pp index 9c1c5b6..d16280c 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -56,7 +56,7 @@ exec { $real_section_key: command => "${real_command} ${real_section_key} \"$value\"", - unless => "test \"`${real_command} ${real_section_key}`\" = \"${value}\"", + onlyif => "test \"`${real_command} ${real_section_key}`\" = \"${value}\"", require => Package['git'], } } \ No newline at end of file From c88ba1bfd494b761c79eb7cbf012e97f99d329ef Mon Sep 17 00:00:00 2001 From: Americas Date: Mon, 10 Nov 2014 12:21:56 +0000 Subject: [PATCH 03/11] removed some " --- manifests/config.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/config.pp b/manifests/config.pp index d16280c..6b85557 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -56,7 +56,7 @@ exec { $real_section_key: command => "${real_command} ${real_section_key} \"$value\"", - onlyif => "test \"`${real_command} ${real_section_key}`\" = \"${value}\"", + onlyif => "test `${real_command} ${real_section_key}` = \"${value}\"", require => Package['git'], } } \ No newline at end of file From 6cde371b6d3fd12d995dce158c9d024791c72616 Mon Sep 17 00:00:00 2001 From: Americas Date: Mon, 10 Nov 2014 12:26:34 +0000 Subject: [PATCH 04/11] tryhard --- manifests/config.pp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/manifests/config.pp b/manifests/config.pp index 6b85557..47bc76f 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -55,8 +55,9 @@ } exec { $real_section_key: + path => "/bin", command => "${real_command} ${real_section_key} \"$value\"", - onlyif => "test `${real_command} ${real_section_key}` = \"${value}\"", + unless => "test \"`${real_command} ${real_section_key}`\" = \"${value}\"", require => Package['git'], } } \ No newline at end of file From 6e9a911230be3b0d24a589028bb86d408880f722 Mon Sep 17 00:00:00 2001 From: Americas Date: Tue, 11 Nov 2014 18:43:27 +0000 Subject: [PATCH 05/11] fix test --- manifests/config.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/config.pp b/manifests/config.pp index 47bc76f..378b543 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -57,7 +57,7 @@ exec { $real_section_key: path => "/bin", command => "${real_command} ${real_section_key} \"$value\"", - unless => "test \"`${real_command} ${real_section_key}`\" = \"${value}\"", + onlyif => "${real_command} ${real_section_key} | grep -c '${value}'", require => Package['git'], } } \ No newline at end of file From f677332a834f8626f2a64a41dca3e8cc878cf73a Mon Sep 17 00:00:00 2001 From: Americas Date: Tue, 11 Nov 2014 18:52:00 +0000 Subject: [PATCH 06/11] w/out testing --- manifests/config.pp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manifests/config.pp b/manifests/config.pp index 378b543..0ecb0a5 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -56,8 +56,8 @@ exec { $real_section_key: path => "/bin", - command => "${real_command} ${real_section_key} \"$value\"", - onlyif => "${real_command} ${real_section_key} | grep -c '${value}'", + command => "${real_command} ${real_section_key} \"${value}\"", + #onlyif => "${real_command} ${real_section_key} | grep -c '${value}'", require => Package['git'], } } \ No newline at end of file From 1e052986fb6c1e5e4647c6608e7198f0a5c7f109 Mon Sep 17 00:00:00 2001 From: Americas Date: Wed, 12 Nov 2014 10:12:36 +0000 Subject: [PATCH 07/11] no path --- manifests/config.pp | 1 - 1 file changed, 1 deletion(-) diff --git a/manifests/config.pp b/manifests/config.pp index 0ecb0a5..a8eb3f9 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -55,7 +55,6 @@ } exec { $real_section_key: - path => "/bin", command => "${real_command} ${real_section_key} \"${value}\"", #onlyif => "${real_command} ${real_section_key} | grep -c '${value}'", require => Package['git'], From a1b6f8e7a59dde3e551bff5c85bd72665cd09d37 Mon Sep 17 00:00:00 2001 From: Americas Date: Wed, 12 Nov 2014 10:16:06 +0000 Subject: [PATCH 08/11] with better path --- manifests/config.pp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/manifests/config.pp b/manifests/config.pp index a8eb3f9..c4a5f8a 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -55,8 +55,9 @@ } exec { $real_section_key: + path => "/usr/local/bin/:/bin/", command => "${real_command} ${real_section_key} \"${value}\"", - #onlyif => "${real_command} ${real_section_key} | grep -c '${value}'", + onlyif => "${real_command} ${real_section_key} | grep -c '${value}'", require => Package['git'], } } \ No newline at end of file From 03805157812e8b7a54ea0c5920dc7d726c94bb5d Mon Sep 17 00:00:00 2001 From: Americas Date: Wed, 12 Nov 2014 10:17:44 +0000 Subject: [PATCH 09/11] more paths --- manifests/config.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/config.pp b/manifests/config.pp index c4a5f8a..32e262c 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -55,7 +55,7 @@ } exec { $real_section_key: - path => "/usr/local/bin/:/bin/", + path => "/usr/local/bin/:/bin/:/usr/bin/", command => "${real_command} ${real_section_key} \"${value}\"", onlyif => "${real_command} ${real_section_key} | grep -c '${value}'", require => Package['git'], From 5167e34cc28dc9667a9bab3dc351fe10ef38cdb4 Mon Sep 17 00:00:00 2001 From: Americas Date: Wed, 12 Nov 2014 10:29:51 +0000 Subject: [PATCH 10/11] onlyif to unless again --- manifests/config.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/config.pp b/manifests/config.pp index 32e262c..fd9a816 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -57,7 +57,7 @@ exec { $real_section_key: path => "/usr/local/bin/:/bin/:/usr/bin/", command => "${real_command} ${real_section_key} \"${value}\"", - onlyif => "${real_command} ${real_section_key} | grep -c '${value}'", + unless => "${real_command} ${real_section_key} | grep -c '${value}'", require => Package['git'], } } \ No newline at end of file From 9c78c309db98ce4c3e4e3558233fe74e014fcb9a Mon Sep 17 00:00:00 2001 From: Americas Date: Wed, 12 Nov 2014 11:26:06 +0000 Subject: [PATCH 11/11] no paths --- manifests/config.pp | 1 - 1 file changed, 1 deletion(-) diff --git a/manifests/config.pp b/manifests/config.pp index fd9a816..d69b7d5 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -55,7 +55,6 @@ } exec { $real_section_key: - path => "/usr/local/bin/:/bin/:/usr/bin/", command => "${real_command} ${real_section_key} \"${value}\"", unless => "${real_command} ${real_section_key} | grep -c '${value}'", require => Package['git'],