# Playbook to prepare Olimex board to run a MOD-ENV sensor and
# parse the tracked data to Fluentd

- import_playbook: wendelin-olimex-base.yml

- name: a play that runs entirely on the ansible host
  hosts: 127.0.0.1
  connection: local

  vars:
    - iptables_rules: |
        # To allow connection to SlapOS master
        # (for requesting Fluentd instance)

        # Only accept packets on the INPUT chain that are ESTABLISHED or RELATED to a current connection
        iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT

        # Accept DNS
        iptables -A OUTPUT -p tcp --dport 53 -j ACCEPT
        iptables -A OUTPUT -p udp --dport 53 -j ACCEPT

        # Accept HTTP
        iptables -A OUTPUT -p tcp --dport 80 -j ACCEPT

        # Accept HTTPS
        iptables -A OUTPUT -p tcp --dport 443 -j ACCEPT
        iptables -A OUTPUT -p udp --dport 443 -j ACCEPT

        # To send data to IoT Gateway

        LISTEN_SENSOR_PORT=24224

        ip6tables -A OUTPUT -o eth0 -j ACCEPT

        ip6tables -A INPUT -p tcp --sport $LISTEN_SENSOR_PORT -j ACCEPT 
        ip6tables -A INPUT -p udp --sport $LISTEN_SENSOR_PORT -j ACCEPT

  roles:
    - role: olimex-sensor
    - role: olimex-board
