Puppet Class: dotfiles::install

Defined in:
manifests/install.pp

Overview

Parameters:

  • dotfiles_install_path (Any) (defaults to: undef)
  • dotfiles_install_script (Any) (defaults to: undef)
  • dotfiles_repository_url (Any) (defaults to: undef)
  • use_ssh_key (Any) (defaults to: false)


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
# File 'manifests/install.pp', line 3

class dotfiles::install (
  $dotfiles_install_path   = undef,
  $dotfiles_install_script = undef,
  $dotfiles_repository_url = undef,
  $use_ssh_key             = false,
) {

  case $::operatingsystem {
    'Ubuntu': { $shell_exec_cmd = 'bash' }
    default: { $shell_exec_cmd = 'sh' }
  }

  if $use_ssh_key {
    $initialize_submodules = true
    $install_requirements = Vcsrepo['clone_dotfiles']
  } else {
    $initialize_submodules = false
    $install_requirements = [ Vcsrepo['clone_dotfiles'], Exec['update_gitmodules'] ]
  }

  vcsrepo { 'clone_dotfiles':
    ensure     => present,
    path       => $dotfiles_install_path,
    provider   => git,
    source     => $dotfiles_repository_url,
    submodules => $initialize_submodules,
  }

  if $use_ssh_key == false {

    exec { 'gitmodules_git_ssh_to_https':
      path    => '/bin',
      cwd     => $dotfiles_install_path,
      command => 'sed -i "s/git@github.com:/https:\/\/github.com\//" .gitmodules',
      require => Vcsrepo['clone_dotfiles']
    }

    exec { 'gitmodules_plain_git_to_https':
      path    => '/bin',
      cwd     => $dotfiles_install_path,
      command => 'sed -i "s/git:\/\/github.com\//https:\/\/github.com\//" .gitmodules',
      require => Vcsrepo['clone_dotfiles']
    }

    exec { 'update_gitmodules':
      path    => '/usr/bin',
      cwd     => $dotfiles_install_path,
      command => 'git submodule update --init --recursive',
      require => [ Exec['gitmodules_git_ssh_to_https'], Exec['gitmodules_plain_git_to_https'] ]
    }
  }

  exec { 'install_dotfiles':
    path    => '/bin',
    command => "${shell_exec_cmd} ${dotfiles_install_path}/${dotfiles_install_script}",
    require => $install_requirements
  }

}