---

- name: Ensure batctl is installed
  apt: name=batctl

- name: Enable batman module on boot
  lineinfile: dest=/etc/modules line=batman_adv

- name: Load batman-adv kernel module
  modprobe: name=batman_adv state=present

- name: Install batman-adv mesh interface definition
  template:
    dest: "/etc/network/interfaces.d/40_batman.cfg"
    src: "batman.cfg.j2"

- name: Install gretap tunnel definitions
  template:
    dest: "/etc/network/interfaces.d/45_batman-tunnel.cfg"
    src: "batman-tunnel.cfg.j2"

- name: Install IPv6 routing to bat0
  template: src=batman6.conf.j2 dest=/etc/bird/conf6.d/batman6.conf
  notify: Reload bird daemons

- name: Install IPv4 routing to bat0
  template: src=batman.conf.j2 dest=/etc/bird/conf.d/batman.conf
  notify: Reload bird daemons
