Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/manage http options #12

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ how general configuration is set.

* `$queues_options` is detailed in the Queues Options section.

* `$http_options` is detailed in the Asterisk Built-in HTTP Server section.

* `$modules_autoload`, `$modules_noload`, `$modules_load` and
`$modules_global_options` are detailed in the Modules section.

Expand Down Expand Up @@ -531,6 +533,29 @@ $queues_options = {
}
```

Asterisk Built-in HTTP Server
------

The core of Asterisk provides a basic HTTP/HTTPS server. To enable the server, you can use the `asterisk::http_options` parameter. For passing in settings, you need to send a hash to the asterisk class with the http_options parameter.

Here is the default hash with the default values, as defined in params.pp::

```puppet
$http_options = {
'bindaddr' => '127.0.0.1',
'enabled' => 'yes',
'bindport' => 8080,
'prefix' => 'asterisk',
'sessionlimit' => 100,
'session_inactivity' => 30000,
'session_keep_alive' => '15000',
'enablestatic' => 'yes',
}
```

See:
https://wiki.asterisk.org/wiki/display/AST/Asterisk+Builtin+mini-HTTP+Server

Modules
-------

Expand Down
5 changes: 5 additions & 0 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@
content => template('asterisk/queues.conf.erb'),
}

$http_options = $asterisk::http_options
asterisk::dotd { '/etc/asterisk/http':
content => template('asterisk/http.conf.erb'),
}

$manager_enable = $asterisk::real_manager_enable
$manager_port = $asterisk::manager_port
$manager_bindaddr = $asterisk::manager_bindaddr
Expand Down
1 change: 1 addition & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
$features_options = $asterisk::params::features_options,
$features_featuremap = {},
$queues_options = {},
$http_options = $asterisk::params::http_options,
$modules_autoload = $asterisk::params::modules_autoload,
$modules_noload = $asterisk::params::modules_noload,
$modules_load = $asterisk::params::modules_load,
Expand Down
11 changes: 11 additions & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,17 @@
'monitor-type' => 'MixMonitor',
}

$http_options = {
'bindaddr' => '127.0.0.1',
'enabled' => 'yes',
'bindport' => 8080,
'prefix' => 'asterisk',
'sessionlimit' => 100,
'session_inactivity' => 30000,
'session_keep_alive=' => '15000',
'enablestatic' => 'yes',
}

$modules_autoload = true
$modules_noload = [
'pbx_gtkconsole.so',
Expand Down
118 changes: 118 additions & 0 deletions templates/http.conf.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
; THIS FILE IS MANAGED BY PUPPET
; all local modifications will be lost
; To change values found in this file, see the $http_options parameter of
; the asterisk module
;
; http.conf - configuration for the Asterisk Builtin mini HTTP server
;
;
;
; Asterisk Builtin mini-HTTP server
;
;
; Note about Asterisk documentation:
; If Asterisk was installed from a tarball, then the HTML documentation should
; be installed in the static-http/docs directory which is
; (/var/lib/asterisk/static-http/docs) on linux by default. If the Asterisk
; HTTP server is enabled in this file by setting the "enabled", "bindaddr",
; and "bindport" options, then you should be able to view the documentation
; remotely by browsing to:
; http://<server_ip>:<bindport>/static/docs/index.html
;
;[general]
;
; Whether HTTP/HTTPS interface is enabled or not. Default is no.
; This also affects manager/rawman/mxml access (see manager.conf)
;
;enabled=yes
;
; Address to bind to, both for HTTP and HTTPS. You MUST specify
; a bindaddr in order for the HTTP server to run. There is no
; default value.
;
;bindaddr=127.0.0.1
;
; Port to bind to for HTTP sessions (default is 8088)
;
;bindport=8088
;
; Prefix allows you to specify a prefix for all requests
; to the server. The default is blank. If uncommented
; all requests must begin with /asterisk
;
;prefix=asterisk
;
; sessionlimit specifies the maximum number of httpsessions that will be
; allowed to exist at any given time. (default: 100)
;
;sessionlimit=100
;
; session_inactivity specifies the number of milliseconds to wait for
; more data over the HTTP connection before closing it.
;
; Default: 30000
;session_inactivity=30000
;
; session_keep_alive specifies the number of milliseconds to wait for
; the next HTTP request over a persistent connection.
;
; Set to 0 to disable persistent HTTP connections.
; Default: 15000
;session_keep_alive=15000
;
; Whether Asterisk should serve static content from static-http
; Default is no.
;
;enablestatic=yes
;
; Redirect one URI to another. This is how you would set a
; default page.
; Syntax: redirect=<from here> <to there>
; For example, if you are using the Asterisk-gui,
; it is convenient to enable the following redirect:
;
;redirect = / /static/config/index.html
;
; HTTPS support. In addition to enabled=yes, you need to
; explicitly enable tls, define the port to use,
; and have a certificate somewhere.
;tlsenable=yes ; enable tls - default no.
;tlsbindaddr=0.0.0.0:8089 ; address and port to bind to - default is bindaddr and port 8089.
;
;tlscertfile=</path/to/certificate.pem> ; path to the certificate file (*.pem) only.
;tlsprivatekey=</path/to/private.pem> ; path to private key file (*.pem) only.
; If no path is given for tlscertfile or tlsprivatekey, default is to look in current
; directory. If no tlsprivatekey is given, default is to search tlscertfile for private key.
;
; To produce a certificate you can e.g. use openssl. This places both the cert and
; private in same .pem file.
; openssl req -new -x509 -days 365 -nodes -out /tmp/foo.pem -keyout /tmp/foo.pem
;
; The post_mappings section maps URLs to real paths on the filesystem. If a
; POST is done from within an authenticated manager session to one of the
; configured POST mappings, then any files in the POST will be placed in the
; configured directory.
;
;[post_mappings]
;
; NOTE: You need a valid HTTP AMI mansession_id cookie with the manager
; config permission to POST files.
;
; In this example, if the prefix option is set to "asterisk", then using the
; POST URL: /asterisk/uploads will put files in /var/lib/asterisk/uploads/.
;uploads = /var/lib/asterisk/uploads/
;
; CONFIG STARTS HERE
;
[general]
<% @http_options.sort.map do |name, value|
if value.is_a? Array
value.each do |v| -%>
<%= name -%>=<%= v %>
<% end
else -%>
<%= name -%>=<%= value %>
<% end
end -%>

#include </etc/asterisk/http.d/*.conf>