diff --git a/roles/nameserver/files/snmpd_bind.conf b/roles/nameserver/files/snmpd_bind.conf new file mode 100644 index 0000000..759a161 --- /dev/null +++ b/roles/nameserver/files/snmpd_bind.conf @@ -0,0 +1,12 @@ +# The default config file is... /etc/snmp/bind.config +# This is the path to rndc. +rndc=/usr/sbin/rndc +# This is the the path to the named stats file. +stats_file=/etc/bind/named.stats +# This is a 0/1 boolean for if rndc should be called. +# If you are using netdata, you most likely want to set this to 0. +call_rndc=1 +# This is a 0/1 boolean for this is being used as a LibreNMS agent. +agent=0 +# This is a 0/1 boolean for if the stats file should be zeroed before calling rndc stats. +zero_stats=1 \ No newline at end of file diff --git a/roles/nameserver/handlers/main.yml b/roles/nameserver/handlers/main.yml new file mode 100644 index 0000000..54ddee6 --- /dev/null +++ b/roles/nameserver/handlers/main.yml @@ -0,0 +1,9 @@ +- name: restart_named + service: + name: "named" + state: restarted + +- name: restart_snmpd + service: + name: "snmpd" + state: restarted \ No newline at end of file diff --git a/roles/nameserver/tasks/configure_snmpd.yml b/roles/nameserver/tasks/configure_snmpd.yml index 1f121b4..44a21cc 100644 --- a/roles/nameserver/tasks/configure_snmpd.yml +++ b/roles/nameserver/tasks/configure_snmpd.yml @@ -1,7 +1,44 @@ +- name: nameserver | snmpd | install needed modules + package: + name: "{{ perl_readbackwards }}" + state: present + - name: nameserver | snmpd | get script + get_url: + url: "https://github.com/librenms/librenms-agent/raw/master/snmp/bind" + dest: "/etc/snmp/bind" + mode: "0755" + owner: "root" + group: "root" - name: nameserver | snmpd | create configuration + copy: + dest: "/etc/snmp/bind.conf" + src: "snmpd_bind.conf" + mode: "0644" + owner: "root" + group: "root" - name: nameserver | snmpd | create statistics file + file: + path: /etc/bind/named.stats + state: touch + owner: "bind" + group: "bind" -- name: nameserver | snmpd | configure named for statistics \ No newline at end of file +- name: nameserver | snmpd | configure named for statistics + lineinfile: + path: "/etc/bind/named.conf.options" # required. The file to modify. Before Ansible 2.3 this option was only usable as I(dest), I(destfile) and I(name). + state: present + line: "statistics-file "/var/cache/bind/stats"; zone-statistics yes;" + insertafter: "options {" + validate: /usr/bin/named-checkconf %s + notify: restart_named + +- name: nameserver | snmpd | configure extend + lineinfile: + path: "/etc/snmp/snmpd.conf" + state: present + line: "extend bind /etc/snmp/bind" + insertafter: "^syslocation.*$" + notify: restart_snmpd \ No newline at end of file diff --git a/roles/nameserver/vars/Archlinux.yml b/roles/nameserver/vars/Archlinux.yml index 7aae925..81ec7ed 100644 --- a/roles/nameserver/vars/Archlinux.yml +++ b/roles/nameserver/vars/Archlinux.yml @@ -1 +1,2 @@ -bind_package: bind \ No newline at end of file +bind_package: bind +perl_readbackwards: perl-file-readbackwards \ No newline at end of file diff --git a/roles/nameserver/vars/Debian.yml b/roles/nameserver/vars/Debian.yml index 28a8e2b..d6b249e 100644 --- a/roles/nameserver/vars/Debian.yml +++ b/roles/nameserver/vars/Debian.yml @@ -1 +1,2 @@ -bind_package: bind9 \ No newline at end of file +bind_package: bind9 +perl_readbackwards: libfile-readbackwards-perl \ No newline at end of file diff --git a/roles/nameserver/vars/Ubuntu.yml b/roles/nameserver/vars/Ubuntu.yml index 28a8e2b..d6b249e 100644 --- a/roles/nameserver/vars/Ubuntu.yml +++ b/roles/nameserver/vars/Ubuntu.yml @@ -1 +1,2 @@ -bind_package: bind9 \ No newline at end of file +bind_package: bind9 +perl_readbackwards: libfile-readbackwards-perl \ No newline at end of file