Puppet Class: classroom_legacy::agent::git

Defined in:
manifests/agent/git.pp

Overview



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'manifests/agent/git.pp', line 1

class classroom_legacy::agent::git {
  assert_private('This class should not be called directly')

  case $::osfamily {
    'windows' : {
      $environment = undef
      $path        = 'C:/Program Files/Git/bin'
      $sshpath     = 'C:/Program Files/Git/.ssh'
    }
    default   : {
      $environment = 'HOME=/root'
      $path        = '/usr/bin:/bin:/user/sbin:/usr/sbin'
      $sshpath     = '/root/.ssh'
    }
  }
  Exec {
    environment => $environment,
    path        => $path,
  }

  if $::osfamily == 'windows'{
    require chocolatey

    package { ['git', 'kdiff3']:
      ensure   => present,
      provider => 'chocolatey',
      before   => [ File[$sshpath], Exec['generate_key'] ],
      require  => Package['chocolatey'],
    }

    file { 'C:/Users/Administrator/.ssh/':
      ensure  => directory,
      source  => $sshpath,
      recurse => true,
      require => [File[$sshpath],Exec['generate_key'],User['Administrator']],
    }

    windows_env { 'PATH=C:\Program Files\Git\bin': }
  }
  else {
    class { '::git':
      before => [ File[$sshpath], Exec['generate_key'] ],
    }
  }

  file { $sshpath:
    ensure => directory,
    mode   => '0600',
  }

  exec { 'generate_key':
    command => $::osfamily ? {
      'windows' => "bash.exe -c \"ssh-keygen -t rsa -N '' -f '${sshpath}/id_rsa'\"",
      'RedHat'  => "ssh-keygen -t rsa -N '' -f '${sshpath}/id_rsa'",
      # no default should make catalog compilation fail on other OS families
    },
    creates => "${sshpath}/id_rsa",
    require => File[$sshpath],
  }

  exec { "git config --global user.name '${classroom_legacy::params::machine_name}'":
    unless  => 'git config --global user.name',
    require => Exec['generate_key'],
  }

  exec { "git config --global user.email ${classroom_legacy::params::machine_name}@puppetlabs.vm":
    unless  => 'git config --global user.email',
    require => Exec['generate_key'],
  }

  exec { 'git config --global color.ui always':
    unless  => 'git config --global color.ui',
    require => Exec['generate_key'],
  }

}