Improve librenms role.

This commit is contained in:
Markus 2016-07-06 16:28:16 +02:00
parent 057c04c313
commit 3ba596b471
3 changed files with 79 additions and 4 deletions

View File

@ -33,8 +33,23 @@
- name: Configure MySQL user
mysql_user: name={{ librenms_dbuser }} password={{ librenms_dbpass }} priv={{ librenms_dbname }}.*:ALL state=present
- name: Unpack librenms
unarchive: src=https://github.com/librenms/librenms/archive/201607.zip dest=/opt copy=no
- name: Ensure librenms user exists
user: name=librenms createhome=no groups=www-data home=/opt/librenms system=yes
- name: Clone librenms
git: repo=https://github.com/librenms/librenms.git dest=/opt/librenms depth=1 update=no
become: yes
become_user: librenms
- name: Ensure rrd directory exists
file: path=/opt/librenms/rrd owner=librenms group=librenms mode=0775 state=directory
- name: Ensure logs directory exists
file: path=/opt/librenms/logs owner=librenms group=librenms mode=0775 state=directory
- name: Configure librenms
template: src=config.php.j2 dest=/opt/librenms/config.php owner=librenms group=librenms mode=0440
- name: Configure vhost
template: src=vhost.j2 dest=/etc/nginx/sites-available/librenms

View File

@ -0,0 +1,47 @@
<?php
## Have a look in defaults.inc.php for examples of settings you can set here. DO NOT EDIT defaults.inc.php!
### Database config
$config['db_host'] = 'localhost';
$config['db_user'] = '{{ librenms_dbuser }}';
$config['db_pass'] = '{{ librenms_dbpass }}';
$config['db_name'] = '{{ librenms_dbname }}';
$config['db']['extension'] = "mysqli";// mysql or mysqli
// This is the user LibreNMS will run as
//Please ensure this user is created and has the correct permissions to your install
$config['user'] = 'librenms';
### Memcached config - We use this to store realtime usage
$config['memcached']['enable'] = FALSE;
$config['memcached']['host'] = "localhost";
$config['memcached']['port'] = 11211;
### Locations - it is recommended to keep the default
$config['install_dir'] = "/opt/librenms";
### This should *only* be set if you want to *force* a particular hostname/port
### It will prevent the web interface being usable form any other hostname
#$config['base_url'] = "http://{{ librenms_domain }}";
### Enable this to use rrdcached. Be sure rrd_dir is within the rrdcached dir
### and that your web server has permission to talk to rrdcached.
#$config['rrdcached'] = "unix:/var/run/rrdcached.sock";
### Default community
$config['snmp']['community'] = array("public");
### Authentication Model
$config['auth_mechanism'] = "mysql"; # default, other options: ldap, http-auth
#$config['http_auth_guest'] = "guest"; # remember to configure this user if you use http-auth
### List of RFC1918 networks to allow scanning-based discovery
#$config['nets'][] = "10.0.0.0/8";
#$config['nets'][] = "172.16.0.0/12";
#$config['nets'][] = "192.168.0.0/16";
# following is necessary for poller-wrapper
# poller-wrapper is released public domain
$config['poller-wrapper']['alerter'] = FALSE;
# Uncomment the next line to disable daily updates
$config['update'] = 0;

View File

@ -4,11 +4,15 @@ server {
server_name {{ librenms_domain }};
root /opt/librenms/wwwroot;
root /opt/librenms/html;
index index.php;
location ~ \.php(?:$|/) {
location / {
try_files $uri $uri/ @librenms;
}
location ~ \.php {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
@ -16,4 +20,13 @@ server {
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_intercept_errors on;
}
location ~ /\.ht {
deny all;
}
location @librenms {
rewrite api/v0(.*)$ /api_v0.php/$1 last;
rewrite ^(.+)$ /index.php/$1 last;
}
}