From 31b4b2e385f0c0c172f5380d9fe7ee45c1f89874 Mon Sep 17 00:00:00 2001 From: Markus Hauschild Date: Wed, 6 Jul 2016 13:26:42 +0200 Subject: [PATCH] Add incomplete librenms role. --- group_vars/FreeBSD | 1 + group_vars/Ubuntu | 1 + group_vars/all | 5 ++++ roles/librenms/handlers/main.yml | 4 +++ roles/librenms/meta/main.yml | 4 +++ roles/librenms/tasks/main.yml | 48 +++++++++++++++++++++++++++++++ roles/librenms/templates/vhost.j2 | 19 ++++++++++++ 7 files changed, 82 insertions(+) create mode 100644 group_vars/FreeBSD create mode 100644 group_vars/Ubuntu create mode 100644 roles/librenms/handlers/main.yml create mode 100644 roles/librenms/meta/main.yml create mode 100644 roles/librenms/tasks/main.yml create mode 100644 roles/librenms/templates/vhost.j2 diff --git a/group_vars/FreeBSD b/group_vars/FreeBSD new file mode 100644 index 0000000..649edfe --- /dev/null +++ b/group_vars/FreeBSD @@ -0,0 +1 @@ +pdns_config_dir: /usr/local/etc/pdns diff --git a/group_vars/Ubuntu b/group_vars/Ubuntu new file mode 100644 index 0000000..806c71e --- /dev/null +++ b/group_vars/Ubuntu @@ -0,0 +1 @@ +pdns_config_dir: /etc/powerdns diff --git a/group_vars/all b/group_vars/all index 02b2307..ff9ab00 100644 --- a/group_vars/all +++ b/group_vars/all @@ -14,6 +14,11 @@ ldap_base: dc=binary-kitchen,dc=de ldap_binddn: cn=Services,ou=roles,dc=binary-kitchen,dc=de ldap_bindpw: svcpwd +librenms_domain: librenms.binary.kitchen +librenms_dbname: librenms +librenms_dbuser: librenms +librenms_dbpass: xNUYsUhzwP4u7cVNCECz + mail_domain: binary-kitchen.de mail_domains: - ccc-r.de diff --git a/roles/librenms/handlers/main.yml b/roles/librenms/handlers/main.yml new file mode 100644 index 0000000..44975c4 --- /dev/null +++ b/roles/librenms/handlers/main.yml @@ -0,0 +1,4 @@ +--- + +- name: Restart nginx + service: name=nginx state=restarted diff --git a/roles/librenms/meta/main.yml b/roles/librenms/meta/main.yml new file mode 100644 index 0000000..34de459 --- /dev/null +++ b/roles/librenms/meta/main.yml @@ -0,0 +1,4 @@ +--- + +dependencies: +- { role: nginx, nginx_ssl: False } diff --git a/roles/librenms/tasks/main.yml b/roles/librenms/tasks/main.yml new file mode 100644 index 0000000..b867523 --- /dev/null +++ b/roles/librenms/tasks/main.yml @@ -0,0 +1,48 @@ +--- + +- name: Install dependencies + apt: name={{ item }} state=present + with_items: + - fping + - git + - graphviz + - imagemagick + - mtr-tiny + - mysql-server + - nmap + - php-net-ipv4 + - php-net-ipv6 + - php-pear + - php5-cli + - php5-curl + - php5-fpm + - php5-gd + - php5-json + - php5-mcrypt + - php5-mysql + - php5-snmp + - python-mysqldb + - rrdtool + - snmp + - snmpd + - whois + +- name: Configure MySQL database + mysql_db: name={{ librenms_dbname }} + +- 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: Configure vhost + template: src=vhost.j2 dest=/etc/nginx/sites-available/librenms + notify: Restart nginx + +- name: Enable vhost + file: src=/etc/nginx/sites-available/librenms dest=/etc/nginx/sites-enabled/librenms state=link + notify: Restart nginx + +- name: Start php5-fpm + service: name=php5-fpm state=started enabled=yes diff --git a/roles/librenms/templates/vhost.j2 b/roles/librenms/templates/vhost.j2 new file mode 100644 index 0000000..978942e --- /dev/null +++ b/roles/librenms/templates/vhost.j2 @@ -0,0 +1,19 @@ +server { + listen 80; + listen [::]:80; + + server_name {{ librenms_domain }}; + + root /opt/librenms/wwwroot; + + index index.php; + + location ~ \.php(?:$|/) { + fastcgi_split_path_info ^(.+\.php)(/.+)$; + include fastcgi_params; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + fastcgi_param PATH_INFO $fastcgi_path_info; + fastcgi_pass unix:/var/run/php5-fpm.sock; + fastcgi_intercept_errors on; + } +}