Puppet Class: dotfiles::config

Defined in:
manifests/config.pp

Overview

Parameters:

  • github_ssh_key (Any) (defaults to: undef)
  • ssh_config_dir (Any) (defaults to: undef)
  • ssh_known_hosts_file_path (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
# File 'manifests/config.pp', line 3

class dotfiles::config (
  $github_ssh_key            = undef,
  $ssh_config_dir            = undef,
  $ssh_known_hosts_file_path = undef,
  $use_ssh_key               = false,
) {

  file { 'ssh_known_hosts':
    ensure  => present,
    path    => $ssh_known_hosts_file_path,
    replace => 'no',
    mode    => '0644'
  }

  exec { 'add_github_to_known_hosts':
    path    => '/usr/bin',
    command => "ssh-keyscan -t rsa github.com >> ${ssh_known_hosts_file_path}",
    require => File['ssh_known_hosts']
  }

  if $use_ssh_key {
    file { 'create_ssh_config_dir':
      ensure => 'directory',
      path   => $ssh_config_dir
    }

    file { 'ssh_config':
      ensure  => file,
      path    => "${ssh_config_dir}/config",
      content => template('dotfiles/.ssh/config.erb'),
      require => File['create_ssh_config_dir']
    }
  }

}