mirror of
https://github.com/iiab/iiab.git
synced 2025-02-13 19:52:06 +00:00
48 lines
1.7 KiB
YAML
48 lines
1.7 KiB
YAML
# Similar code block in roles/network/tasks/detected_network.yml
|
|
- name: "If above ansible_default_ipv4.gateway is defined, set WAN candidate 'discovered_wan_iface: {{ ansible_default_ipv4.alias }}' -- using ansible_default_ipv4.alias"
|
|
set_fact:
|
|
discovered_wan_iface: "{{ ansible_default_ipv4.alias }}"
|
|
when: ansible_default_ipv4.gateway is defined
|
|
|
|
- name: "Verify gateway active: ping -c4 {{ ansible_default_ipv4.gateway }} -- using ansible_default_ipv4.gateway"
|
|
shell: ping -c4 "{{ ansible_default_ipv4.gateway }}" | grep icmp_seq=4 | wc -l
|
|
register: gw_active_test
|
|
when: discovered_wan_iface != "none"
|
|
|
|
- name: "If gateway responded, set 'iiab_wan_iface: {{ discovered_wan_iface }}' -- using discovered_wan_iface"
|
|
set_fact:
|
|
iiab_wan_iface: "{{ discovered_wan_iface }}"
|
|
when: discovered_wan_iface != "none" and gw_active_test.stdout == "1"
|
|
|
|
|
|
- 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
|
|
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 and iiab_lan_iface != "none"
|
|
|
|
|
|
# RECORD vnStat AS INSTALLED
|
|
|
|
- name: "Set 'vnstat_installed: True'"
|
|
set_fact:
|
|
vnstat_installed: True
|
|
|
|
- name: "Add 'vnstat_installed: True' to {{ iiab_state_file }}"
|
|
lineinfile:
|
|
path: "{{ iiab_state_file }}" # /etc/iiab/iiab_state.yml
|
|
regexp: '^vnstat_installed'
|
|
line: 'vnstat_installed: True'
|