Puppet Class: asterisk::config

Inherits:
asterisk
Defined in:
manifests/config.pp

Overview

Parameters:

  • manage_config (Any)
  • asteriskuser (Any)
  • asteriskgroup (Any)
  • ari_enabled (Any)
  • ast_dumpcore (Any)
  • astbinary (Any)
  • astetcdir (Any)
  • astmoddir (Any)
  • astvarlibdir (Any)
  • astdbdir (Any)
  • astkeydir (Any)
  • astdatadir (Any)
  • astagidir (Any)
  • astspooldir (Any)
  • astrundir (Any)
  • astlogdir (Any)
  • http_bindaddr (Any)
  • http_enabled (Any)
  • http_port (Any)
  • manager_bindaddr (Any)
  • manager_enabled (Any)
  • manager_port (Any)
  • manager_webenabled (Any)
  • register_sip (Any)
  • rtpstart (Any)
  • rtpend (Any)
  • udpbindaddr (Any)
  • tcpenable (Any)
  • tcpbindaddr (Any)
  • tlsenable (Any)
  • tlsbindaddr (Any)
  • tlscertfile (Any)
  • tlsprivatekey (Any)
  • tlscafile (Any)
  • tlscapath (Any)
  • tlsdontverifyserver (Any)
  • ext_static (Any)
  • ext_writeprotect (Any)
  • ext_autofallthrough (Any)
  • ext_patternmatchnew (Any)
  • ext_clearglobalvars (Any)
  • ext_userscontext (Any)
  • ext_includes (Any)
  • ext_execs (Any)


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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
# File 'manifests/config.pp', line 14

class asterisk::config (
  $manage_config,
  $asteriskuser,
  $asteriskgroup,
  $ari_enabled,
  $ast_dumpcore,
  $astbinary,
  $astetcdir,
  $astmoddir,
  $astvarlibdir,
  $astdbdir,
  $astkeydir,
  $astdatadir,
  $astagidir,
  $astspooldir,
  $astrundir,
  $astlogdir,
  $http_bindaddr,
  $http_enabled,
  $http_port,
  $manager_bindaddr,
  $manager_enabled,
  $manager_port,
  $manager_webenabled,
  $register_sip,
  $rtpstart,
  $rtpend,
  $udpbindaddr,
  $tcpenable,
  $tcpbindaddr,
  $tlsenable,
  $tlsbindaddr,
  $tlscertfile,
  $tlsprivatekey,
  $tlscafile,
  $tlscapath,
  $tlsdontverifyserver,
  $ext_static,
  $ext_writeprotect,
  $ext_autofallthrough,
  $ext_patternmatchnew,
  $ext_clearglobalvars,
  $ext_userscontext,
  $ext_includes,
  $ext_execs,
) inherits asterisk {
  File {
    owner => 'root',
    group => '0',
    mode  => '0640',
  }

  if ($manage_config) {
    if ($::osfamily == 'Debian') {
      file { '/etc/default/asterisk':
        ensure  => file,
        mode    => '0644',
        path    => '/etc/default/asterisk',
        content => template('asterisk/etc_default_asterisk.erb'),
        notify  => Service['asterisk'], # restart asterisk when this changes
      }
    }

    file { "${astetcdir}/asterisk.conf":
      ensure  => file,
      owner   => $asteriskuser,
      group   => $asteriskgroup,
      path    => "${astetcdir}/asterisk.conf",
      content => template('asterisk/asterisk.conf.erb'),
      notify  => Service['asterisk'], # restart asterisk when asterisk.conf changes
    }

    file { "${astetcdir}/rtp.conf":
      ensure  => file,
      owner   => $asteriskuser,
      group   => $asteriskgroup,
      path    => "${astetcdir}/rtp.conf",
      content => template('asterisk/rtp.conf.erb'),
      notify  => Service['asterisk'], # restart asterisk when rtp.conf changes
    }

    # Default settings for all config files created with concat
    Concat {
      owner  => $asteriskuser,
      group  => $asteriskgroup,
      mode   => '0440',
      warn   => false,
      notify => Service['asterisk'],
    }

    # SIP configuration
    concat {"${astetcdir}/sip.conf":
      notify => Exec['asterisk-sip-reload'],
    }
    concat::fragment { 'sip_general':
      target  => "${astetcdir}/sip.conf",
      content => template('asterisk/sip.conf.erb'),
      order   => '10',
    }
    concat::fragment { 'sip_authentication':
      target  => "${astetcdir}/sip.conf",
      content => template('asterisk/sip.conf.authentication.erb'),
      order   => '20',
    }
    concat::fragment { 'sip_devices':
      target  => "${astetcdir}/sip.conf",
      content => template('asterisk/sip.conf.devices.erb'),
      order   => '40',
    }

    # IAX configuration
    concat {"${astetcdir}/iax.conf":
      notify => Exec['asterisk-iax-reload'],
    }
    concat::fragment { 'iax_general':
      target  => "${astetcdir}/iax.conf",
      content => template('asterisk/iax.conf.erb'),
      order   => '10',
    }

    # Manager/AMI configuration
    concat { "${astetcdir}/manager.conf": }
    concat::fragment { 'manager_header':
      target  => "${astetcdir}/manager.conf",
      content => template('asterisk/manager.conf.erb'),
      order   => '1',
    }

    # HTTP configuration
    concat { "${astetcdir}/http.conf": }
    concat::fragment { 'http_header':
      target  => "${astetcdir}/http.conf",
      content => template('asterisk/http.conf.erb'),
      order   => '1',
    }

    # Validation step
    if ( $ari_enabled == 'yes' and $http_enabled == 'no') {
      warning('ARI is enabled but HTTP is not. ARI will not be available.')
    }
    # ARI configuration
    concat{ "${astetcdir}/ari.conf": }
    concat::fragment { 'ari_header':
      target  => "${astetcdir}/ari.conf",
      content => template('asterisk/ari.conf.erb'),
      order   => '1',
    }

    # Extensions
    concat {"${astetcdir}/extensions.conf": }
    concat::fragment {'extensions_general':
      target  => "${astetcdir}/extensions.conf",
      content => template('asterisk/extensions.conf.general.erb'),
      order   => '5',
    }

    # TODO /etc/init.d/asterisk
    # TODO /etc/logrotate.d/asterisk
  }

  # Ask Asterisk to reload the SIP configuration
  exec { 'asterisk-sip-reload':
    command     => "${astbinary} -rx 'sip reload'",
    refreshonly => true,
  }

  # Ask Asterisk to reload the IAX configuration
  exec { 'asterisk-iax-reload':
    command     => "${astbinary} -rx 'reload chan_iax2.so'",
    refreshonly => true,
  }
}