mirror of
https://github.com/iiab/iiab.git
synced 2025-03-09 15:40:17 +00:00
Merge pull request #3562 from holta/vnstat2
Toughen up vnStat: Mitigate #3539 db errors, stop using 2011's /etc/vnstat.conf, etc
This commit is contained in:
commit
7db038c72c
3 changed files with 33 additions and 14 deletions
|
@ -1,21 +1,36 @@
|
|||
# Similar code block in roles/network/tasks/detected_network.yml
|
||||
- name: "Setting iiab_wan_iface to '{{ ansible_default_ipv4.alias }}' -- using ansible_default_ipv4.alias if detected"
|
||||
set_fact:
|
||||
iiab_wan_iface: "{{ ansible_default_ipv4.alias }}"
|
||||
when: ansible_default_ipv4.gateway is defined
|
||||
|
||||
|
||||
- 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'
|
||||
|
||||
# Similar code block in roles/network/tasks/detected_network.yml (line ~35) and roles/network/tasks/computed_network.yml (lines ~74 and ~110)
|
||||
- name: "Setting iiab_wan_iface to '{{ ansible_default_ipv4.alias }}' -- using ansible_default_ipv4.alias if detected"
|
||||
set_fact:
|
||||
iiab_wan_iface: "{{ ansible_default_ipv4.alias }}"
|
||||
when: ansible_default_ipv4.gateway is defined
|
||||
|
||||
# 2023-05-01: Probably no longer nec, as line 'Interface ""' in /etc/vnstat.conf (as installed by apt) automatically selects the default interface
|
||||
- name: Insert 'Interface "{{ iiab_wan_iface }}"' into /etc/vnstat.conf
|
||||
lineinfile:
|
||||
path: /etc/vnstat.conf
|
||||
regexp: '^Interface '
|
||||
line: 'Interface "{{ iiab_wan_iface }}"'
|
||||
|
||||
# - name: Install /etc/vnstat.conf from template
|
||||
# template:
|
||||
# src: vnstat.conf.j2
|
||||
# dest: /etc/vnstat.conf
|
||||
# mode: '0744'
|
||||
|
||||
|
||||
# 2023-05-01: https://github.com/vergoh/vnstat/issues/134#issuecomment-663836557
|
||||
- name: 'Precautionary Start & Enable of vnstat.service, to mitigate intermittent #3539 (''Failed to open database "/var/lib/vnstat/vnstat.db" in read-only mode'') during WAN db creation just below'
|
||||
systemd:
|
||||
name: vnstat
|
||||
daemon_reload: true
|
||||
state: started
|
||||
enabled: true
|
||||
|
||||
- name: Create database for WAN to collect vnStat data
|
||||
shell: /usr/bin/vnstat -i {{ iiab_wan_iface }}
|
||||
|
|
8
test.yml
8
test.yml
|
@ -27,11 +27,15 @@
|
|||
|
||||
- name: DOUBLE UP to escape single quotes... '"''"' e.g. iiab.ini descriptions for azuracast, captiveportal, mosquitto, munin, nodejs, osm-vector-maps, sshd
|
||||
debug:
|
||||
msg: '"''"' # FAILS: '"\'"'
|
||||
msg: '"''"' # OR: '''' FAILS: '"\'"'
|
||||
|
||||
- name: BACKSLASH to escape double quotes... "'\"'" e.g. cups/tasks/install.yml
|
||||
debug:
|
||||
msg: "'\"'" # FAILS: "'""'"
|
||||
msg: "'\"'" # OR: "\"" FAILS: "'""'"
|
||||
|
||||
- name: "Entire string must be enclosed in quotes if using ' #' Space-then-Pound/Hash sequence -- or right side will be a comment! e.g. roles/vnstat/install.yml"
|
||||
debug:
|
||||
msg: "Left side # Right side"
|
||||
|
||||
- name: a shows "VARIABLE IS NOT DEFINED!" -- whereas b (w/o whitespace) AND c (with space) AND d (with tab, STRICTLY DISALLOWED IN YAML BY ansible-core 2.11.6) showed null (without quotes!) -- whereas e (singlequotes) and f (doublequotes) show "" empty string
|
||||
set_fact:
|
||||
|
|
Loading…
Add table
Reference in a new issue