diff --git a/roles/common/vars/os_Raspbian_9.yml b/roles/common/vars/os_Raspbian_9.yml new file mode 100644 index 0000000..3558d61 --- /dev/null +++ b/roles/common/vars/os_Raspbian_9.yml @@ -0,0 +1,25 @@ +--- +dependency_packages: + - expect + - ftp + - cadaver + - iperf + - iperf3 + - libpcap0.8 + - libsctp1 + - libsctp-dev + - libncurses-dev + - libssl-dev + - libpcap-dev + - vim + - mc + - smbclient + - ncurses-dev + - build-essential + - openvpn + - lightdm + - lxde + - realvnc-vnc-server + - aptitude + - chromium-browser + - raspberrypi-ui-mods diff --git a/roles/ntopng/files/ntopng b/roles/ntopng/files/ntopng new file mode 100644 index 0000000..402527c --- /dev/null +++ b/roles/ntopng/files/ntopng @@ -0,0 +1,3 @@ +# +# Command line options for ntopng... +OPTIONS="/etc/ntopng/ntopng.conf" diff --git a/roles/ntopng/files/ntopng.conf b/roles/ntopng/files/ntopng.conf new file mode 100644 index 0000000..52b461a --- /dev/null +++ b/roles/ntopng/files/ntopng.conf @@ -0,0 +1,60 @@ +# +# ntopng Configuration File: NST 2013 +# ====== ============= ===== === ==== + +# +# ***Note: When using this file with the NST WUI then +# 'Only' use the ntopng long option formats. + +# +# Verbose (Debug) +# ======= ======= +#--verbose + +# +# Network Interface(s): +# ======= ============= +# ***Note: To add more than one interface use multiple entries: +#--interface p3p1 +#--interface p3p2 +--interface eth0 + +# +# HTTP Access Port: +# ==== ====== ===== +--http-port 3000 + +# +# Local Networks: +# ===== ========= +# ***Note: To add more than one local network comma separate: +# --local-networks 172.16.1.0/24,172.31.1.0/24 +--local-networks 192.168.1.0/24 + +# +# ntopng Working Directory: +# ====== ======= ========== +--data-dir /var/nst/ntopng + +# +# DNS Address Resolution Mode: +# === ======= ========== ===== +--dns-mode 1 + +# +# Web Interface Logout For Inactivity: +# === ========= ====== === =========== +--disable-autologout + +# +# Disable Alerts: +# ======= ======= +--disable-alerts + +# +# Sticky Hosts +# ====== ===== +--sticky-hosts none +#--sticky-hosts local +#--sticky-hosts remote +#--sticky-hosts all diff --git a/roles/ntopng/files/ntopng.service b/roles/ntopng/files/ntopng.service new file mode 100644 index 0000000..88a0a84 --- /dev/null +++ b/roles/ntopng/files/ntopng.service @@ -0,0 +1,13 @@ +[Unit] +Description=ntopng Service +Requires=redis.service +After=syslog.target network.target redis.service + +[Service] +TimeoutStopSec=10s +EnvironmentFile=/etc/default/ntopng +WorkingDirectory=/usr/share/ntopng +ExecStart=/usr/local/bin/ntopng $OPTIONS + +[Install] +WantedBy=multi-user.target diff --git a/roles/ntopng/tasks/main.yaml b/roles/ntopng/tasks/main.yaml index 3b55eea..6866e12 100644 --- a/roles/ntopng/tasks/main.yaml +++ b/roles/ntopng/tasks/main.yaml @@ -1,25 +1,57 @@ --- -- name: Check if ntopng is installed - become: yes - command: dpkg-query -W "{{ ntopng_deb }}" - register: ntopng_check_deb - failed_when: ntopng_check_deb.rc > 1 - changed_when: ntopng_check_deb.rc == 1 -- name: Download ntopng - get_url: - url="{{ ntopng_deb_url }}" - dest="/home/{{ ansible_env.USER }}/Downloads/{{ ntopng_deb }}.deb" - when: ntopng_check_deb.rc == 1 -- name: Install ntopng source - become: yes - apt: deb="/home/{{ ansible_env.USER }}/Downloads/{{ ntopng_deb }}.deb" - when: ntopng_check_deb.rc == 1 -- name: install ntopng - become: yes - apt: - name: ntopng +- name: Include OS-specific variables + include_vars: "os_{{ ansible_lsb.id }}_{{ ansible_lsb.major_release }}.yml" +- name: install package dependencies + become: true + package: + name: "{{ ntopng_dependency_packages }}" state: present - update_cache: yes +- name: clone nDPI + git: + repo: https://github.com/ntop/nDPI.git + dest: "{{ ansible_user_dir }}/nDPI" +- name: clone ntopng + git: + repo: https://github.com/ntop/ntopng.git + dest: "{{ ansible_user_dir }}/ntopng" +- name: build nDPI + command: "./autogen.sh && ./configure --with-pic && make" + args: + chdir: "{{ ansible_user_dir }}/nDPI" +- name: build ntopng + command: "./autogen.sh && ./configure && make" + args: + chdir: "{{ ansible_user_dir }}/ntopng" +- name: install + become: yes + command: "make install" + args: + chdir: "{{ ansible_user_dir }}/ntopng" +- name: create directories + become: yes + file: + path: "{{ items }}" + state: directory + owner: ntopng + group: ntopng + with_items: + - /var/nst/ntopng + - /usr/share/ntopng + - /etc/ntopng +- name: copy files + template: + src: "{{ item.src }}" + dest: "{{ item.dest }}" + owner: root + group: root + with_items: + - { src: "{{ role_path }}/files/ntopng", dest: "/etc/default/ntopng" } + - { src: "{{ role_path }}/files/ntopng.conf", dest: "/etc/ntopng/ntopng.conf" } + - { src: "{{ role_path }}/files/ntopng.service", dest: "/etc/systemd/system/ntopng.service" } +- name: reload systemd + become: true + systemd: + daemon_reload: yes - name: start ntopng become: yes systemd: diff --git a/roles/ntopng/vars/os_Raspbian_10.yml b/roles/ntopng/vars/os_Raspbian_10.yml new file mode 100644 index 0000000..a076600 --- /dev/null +++ b/roles/ntopng/vars/os_Raspbian_10.yml @@ -0,0 +1,13 @@ +--- +ntopng_dependency_packages: + - autoconf + - shtool + - libtool + - libcurl4-openssl-dev + - libsqlite3-dev + - libmariadbclient-dev + - libreadline-dev + - libxml2-dev + - libglib2.0-dev + - redis + - libmaxminddb-dev diff --git a/roles/ntopng/vars/os_Raspbian_9.yml b/roles/ntopng/vars/os_Raspbian_9.yml new file mode 100644 index 0000000..f43d4a3 --- /dev/null +++ b/roles/ntopng/vars/os_Raspbian_9.yml @@ -0,0 +1,13 @@ +--- +ntopng_dependency_packages: + - autoconf + - shtool + - libtool + - libcurl4-openssl-dev + - libsqlite3-dev + - libmariadbclient-dev + - libreadline-dev + - libxml2-dev + - libglib2.0-dev + - redis-server + - libmaxminddb-dev