Mentions légales du service

Skip to content
Snippets Groups Projects
Commit ada14cf4 authored by autodistries's avatar autodistries
Browse files

check CHANGELOG.md

parent e18534e3
No related branches found
No related tags found
1 merge request!1Refactoring, new features
Showing
with 354 additions and 40 deletions
# Additions
# Modifications
## First master-nodes connection: SSH setup
In order to ease configuring ssh keys and passwordless authentication, the playbook **ssh_setup.yml** (previously **playbook_SSH_keygen.yml**) has been re-written.
- Asks for password and username
- Installs sshpass and keychain (master)
- Creates a ssh key (master)
- Copy public ssh key to authorized_hosts (nodes)
- Using .bashrc, autoload the ssh key (master)
## Nodes configuration
- install git, bc, + other optional packages (nodes)
- Switch off predictable netfowk interface naming (nodes)
- set up udev rules for forced interface naming (nodes)
- clone, build and install custom rtl8188 module (nodes)
- set up networkmanager to ignore wlan5..7
- copy script to setup interfaces monitor mode
- create crontab to run that cript when rebooted
## Data transfer (fetch results)
- Renamed playbook_data_transfer to data_transfer
- Move results to ../results/DATE/GROUP NAME, like SS1/INVENTORY NAME, like S1/filename"
## Update hosts
- Renamed from playbook_hosts to hosts_update
- Fix it
- Added super-sniffer inside hosts
ex: `192.168.1.244 ss2-s6`
## Hostame setup
- renamed from playbook_hostname to hostname_update
- added group (super-sniffer) to hostname: `ss2-s6`
## Experiment start
- renamed from playbook_scapy-sniffer_GPS.yml to start_sens_sniffer.yml
- Added and removed parameters to make it usable with mitik-sens
## Experiment interrupt
- Removes related crontabs
- Stops current sniffer.py processes
- hosts: all
tasks:
- name: set system hostname
command: sudo hostnamectl set-hostname {{ group_names[1] | default(group_names[0]) }}-{{ inventory_hostname }}
- name: host file update - Local DNS setup across all the servers
hosts: sniffers
gather_facts: yes
tasks:
- name: Update the /etc/hosts file with node name
tags: etchostsupdate
become: yes
become_user: root
lineinfile:
dest: "/etc/hosts"
regexp: ".*\t{{ hostvars[item]['ansible_hostname']}}\t{{ hostvars[item]['ansible_hostname']}}"
line: "{{ hostvars[item]['ansible_default_ipv4']['address'] }}\t{{ hostvars[item]['ansible_hostname']}}\t{{ hostvars[item]['ansible_hostname']}}"
state: present
register: etchostsupdate
when:
ansible_hostname != "item" or ansible_hostname == "item"
with_items: "{{groups['sniffers']}}"
...@@ -91,7 +91,7 @@ ...@@ -91,7 +91,7 @@
;debug=False ;debug=False
# (string) This indicates the command to use to spawn a shell under, which is required for Ansible's execution needs on a target. Users may need to change this in rare instances when shell usage is constrained, but in most cases, it may be left as is. # (string) This indicates the command to use to spawn a shell under, which is required for Ansible's execution needs on a target. Users may need to change this in rare instances when shell usage is constrained, but in most cases, it may be left as is.
executable=/bin/bash ;executable=/bin/bash
# (string) This option allows you to globally configure a custom path for 'local_facts' for the implied :ref:`ansible_collections.ansible.builtin.setup_module` task when using fact gathering. # (string) This option allows you to globally configure a custom path for 'local_facts' for the implied :ref:`ansible_collections.ansible.builtin.setup_module` task when using fact gathering.
# If not set, it will fall back to the default from the ``ansible.builtin.setup`` module: ``/etc/ansible/facts.d``. # If not set, it will fall back to the default from the ``ansible.builtin.setup`` module: ``/etc/ansible/facts.d``.
...@@ -134,7 +134,7 @@ executable=/bin/bash ...@@ -134,7 +134,7 @@ executable=/bin/bash
;hash_behaviour=replace ;hash_behaviour=replace
# (pathlist) Comma-separated list of Ansible inventory sources # (pathlist) Comma-separated list of Ansible inventory sources
inventory=./hosts inventory=./inventory
# (pathspec) Colon-separated paths in which Ansible will search for HttpApi Plugins. # (pathspec) Colon-separated paths in which Ansible will search for HttpApi Plugins.
;httpapi_plugins=/home/guigui/.ansible/plugins/httpapi:/usr/share/ansible/plugins/httpapi ;httpapi_plugins=/home/guigui/.ansible/plugins/httpapi:/usr/share/ansible/plugins/httpapi
...@@ -326,7 +326,7 @@ inventory=./hosts ...@@ -326,7 +326,7 @@ inventory=./hosts
;inject_facts_as_vars=True ;inject_facts_as_vars=True
# (string) Path to the Python interpreter to be used for module execution on remote targets, or an automatic discovery mode. Supported discovery modes are ``auto`` (the default), ``auto_silent``, ``auto_legacy``, and ``auto_legacy_silent``. All discovery modes employ a lookup table to use the included system Python (on distributions known to include one), falling back to a fixed ordered list of well-known Python interpreter locations if a platform-specific default is not available. The fallback behavior will issue a warning that the interpreter should be set explicitly (since interpreters installed later may change which one is used). This warning behavior can be disabled by setting ``auto_silent`` or ``auto_legacy_silent``. The value of ``auto_legacy`` provides all the same behavior, but for backward-compatibility with older Ansible releases that always defaulted to ``/usr/bin/python``, will use that interpreter if present. # (string) Path to the Python interpreter to be used for module execution on remote targets, or an automatic discovery mode. Supported discovery modes are ``auto`` (the default), ``auto_silent``, ``auto_legacy``, and ``auto_legacy_silent``. All discovery modes employ a lookup table to use the included system Python (on distributions known to include one), falling back to a fixed ordered list of well-known Python interpreter locations if a platform-specific default is not available. The fallback behavior will issue a warning that the interpreter should be set explicitly (since interpreters installed later may change which one is used). This warning behavior can be disabled by setting ``auto_silent`` or ``auto_legacy_silent``. The value of ``auto_legacy`` provides all the same behavior, but for backward-compatibility with older Ansible releases that always defaulted to ``/usr/bin/python``, will use that interpreter if present.
interpreter_python=/usr/bin/python3.11 ;interpreter_python=/usr/bin/python3.11
# (boolean) If 'false', invalid attributes for a task will result in warnings instead of errors. # (boolean) If 'false', invalid attributes for a task will result in warnings instead of errors.
;invalid_task_attribute_failed=True ;invalid_task_attribute_failed=True
......
[sniffers:children]
ss1
ss2
[ss1] [ss1]
s1 ansible_host=192.168.1.184 s1 ansible_host=192.168.1.184 ansible_ssh_user=user
s2 ansible_host=192.168.1.231 s2 ansible_host=192.168.1.231
s3 ansible_host=192.168.1.239 s3 ansible_host=192.168.1.239
s4 ansible_host=192.168.1.248
[ss2] [ss2]
s4 ansible_host=192.168.1.248
s5 ansible_host=192.168.1.246 s5 ansible_host=192.168.1.246
s6 ansible_host=192.168.1.244
[test] [test]
rp4 ansible_host=192.168.1.248 s6 ansible_host=192.168.1.244
# rp4 ansible_host=192.168.1.248
[sniffers:children]
ss1
ss2
[all:vars] [all:vars]
ansible_connection=ssh ansible_connection=ssh
ansible_ssh_user=tribe ansible_ssh_user=tribe
ansible_python_interpreter=/usr/bin/python3
ansible_executable=/bin/bash
- hosts: ss2 - hosts: s6
tasks: tasks:
- name: set system hostname
command: echo {{ group_names[1] | default(group_names[0]) }}-{{ inventory_hostname }}
register: outt - name: Clone sens repository
- debug: ansible.builtin.git:
msg: "{{outt.stdout}}" repo: https://mitik-sens-mod:glpat-F9S1EPn2KKts_a8syNWu@gitlab.inria.fr/gfarhiri/mitik-sens-mod
dest: ~/mitik-sens-mod
update: true
register: outr
- debug:
msg: "{{outr}}"
[keyfile]
unmanaged-devices=interface-name:wlan5;interface-name:wlan6;interface-name:wlan7;interface-name:wlan8
#!/bin/sh
# Check if interfaces exist before attempting to configure them
if [ -n "$(ip link show wlan5 2>/dev/null)" ]; then
sudo ifconfig wlan5 up
sudo ifconfig wlan5 down
sudo iwconfig wlan5 mode monitor
sudo ifconfig wlan5 up
echo "Set wlan5 to monitor mode"
fi
if [ -n "$(ip link show wlan6 2>/dev/null)" ]; then
sudo ifconfig wlan6 up
sudo ifconfig wlan6 down
sudo iwconfig wlan6 mode monitor
sudo ifconfig wlan6 up
echo "Set wlan6 to monitor mode"
fi
if [ -n "$(ip link show wlan7 2>/dev/null)" ]; then
sudo ifconfig wlan7 up
sudo ifconfig wlan7 down
sudo iwconfig wlan7 mode monitor
sudo ifconfig wlan7 up
echo "Set wlan7 to monitor mode"
fi
if [ -n "$(ip link show wlan8 2>/dev/null)" ]; then
sudo ifconfig wlan8 up
sudo ifconfig wlan8 down
sudo iwconfig wlan8 mode monitor
sudo ifconfig wlan8 up
echo "Set wlan8 to monitor mode"
fi
...@@ -28,7 +28,7 @@ A modified version of Raspian has been provided by [1], as part of the experimen ...@@ -28,7 +28,7 @@ A modified version of Raspian has been provided by [1], as part of the experimen
## **Sniffer manager** ## **Sniffer manager**
A sniffer manager is defined in a Mitik laptop (Macbook Pro). All the instructions executed in the sniffers are defined in the sniffer manager. To establish communication with the sniffers, an inventory with specific parameters is defined.Each sniffer is assigned a static IP. Besides that, sniffers are organized in groups (super-sniffers). _inventory_ shows the definition for each sniffer. Four groups (super-sniffers) are defined (ss1 to ss4), and each one contains five sniffers (sniffer#-ss#). A sniffer manager is defined in a Mitik laptop (Macbook Pro). All the instructions executed in the sniffers are defined in the sniffer manager. To establish communication with the sniffers, an inventory with specific parameters is defined. Each sniffer is assigned a static IP. Besides that, sniffers are organized in groups (super-sniffers). _inventory_ shows the definition for each sniffer. Four groups (super-sniffers) are defined (ss1 to ss4), and each one contains five sniffers (sniffer#-ss#).
In addition to the inventory, the sniffer manager sends all the instructions and configurations contained in the playbooks to be executed in each sniffer. In addition to the inventory, the sniffer manager sends all the instructions and configurations contained in the playbooks to be executed in each sniffer.
......
# This script copies resulting capture files to ../results folder
- hosts: sniffers - hosts: sniffers
vars:
remote_src_file: "/home/tribe/mitik-sens-mod/capture-*.pcap"
dest_file: "../results/"
cap_file: capture-*
tasks: tasks:
- name: find files to copy - name: find files to copy
find: find:
paths: "/home/tribe/mitik-sens-mod/" paths: "~/termporary-transfer-sniffer/hopping-time-tests/" # top folder to search from/in
recurse: no recurse: yes # yes|no recursive file search ?
patterns: "capture-*.pcap" patterns: "*.pcap" # what your target files look like
register: files_to_copy register: files_to_copy
- name: Copy files - name: Copy files
fetch: fetch:
src: "{{ item.path }}" src: "{{ item.path }}"
dest: "../results/{{ ansible_date_time.date }}/{{ group_names[1] }}/{{ inventory_hostname }}/" dest: "../results/{{ ansible_date_time.date }}/{{ group_names[1] | default(group_names[0] | default('nogroup')) }}/{{ inventory_hostname }}/"
flat: yes flat: yes
with_items: "{{ files_to_copy.files }}" with_items: "{{ files_to_copy.files }}"
# Device configuration. Can be ran multiple times on one device
- name: Set up the sniffers
hosts: s6
become: yes
become_user: root
tasks:
- name: Install packages
tags: sniffer-setup config nodes
apt:
pkg:
# required
- git # to clone rtl8188 repo
- bc # required to compile the rtl8188 driver
# optional
# - lshw # list hardware and drivers
# - tcpdump # capture and view packets from command-line
# - python3-scapy # capture packets using python
- name: Switch off predictable naming mechanism mechanism
tags: nodes device-setup
command: sudo ls -nfs /dev/null /etc/systemd/network/99-default.link
- name: Copy UDEV rules to set interface names based on physical USB positions
tags: device-setup nodes
copy:
src: "../files/72-wlan-geo-dependent.rules"
dest: /etc/udev/rules.d/72-wlan-geo-dependent.rules
- name: Build and install rtl8188eus module
tags: device-setup config nodes
shell: |
ls ./rtl8188eus 2>/dev/null || git clone https://github.com/aircrack-ng/rtl8188eus/ # only pull if it doesn't already exists
cd rtl8188eus
make && sudo make install
echo 'blacklist rtl8xxxu' | sudo tee -a '/etc/modprobe.d/realtek.conf' #this is the default driver that we don't want it to use
sudo rmmod rtl8xxxu
sudo modprobe 8188eu
- name: Setup NetworkManager to ignore wlan5..8
tags: device-setup network nodes
copy:
src: "../files/99-unmanaged-devices.conf"
dest: /etc/NetworkManager/conf.d/99-unmanaged-devices.conf
- name: Copy setInterfacesToMonitorMode.sh to ~/setInterfacesToMonitorMode.sh
tags: device-setup nodes
copy:
src: "../files/setInterfacesToMonitorMode.sh"
dest: "~/setInterfacesToMonitorMode.sh"
mode: '0770'
- name: Crontab - set interfaces to monitor mode on reboot
ansible.builtin.cron:
name: "setInterfacesToMonitorMode.sh"
special_time: reboot
job: "~/setInterfacesToMonitorMode.sh"
- name: Clone and/or sens repository
ansible.builtin.git:
repo: https://mitik-sens-mod:glpat-F9S1EPn2KKts_a8syNWu@gitlab.inria.fr/gfarhiri/mitik-sens-mod
dest: ~/mitik-sens-mod
update: true
- import_playbook: hostname_update.yml
- import_playbook: hosts_update.yml
- name: idk,reboot
hosts: s6
become: yes
become_user: root
vars_prompt:
- name: user_reboot
prompt: If this is your first configuration ever, it is advised to reboot. Reboot ? (y/n)
default: "n"
private: no
tasks:
- name: Perform reboot
ansible.builtin.reboot:
post_reboot_delay: 30
when: user_reboot == 'y'
# This playbook sets the hostname of targets to group-device name (ss1-s1)
- hosts: s6
tasks:
- name: set system hostname
shell: sudo hostnamectl set-hostname {{ group_names[1] | default(group_names[0]) }}-{{ inventory_hostname }}
# This update the hosts file of all nodes with local addresses of all nodes
# 192.168.1.184 ss2-s1
# 192.168.1.231 ss2-s2
# 192.168.1.239 ss2-s3
# 192.168.1.248 ss2-s4
# 192.168.1.246 ss2-s5
# 192.168.1.244 ss2-s6
# It works when this line does not exist before; it also updates existing lines if necessary
- name: host file update - Local DNS setup across all the nodes
hosts: sniffers
gather_facts: yes
become: yes
become_user: root
tasks:
- name: Add IP address of all hosts to all hosts
lineinfile:
dest: "/etc/hosts"
regexp: '.*{{ item }}$'
line: "{{ hostvars[item].ansible_host }} {{ group_names[1] | default(group_names[0] | default('nogroup')) }}-{{item}}"
state: present
when: hostvars[item].ansible_host is defined
with_items: "{{ groups.sniffers }}"
- hosts: sniffers
gather_facts: false
user: gta
become: yes
become_user: root
tasks:
#GPIO status
- name: GPIO status test
shell: raspi-gpio get 18 | awk -F" | |=" '{print $4}'
register: result
- name: GPS module enabled
debug:
msg: "GPS module is enabled"
when: result.stdout == '0'
- name: GPS module disabled
debug:
msg: "GPS module is disabled"
when: result.stdout != '0'
# Copies network interfaces naming scheme (based on physical usb location)
- hosts: sniffers - hosts: sniffers
become: yes become: yes
become_user: root become_user: root
...@@ -8,5 +9,5 @@ ...@@ -8,5 +9,5 @@
- name: Copy new rules to identify interfaces based on USB positions - name: Copy new rules to identify interfaces based on USB positions
copy: copy:
src: "{{ playbook_dir }}/../../files/72-wlan-geo-dependent.rules" src: "../files/72-wlan-geo-dependent.rules"
dest: /etc/udev/rules.d/72-wlan-geo-dependent.rules dest: /etc/udev/rules.d/72-wlan-geo-dependent.rules
# Why do we need to get public key of remote nodes ?
# (and why not give all nodes OUR (master) public key instead ?)
- name: Exchange Keys between servers - name: Exchange Keys between servers
hosts: sniffers hosts: sniffers
tasks: tasks:
......
- hosts: all
gather_facts: true
become: yes
become_user: root
vars:
active_interfaces: "{{ ansible_interfaces | reject('==', 'lo') | reject('==', 'eth0') }}"
interfaces_list_raw: >-
{{
hostvars[inventory_hostname]
| dict2items
| selectattr('value.device', 'defined')
| selectattr('value.device', 'in', active_interfaces)
| map(attribute='value')
}}
interface_query: >-
[].[device, macaddress]
interfaces_formated_list: >-
{{ interfaces_list_raw | json_query(interface_query) | map('join', ': ') }}
tasks:
#Interfaces status
- name: Interfaces connected
debug:
#var: interfaces_formated_list
msg: "Interfaces: {{ interfaces_formated_list }}"
- hosts: sniffers
gather_facts: false
user: gta
become: yes
become_user: root
tasks:
#Services status
- name: Check time sync service status
systemd:
name: "chronyd.service"
register: chrony_service
- name: Check gpsd_scoket status
systemd:
name: "gpsd.socket"
register: gpsd_socket
- name: Check gpsd_sservice status
systemd:
name: "gpsd.service"
register: gpsd_service
- name: Check networking status
systemd:
name: "networking.service"
register: networking_service
- name: Service status
debug:
#var: gpsd_socket.status.ActiveState
msg: "chrony: {{ chrony_service.status.ActiveState }}, gpsd socket: {{ gpsd_socket.status.ActiveState }}, gpsd service: {{ gpsd_service.status.ActiveState }}, networking: {{ networking_service.status.ActiveState }}"
- import_playbook: playbook_interfaces_status
- import_playbook: playbook_GPIO_status
- import_playbook: playbook_service_status
- import_playbook: playbook_time
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment