Defined Type: python::dotfile

Defined in:
manifests/dotfile.pp

Summary

Manages any python dotfiles with a simple config hash.

Overview

Examples:

Create a pip config in /var/lib/jenkins/.pip/

python::dotfile { '/var/lib/jenkins/.pip/pip.conf':
  ensure => present,
  owner  => 'jenkins',
  group  => 'jenkins',
  config => {
    'global' => {
      'index-url'       => 'https://mypypi.acme.com/simple/'
      'extra-index-url' => 'https://pypi.risedev.at/simple/'
    }
  }
}

Parameters:

  • ensure (Enum['absent', 'present']) (defaults to: 'present')
  • filename (Stdlib::Absolutepath) (defaults to: $title)

    Filename.

  • mode (Stdlib::Filemode) (defaults to: '0644')

    File mode.

  • owner (String[1]) (defaults to: 'root')

    user owner of dotfile

  • group (String[1]) (defaults to: 'root')

    group owner of dotfile

  • config (Hash) (defaults to: {})

    Config hash. This will be expanded to an ini-file.



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

define python::dotfile (
  Enum['absent', 'present'] $ensure   = 'present',
  Stdlib::Absolutepath      $filename = $title,
  String[1]                 $owner    = 'root',
  String[1]                 $group    = 'root',
  Stdlib::Filemode          $mode     = '0644',
  Hash                      $config   = {},
) {
  $parent_dir = dirname($filename)

  exec { "create ${title}'s parent dir":
    command => "install -o ${owner} -g ${group} -d ${parent_dir}",
    path    => ['/usr/bin', '/bin', '/usr/local/bin',],
    creates => $parent_dir,
  }

  file { $filename:
    ensure  => $ensure,
    owner   => $owner,
    group   => $group,
    mode    => $mode,
    content => template("${module_name}/inifile.erb"),
    require => Exec["create ${title}'s parent dir"],
  }
}