-
-
Save RA80533/c36e856820c63e6abbcaeba686ce3f15 to your computer and use it in GitHub Desktop.
Manage System Git Config with Puppet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class myweb::sites::wiki_example_com { | |
wiki_base = '/var/www/sites/wiki.example.com' | |
include ::profile::gitconfig | |
profile::gitconfig::safe_directory {"${wiki_base}/code/mediawiki-1.35-LTS":} | |
vcsrepo { "${wiki_base}/code/mediawiki-1.35-LTS/": | |
ensure => latest, | |
provider => git, | |
source => '[email protected]:wiki/mediawiki-1.35-LTS.git', | |
revision => 'master', | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# == Class: profile::gitconfig | |
# | |
# Control System-Wide Git Configuration | |
# | |
# === Authors | |
# | |
# Yehuda Katz <[email protected]> | |
# | |
class profile::gitconfig { | |
$gitconfig_file = lookup('profile::gitconfig::file', {default_value => '/etc/gitconfig'}) | |
$gitconfig_dir = lookup('profile::gitconfig::dir', {default_value => '/etc/gitconfig.d'}) | |
Concat::Fragment <| tag == gitconfig |> -> Vcsrepo <| |> | |
file { $gitconfig_file: | |
ensure => present, | |
owner => 'root', | |
group => 'root', | |
mode => '0644', | |
} | |
file { $gitconfig_dir: | |
ensure => directory, | |
owner => 'root', | |
group => 'root', | |
mode => '0755', | |
} | |
ini_setting { 'Include Puppet-Managed Git Config': | |
ensure => present, | |
path => $gitconfig_file, | |
section => 'include', | |
setting => 'path', | |
value => "${gitconfig_dir}/puppet", | |
} | |
concat { 'gitconfig': | |
path => "${gitconfig_dir}/puppet", | |
owner => 'root', | |
group => 'root', | |
mode => '0644', | |
warn => true, | |
} | |
# For ordering, space comes before /: The space is important | |
concat::fragment { 'gitconfig-safedir- header': | |
target => 'gitconfig', | |
content => "[safe]\n", | |
order => '10', | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# == Class: profile::gitconfig::safe_directory | |
# | |
# Add `safe.directory` to system config | |
# | |
# === Authors | |
# | |
# Yehuda Katz <[email protected]> | |
# | |
define profile::gitconfig::safe_directory ( | |
Stdlib::Absolutepath $path = $title | |
) { | |
if $path =~ /^.+\/$/ { | |
fail("safe.directory can not have a trailing slash: ${path}") | |
} | |
concat::fragment { "gitconfig-safedir-${title}": | |
target => 'gitconfig', | |
content => " directory = ${path}\n", | |
order => '10', | |
tag => ['gitconfig'], | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment