Defined Type: psick::git::config

Defined in:
manifests/git/config.pp

Overview

Define: psick::git::config

This define configures the gitconfig file, either for the specified user, or, if provided, in the given path.

Parameters

content

Sets the value of content parameter for the gitconfig file. Can be set as an array (joined with newlines)

source

Sets the value of source parameter for the gitconfig file

template

Sets the value of content parameter for the gitconfig file Note: This option is alternative to the source one

ensure

Define if the gitconfig file should be present (default) or ‘absent’

user

Set the user for which to create a gitconfig file. Default is taken from the title.

path

Set the path of the git config file (this overrides any path derived from user parameter

options_hash

Custom hash of options to use in templates.

Parameters:

  • ensure (Enum['present','absent']) (defaults to: present)
  • content (Variant[Undef,String]) (defaults to: undef)
  • template (Variant[Undef,String]) (defaults to: 'psick/generic/inifile_with_stanzas.erb')
  • source (Variant[Undef,String]) (defaults to: undef)
  • user (Optional[String]) (defaults to: undef)
  • path (Optional[String]) (defaults to: undef)
  • options_hash (Hash) (defaults to: {})


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
77
# File 'manifests/git/config.pp', line 33

define psick::git::config (
  Enum['present','absent'] $ensure       = present,
  Variant[Undef,String]    $content      = undef,
  Variant[Undef,String]    $template     = 'psick/generic/inifile_with_stanzas.erb',
  Variant[Undef,String]    $source       = undef,
  Optional[String]         $user         = undef,
  Optional[String]         $path         = undef,
  Hash                     $options_hash = {},
) {
  # TODO: This can be replaced with $title as default for user param
  $user_real = $user ? {
    undef    => $title,
    default => $user,
  }

  # $parameters is used in the default generic template
  $parameters = $options_hash

  # Define the final content: if $content is set a line break is added at the
  # end, if not, the $template is used, if set.
  $real_content = $content ? {
    undef     => $template ? {
      undef   => undef,
      default => template($template),
    },
    default   => inline_template('<%= [@content].flatten.join("\n") + "\n" %>'),
  }

  $path_real = $path ? {
    undef   => $user_real ? {
      'root'  => "/${user_real}/.gitconfig",
      default => "/home/${user_real}/.gitconfig",
    },
    default => $path,
  }

  file { $path_real:
    ensure  => $ensure,
    owner   => $user_real,
    group   => $user_real,
    mode    => '0640',
    content => $real_content,
    source  => $source,
  }
}