mirror of
https://github.com/unman/shaker.git
synced 2025-02-02 17:44:49 -05:00
Monitor - create monitoring qube
This commit is contained in:
parent
aceb67d69d
commit
5078086f63
68
monitor/README.md
Normal file
68
monitor/README.md
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
# Introduction
|
||||||
|
These files create a template, with tools installed for network monitoring.
|
||||||
|
An AppVM named sys-monitor, is created from that template.
|
||||||
|
|
||||||
|
## Template
|
||||||
|
The template, template-monitor, is cloned from the debian-12-minimal template.
|
||||||
|
If the debian-12-minimal template is not present, it will be downloaded
|
||||||
|
and installed - this may take some time depending on your net connection.
|
||||||
|
|
||||||
|
The template has passwordless root installed, so you can run packet captures using `sudo..`.
|
||||||
|
If you want to run wireshark as an ordinary user, open a terminal in template-monitor and run
|
||||||
|
`sudo dpkg-reconfigure wireshark-common`.
|
||||||
|
Answer `Yes` to the question, "should non-superusers be able to capture packets?"
|
||||||
|
Run `sudo usermod -a -G wireshark user`.
|
||||||
|
Shut down the template.
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
sys-monitor is created with `provides_network` set, so you can attach qubes to it, setting it as netvm.
|
||||||
|
Wireshark, suricata, tcpdump, and tcpflow are installed and ready to run.
|
||||||
|
For wireshark see the note above about running as an ordinary user - useful if you want to start from the Q Menu.
|
||||||
|
|
||||||
|
As with all Debian templates, services are masked in the template.
|
||||||
|
This is done in `create.sls`
|
||||||
|
The suricata service is *unmasked* in the qube, by an entry in `/rw/config/rc.local` which is created in `config.sls`.
|
||||||
|
This means that you can simply run `sudo systemctl start suricata` to have suricata running with default settings.
|
||||||
|
Alternatively you can start the service with a custom configuration, as you will.
|
||||||
|
|
||||||
|
By default sys-monitor has sys-net as netvm, but you can change this if you wish.
|
||||||
|
You can monitor traffic at eth0 or at any of the vif interfaces to downstream qubes.
|
||||||
|
|
||||||
|
You can, of course, use template-monitor to create other qubes for monitoring at different positions in the Qubes networking structure..
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
Copy the monitor folder to /srv/salt.
|
||||||
|
```
|
||||||
|
qubesctl state.apply monitor.create
|
||||||
|
qubesctl --skip-dom0 --targets=template-monitor state.apply monitor.install
|
||||||
|
qubesctl --skip-dom0 --targets=sys-monitor state.apply monitor.configure
|
||||||
|
```
|
||||||
|
### Template creation
|
||||||
|
Clone the debian-12-minimal template - note the use of `qvm.template_installed` which will install the template if it is not already present
|
||||||
|
```
|
||||||
|
sudo qubesctl state.apply monitor.clone
|
||||||
|
```
|
||||||
|
`clone.sls` uses `qvm.features` to set the menu. Note that you can do this *before* the relevant packages are installed.
|
||||||
|
|
||||||
|
### Qube creation
|
||||||
|
`create.sls` is a standard way of creating `sys-monitor` - qvm.present is used to create the qube, and preferences and features are set.
|
||||||
|
|
||||||
|
Note the use of an `include` statement at the head of the file. This allows a single state execution to call other states.
|
||||||
|
So `qubesctl state.apply monitor.create` will call and run `monitor.clone`.
|
||||||
|
|
||||||
|
|
||||||
|
### Package installation
|
||||||
|
```
|
||||||
|
sudo qubesctl --skip-dom0 --targets=template-monitor state.apply monitor.install
|
||||||
|
|
||||||
|
```
|
||||||
|
This state uses `pkg.installed` to install necessary packages in the template.
|
||||||
|
Note the use of `pillar.get` to check if a caching proxy is present: the necessary changes to repository definitions are made using `file.replace` within a jinja command structure.
|
||||||
|
|
||||||
|
### Configuration
|
||||||
|
```
|
||||||
|
sudo qubesctl --skip-dom0 --targets=sys-monitor state.apply monitor.configure
|
||||||
|
```
|
||||||
|
This state uses `file.append` to make sure that the suricata service is unmasked in the qube.
|
||||||
|
The command is run from /rw/config/rc.local: file.append` is used to alter that file.
|
||||||
|
`file.append` will only add the text if it is not already present.
|
16
monitor/clone.sls
Normal file
16
monitor/clone.sls
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
monitor_precursor:
|
||||||
|
qvm.template_installed:
|
||||||
|
- name: debian-12-minimal
|
||||||
|
|
||||||
|
qvm-clone-monitor:
|
||||||
|
qvm.clone:
|
||||||
|
- name: template-monitor
|
||||||
|
- source: debian-12-minimal
|
||||||
|
|
||||||
|
qvm-features-template-monitor:
|
||||||
|
qvm.features:
|
||||||
|
- name: template-monitor
|
||||||
|
- set:
|
||||||
|
- menu-items: "org.wireshark.Wireshark.desktop debian-uxterm.desktop"
|
||||||
|
- default-menu-items: "org.wireshark.Wireshark.desktop debian-uxterm.desktop"
|
||||||
|
|
4
monitor/clone.top
Normal file
4
monitor/clone.top
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
base:
|
||||||
|
dom0:
|
||||||
|
- match: nodegroup
|
||||||
|
- monitor.clone
|
9
monitor/configure.sls
Normal file
9
monitor/configure.sls
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
# vim: set syntax=yaml ts=2 sw=2 sts=2 et :
|
||||||
|
|
||||||
|
{% if grains['nodename'] != 'dom0' %}
|
||||||
|
|
||||||
|
/rw/config/rc.local:
|
||||||
|
file.append:
|
||||||
|
- text: systemctl unmask suricata
|
||||||
|
|
||||||
|
{% endif %}
|
31
monitor/create.sls
Normal file
31
monitor/create.sls
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
include:
|
||||||
|
- monitor.clone
|
||||||
|
|
||||||
|
qvm-present-monitor:
|
||||||
|
qvm.present:
|
||||||
|
- name: sys-monitor
|
||||||
|
- template: template-monitor
|
||||||
|
- label: green
|
||||||
|
|
||||||
|
qvm-prefs-monitor:
|
||||||
|
qvm.prefs:
|
||||||
|
- name: sys-monitor
|
||||||
|
- netvm: sys-net
|
||||||
|
- memory: 400
|
||||||
|
- maxmem: 1500
|
||||||
|
- vcpus: 2
|
||||||
|
- provides-network: True
|
||||||
|
|
||||||
|
qvm-features-monitor:
|
||||||
|
qvm.features:
|
||||||
|
- name: sys-monitor
|
||||||
|
- ipv6: ''
|
||||||
|
- disable:
|
||||||
|
- service.cups
|
||||||
|
- service.cups-browsed
|
||||||
|
- service.tinyproxy
|
||||||
|
- set:
|
||||||
|
- menu-items: "org.wireshark.Wireshark.desktop debian-uxterm.desktop"
|
||||||
|
|
||||||
|
'qvm-volume extend sys-monitor:private 40G' :
|
||||||
|
cmd.run
|
4
monitor/create.top
Normal file
4
monitor/create.top
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
base:
|
||||||
|
dom0:
|
||||||
|
- match: nodegroup
|
||||||
|
- monitor.create
|
56
monitor/install.sls
Normal file
56
monitor/install.sls
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
# vim: set syntax=yaml ts=2 sw=2 sts=2 et :
|
||||||
|
#
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
|
{% if salt['pillar.get']('update_proxy:caching') %}
|
||||||
|
{% set proxy = 'cacher' %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if grains['nodename'] != 'dom0' %}
|
||||||
|
{% if grains['os_family']|lower == 'debian' %}
|
||||||
|
{% if grains['nodename']|lower != 'host' %}
|
||||||
|
{% if proxy == 'cacher' %}
|
||||||
|
{% for repo in salt['file.find']('/etc/apt/sources.list.d/', name='*list') %}
|
||||||
|
{{ repo }}_baseurl:
|
||||||
|
file.replace:
|
||||||
|
- name: {{ repo }}
|
||||||
|
- pattern: 'https://'
|
||||||
|
- repl: 'http://HTTPS///'
|
||||||
|
- flags: [ 'IGNORECASE', 'MULTILINE' ]
|
||||||
|
- backup: False
|
||||||
|
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
/etc/apt/sources.list:
|
||||||
|
file.replace:
|
||||||
|
- name: /etc/apt/sources.list
|
||||||
|
- pattern: 'https:'
|
||||||
|
- repl: 'http://HTTPS/'
|
||||||
|
- flags: [ 'IGNORECASE', 'MULTILINE' ]
|
||||||
|
- backup: False
|
||||||
|
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
installed:
|
||||||
|
pkg.installed:
|
||||||
|
- pkgs:
|
||||||
|
- qubes-core-agent-networking
|
||||||
|
- qubes-core-agent-passwordless-root
|
||||||
|
- mate-notification-daemon
|
||||||
|
- suricata
|
||||||
|
- tcpdump
|
||||||
|
- tcpflow
|
||||||
|
- wireshark
|
||||||
|
|
||||||
|
systemd-disable-suricata:
|
||||||
|
cmd.run:
|
||||||
|
- name: systemctl disable suricata
|
||||||
|
|
||||||
|
systemd-mask-suricata:
|
||||||
|
cmd.run:
|
||||||
|
- name: systemctl mask suricata
|
||||||
|
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
5
monitor/install.top
Normal file
5
monitor/install.top
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
# vim: set syntax=yaml ts=2 sw=2 sts=2 et :
|
||||||
|
|
||||||
|
base:
|
||||||
|
template-monitor:
|
||||||
|
- monitor.install
|
Loading…
x
Reference in New Issue
Block a user