Puppet Class: mutt

Inherits:
mutt::params
Defined in:
manifests/init.pp

Overview

View README.md for full documentation

Authors

Zan Loy <zan.loy@gmail.com>

Copyright 2014

Parameters:

  • alias_file (Any) (defaults to: $mutt::params::alias_file)
  • certificate_file (Any) (defaults to: $mutt::params::certificate_file)
  • config_file (Any) (defaults to: $mutt::params::config_file)
  • date_format (Any) (defaults to: $mutt::params::date_format)
  • delete (Any) (defaults to: $mutt::params::delete)
  • folder (Any) (defaults to: $mutt::params::folder)
  • history_file (Any) (defaults to: $mutt::params::history_file)
  • hostname (Any) (defaults to: undef)
  • index_format (Any) (defaults to: $mutt::params::index_format)
  • mbox (Any) (defaults to: $mutt::params::mbox)
  • mbox_type (Any) (defaults to: $mutt::params::mbox_type)
  • package (Any) (defaults to: $mutt::params::package)
  • sidebar (Any) (defaults to: $mutt::params::sidebar)


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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'manifests/init.pp', line 11

class mutt (
  $alias_file       = $mutt::params::alias_file,
  $certificate_file = $mutt::params::certificate_file,
  $config_file      = $mutt::params::config_file,
  $date_format      = $mutt::params::date_format,
  $delete           = $mutt::params::delete,
  $folder           = $mutt::params::folder,
  $history_file     = $mutt::params::history_file,
  $hostname         = undef,
  $index_format     = $mutt::params::index_format,
  $mbox             = $mutt::params::mbox,
  $mbox_type        = $mutt::params::mbox_type,
  $package          = $mutt::params::package,
  $sidebar          = $mutt::params::sidebar,
) inherits mutt::params {

  # Parameter validation
  if is_bool($sidebar) == false { fail('sidebar must be a boolean') }

  package { $package:
    ensure => present,
  }

  file { $config_file:
    ensure  => file,
    owner   => 'root',
    group   => 'root',
    mode    => '0644',
    require => Package[$package],
  }

  $options = {
    'alias_file' => {
      line => "set alias_file=${alias_file}",
      match => 'set alias_file=.*',
    },
    'certificate_file' => {
      line => "set certificate_file=${certificate_file}",
      match => 'set certificate_file=.*',
    },
    'date_format' => {
      line => "set date_format=${date_format}",
      match => 'set date_format=.*',
    },
    'delete' => {
      line => "set delete=${delete}",
      match => 'set delete=.*',
    },
    'folder' => {
      line => "set folder=${folder}",
      match => 'set folder=.*',
    },
    'history_file' => {
      line => "set history_file=${history_file}",
      match => 'set history_file=.*',
    },
    'index_format' => {
      line => "set index_format=${index_format}",
      match => 'set index_format=.*',
    },
    'mbox' => {
      line => "set mbox=${mbox}",
      match => 'set mbox=.*',
    },
    'mbox_type' => {
      line => "set mbox_type=${mbox_type}",
      match => 'set mbox_type=.*',
    },
  }

  create_resources(file_line, $options, { 'path' => $config_file, 'require' => File[$config_file] })

  if $hostname != undef {
    file_line { 'hostname':
      path    => $config_file,
      line    => "set hostname=${hostname}",
      match   => 'set hostname=.*',
      require => File[$config_file],
    }
  }

  if $package == 'mutt-patched' and $sidebar == false {
    file_line { 'sidebar':
      path => $config_file,
      line => 'set sidebar_visible=no',
      match => 'set sidebar_visible=.*',
      require => File[$config_file],
    }
  }
}