mirror of
https://github.com/iiab/iiab.git
synced 2025-02-13 11:42:08 +00:00
58 lines
1.5 KiB
YAML
58 lines
1.5 KiB
YAML
- name: Install 'vnstat' package
|
|
package:
|
|
name: vnstat
|
|
state: present
|
|
|
|
- name: Install /etc/vnstat.conf from template
|
|
template:
|
|
src: vnstat.conf.j2
|
|
dest: /etc/vnstat.conf
|
|
# owner: root
|
|
# group: root
|
|
mode: '0744'
|
|
|
|
- name: Create database for WAN to collect vnStat data
|
|
shell: /usr/bin/vnstat -i {{ iiab_wan_iface }}
|
|
|
|
- name: Create database for LAN to collect vnStat data if not appliance config
|
|
shell: /usr/bin/vnstat -i {{ iiab_lan_iface }}
|
|
when: iiab_lan_iface is defined
|
|
|
|
|
|
# RECORD vnStat AS INSTALLED
|
|
|
|
- name: "Set 'vnstat_installed: True'"
|
|
set_fact:
|
|
vnstat_installed: True
|
|
|
|
- name: "Add 'vnstat_installed: True' to {{ iiab_state_file }}"
|
|
lineinfile:
|
|
dest: "{{ iiab_state_file }}" # /etc/iiab/iiab_state.yml
|
|
regexp: '^vnstat_installed'
|
|
line: 'vnstat_installed: True'
|
|
|
|
|
|
- name: Enable & (Re)Start 'vnstat' systemd service, if vnstat_enabled
|
|
systemd:
|
|
name: vnstat
|
|
daemon_reload: yes
|
|
enabled: yes
|
|
state: restarted
|
|
when: vnstat_enabled | bool
|
|
|
|
|
|
- name: Add 'vnstat' variable values to {{ iiab_ini_file }}
|
|
ini_file:
|
|
path: "{{ iiab_ini_file }}"
|
|
section: vnstat
|
|
option: "{{ item.option }}"
|
|
value: "{{ item.value | string }}"
|
|
with_items:
|
|
- option: name
|
|
value: vnStat
|
|
- option: description
|
|
value: '"vnStat is a console-based network traffic monitor for Linux and BSD that keeps a log of network traffic for the selected interface(s)."'
|
|
- option: install
|
|
value: "{{ vnstat_install }}"
|
|
- option: enabled
|
|
value: "{{ vnstat_enabled }}"
|