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
|
# File 'manifests/config.pp', line 14
class asterisk::config (
$manage_config,
$ari_enabled,
$ast_dumpcore,
$astetcdir,
$astmoddir,
$astvarlibdir,
$astdbdir,
$astkeydir,
$astdatadir,
$astagidir,
$astspooldir,
$astrundir,
$astlogdir,
$http_bindaddr,
$http_enabled,
$http_port,
$manager_bindaddr,
$manager_enabled,
$manager_port,
$manager_webenabled,
$rtpstart,
$rtpend,
$udpbindaddr,
$tcpenable,
$tcpbindaddr,
$tlsenable,
$tlsbindaddr,
$tlscertfile,
$tlsprivatekey,
$tlscafile,
$tlscapath,
$tlsdontverifyserver
) inherits asterisk {
File {
owner => 'root',
group => 'root',
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 { '/etc/asterisk/asterisk.conf':
ensure => file,
owner => 'asterisk',
group => 'asterisk',
path => '/etc/asterisk/asterisk.conf',
content => template('asterisk/asterisk.conf.erb'),
notify => Service['asterisk'], # restart asterisk when asterisk.conf changes
}
file { '/etc/asterisk/rtp.conf':
ensure => file,
owner => 'asterisk',
group => 'asterisk',
path => '/etc/asterisk/rtp.conf',
content => template('asterisk/rtp.conf.erb'),
notify => Service['asterisk'], # restart asterisk when rtp.conf changes
}
file { '/etc/asterisk/sip.conf':
ensure => file,
owner => 'asterisk',
group => 'asterisk',
path => '/etc/asterisk/sip.conf',
content => template('asterisk/sip.conf.erb'),
notify => Exec['asterisk-sip-reload'],
}
# Default settings for all config files created with concat
Concat {
owner => 'root',
group => 'asterisk',
mode => '0440',
warn => true,
notify => Service['asterisk']
}
# Manager/AMI configuration
concat { '/etc/asterisk/manager.conf': }
concat::fragment { 'manager_header':
target => '/etc/asterisk/manager.conf',
content => template('asterisk/manager.conf.erb'),
order => 1,
}
# HTTP configuration
concat { '/etc/asterisk/http.conf': }
concat::fragment { 'http_header':
target => '/etc/asterisk/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{'/etc/asterisk/ari.conf': }
concat::fragment { 'ari_header':
target => '/etc/asterisk/ari.conf',
content => template('asterisk/ari.conf.erb'),
order => 1,
}
# TODO /etc/init.d/asterisk
# TODO /etc/logrotate.d/asterisk
}
# Ask Asterisk to reload the SIP configuration
exec { 'asterisk-sip-reload':
command => '/usr/sbin/asterisk -rx "sip reload"',
refreshonly => true,
}
}
|