Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Old docker-compose no longer works . #9

Merged
merged 38 commits into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
9b6274f
Old docker-compose no longer works .
hussamnasir Jul 31, 2024
2342faf
More corrections to docker usage in ansible
hussamnasir Jul 31, 2024
bdf4dca
Add Fabric Service Role for central VM node_exporter installs
hussamnasir Aug 7, 2024
626afc8
Modified some vars and allowed for also gathering the auth.log/secure
hussamnasir Aug 16, 2024
4d04cf9
One more file update
hussamnasir Aug 16, 2024
48177a6
Minor typo
hussamnasir Aug 16, 2024
1b60334
Missed one more
hussamnasir Aug 16, 2024
2ffaa35
Minor syntax fix
hussamnasir Aug 19, 2024
5ea945b
Mount /var/log regardless
hussamnasir Aug 19, 2024
d8f9072
one more typo
hussamnasir Aug 19, 2024
4183ba0
One more
hussamnasir Aug 19, 2024
6cddb05
Finally have a working version
hussamnasir Aug 19, 2024
58ecac4
special case for nat64-gw at RENC
hussamnasir Aug 26, 2024
8c1e0cc
Line space
hussamnasir Aug 26, 2024
7b46543
Add volumes to container in RO mode
hussamnasir Aug 28, 2024
a5e875e
More updates
hussamnasir Aug 28, 2024
ecb3a44
Update the beats code to use docker compose v2 ansible plugin where
hussamnasir Aug 28, 2024
5e9c482
Two more bug fixes
hussamnasir Aug 28, 2024
f1c0514
Update the fiebeat config
hussamnasir Aug 29, 2024
cda8ba2
Modified version of docker-compose file
hussamnasir Aug 29, 2024
38c70ee
Fix typo
hussamnasir Aug 29, 2024
0f36503
Fix lots of typos and yaml syntax error (spaces are yaml enemies)
hussamnasir Aug 29, 2024
4ee60ab
spaces spaces...
hussamnasir Aug 29, 2024
bf3ff39
Hopefully final update
hussamnasir Aug 29, 2024
124b3ad
A few more corrections
hussamnasir Aug 29, 2024
214e958
Modify beats and logstash to conform to Security Team requirements
hussamnasir Sep 3, 2024
3c9b6f4
Fix minor conditional statement check
hussamnasir Sep 3, 2024
fe71d64
Added logs for websession.fabric-testbed.net
hussamnasir Sep 5, 2024
2b92812
Check for docker version variable
hussamnasir Sep 9, 2024
50805b0
Fix "find docker compose version " script
hussamnasir Sep 9, 2024
8f81a81
repeat for lagstash
hussamnasir Sep 9, 2024
bef583e
Added nginx filebeat module
hussamnasir Sep 16, 2024
fe751e9
Fix typo
hussamnasir Sep 16, 2024
ae85652
One more try at fixing the typo
hussamnasir Sep 16, 2024
9f441ec
Minor fix
hussamnasir Sep 16, 2024
6dce091
Some beats modules do not support tags. Force add tags using processors
hussamnasir Sep 17, 2024
9712010
Update docker module calls in ansible to be backward compatible
hussamnasir Oct 11, 2024
e37a013
Converted the URL so that it can be used as a tokenized pull
hussamnasir Oct 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,48 @@
- { src: "filebeat.yml.j2", dest: "/opt/beats/filebeat-docker.yml" }
- { src: "docker-compose.yml.j2", dest: "/opt/beats/docker-compose.yml" }

- name: Start Filebeat
community.docker.docker_compose:
project_src: /opt/beats/
state: present
restarted: true
debug: false
register: output

- name: Check if service is running
ansible.builtin.assert:
that:
- "output.services.filebeat.fabric_beats_filebeat.state.running"
- name: Find Docker Compose version
shell: docker compose version --short 2>/dev/null || docker-compose version --short
register: docker_compose_version
ignore_errors: True


- block:
- name: Start Filebeat
community.docker.docker_compose:
project_src: /opt/beats/
state: present
restarted: true
debug: false
register: output

- name: Check if service is running
ansible.builtin.assert:
that:
- "output.services.filebeat.fabric_beats_filebeat.state.running"
when:
- docker_compose_version is defined
- "docker_compose_version.stdout is version('2.18.0','<')"

- block:
- name: Start Filebeat
community.docker.docker_compose_v2:
project_src: /opt/beats/
state: present
pull: always
build: always
recreate: always
register: output

- name: Check if service is running
ansible.builtin.assert:
that:
#- "output.services.filebeat.fabric_beats_filebeat.state.running"
- beats_container.State == "running"
vars:
beats_container: >-
{{ output.containers | selectattr("Service", "equalto", "filebeat") | first }}

when:
- docker_compose_version is defined
- "docker_compose_version.stdout is version('2.18.0','>=')"
4 changes: 2 additions & 2 deletions instrumentize/elk/fabric-rack/roles/filebeat/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

- include_tasks: install_beats.yml
- import_tasks: install_beats.yml
when: op == 'install'

- include_tasks: remove_beats.yml
- import_tasks: remove_beats.yml
when: op == 'remove'
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,19 @@ services:
volumes:
- "/var/run/docker.sock:/var/run/docker.sock"
- "/var/lib/docker/containers/:/var/lib/docker/containers/:ro"
{% if component_type != 'head' and component_type != 'worker' %}
{% for collector in logs_collection %}
{% if hostname in collector.hosts and "/home/nrig-service/ControlFramework/fabric_cf" not in collector.log_path %}
- "{{ collector.log_path|dirname+'/:'+collector.log_path|dirname+'/' }}"
- "/var/log/:/var/log/:ro"
{% if component_type == 'head' %}
- "/home/nrig-service/ControlFramework/fabric_cf/:/home/nrig-service/ControlFramework/fabric_cf/:ro"
{% endif %}
{% if filebeats_special is defined and 'logs' in filebeats_special.keys() %}
{% for log in filebeats_special.logs %}
- "{{log.path}}:{{log.path}}:ro"
{% endfor %}
{% else %}
- "/var/log/:/var/log/:ro"
- "/opt/data/zeek/logs:/opt/zeek/logs"
- "/opt/data/zeek/spool:/opt/zeek/spool"
- "/home/nrig-service/ControlFramework/fabric_cf/:/home/nrig-service/ControlFramework/fabric_cf/"
{% endif %}
{% if filebeats_nginx is defined %}
- "{{filebeats_nginx.path}}:{{filebeats_nginx.path}}:ro"
{% endif %}

secrets:
- source: filebeat.yml
target: /usr/share/filebeat/filebeat.yml
Expand Down
146 changes: 130 additions & 16 deletions instrumentize/elk/fabric-rack/roles/filebeat/templates/filebeat.yml.j2
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
---
filebeat.inputs:
{% if component_type != 'head' and component_type != 'worker' %}
{% for collector in logs_collection %}
{% if hostname in collector.hosts %}
{% if component_type == 'central-vm' or component_type == 'central-server' %}
{% if filebeats_special is defined and filebeats_special.logs is defined and filebeats_special.logs|length > 0 %}
{% for log in filebeats_special.logs %}
- type: filestream
enabled: true
id: {{ hostname }}
paths:
- {{ collector.log_path }}
{% endif %}
- "{{log.name}}"
tags: {{log.tags}}
{% endfor %}
{% endif %}
{% elif component_type == 'head' %}

- type: filestream
enabled: true
id: {{ hank_name }}-am
Expand All @@ -21,32 +24,45 @@ filebeat.inputs:
match: after
paths:
- /home/nrig-service/ControlFramework/fabric_cf/authority/{{ hank_name }}-am/logs/*.log
tags: ['am_logs']

- type: filestream
enabled: true
id: {{ hank_name }}-data-sw
paths:
- /var/log/remote/192.168.{{ hank_id }}.3/*.log
tags: ['data-sw_logs']

- type: filestream
enabled: true
id: {{ hank_name }}-mgt-sw
paths:
- /var/log/remote/192.168.{{ hank_id }}.2/*.log
tags: ['mgmt-sw_logs']

- type: filestream
enabled: true
id: {{ hank_name }}-vpn
paths:
- /var/log/remote/192.168.{{ hank_id }}.1/*.log
tags: ['srx_logs']

- type: filestream
enabled: true
id: {{ hank_name }}-storage
paths:
- /var/log/remote/192.168.{{ hank_id }}.110/*.log
- /var/log/remote/192.168.{{ hank_id }}.111/*.log
tags: ['storage_logs']

{% if hank_name == 'renc' %}
- type: filestream
enabled: true
id: nat64-gw
paths:
- /var/log/remote/192.168.{{ hank_id }}.4/*.log
tags: ['nat64_logs']
{% endif %}
{% endif %}
{% if component_type == 'head' or component_type == 'worker' %}

Expand All @@ -55,56 +71,95 @@ filebeat.inputs:
id: {{ hank_name }}-nova
paths:
- /var/log/nova/*.log
tags: ['openstack_logs']

- type: filestream
enabled: true
id: linuxptp
paths:
- /var/log/ptp4l.log
- /var/log/phc2sys.log
tags: ['ptp_logs']

- type: filestream
enabled: true
id: {{ hank_name }}-neutron
paths:
- /var/log/neutron/*.log
tags: ['openstack_logs']

- type: filestream
enabled: true
id: dnf
paths:
- /var/log/dnf*.log
tags: ['dnf_logs']

filebeat.modules:
- module: system
syslog:
enabled: {{ system_enable }}
enabled: {{ system_enable|string|lower }}
var.paths: ["/var/log/messages"]
var.convert_timezone: false
var.tags: ['messages_logs']
input:
processors:
- add_tags:
tags: ['messages_logs']

auth:
enabled: {{ system_enable }}
var.paths: ["/var/log/secure*"]
enabled: {{ system_enable|string|lower }}
var.paths: ["/var/log/secure"]
var.convert_timezone: false
var.tags: ['auth_logs']

{% endif %}
{% if component_type == 'central-vm' or component_type == 'central-server' %}
filebeat.modules:
- module: system
auth:
enabled: {{ system_enable|string|lower }}
var.paths: ["/var/log/secure"]
var.convert_timezone: false
var.tags: ['auth_logs']
{% if filebeats_nginx is defined %}
- module: nginx
access:
enabled: True
var.paths: ["{{filebeats_nginx.path}}{{filebeats_nginx.log_filename.access}}"]
error:
enabled: True
var.paths: ["{{filebeats_nginx.path}}{{filebeats_nginx.log_filename.error}}"]
{% endif %}
{% endif %}
{% if component_type == 'head' %}

- module: rabbitmq
log:
enabled: true
var.paths: ["/var/log/rabbitmq/rabbit@{{ hank_name }}-hn.log"]
input:
processors:
- add_tags:
tags: ['openstack_logs']


- module: apache
access:
enabled: true
var.paths:
- "/var/log/httpd/*access.log"
- "/var/log/httpd/access_log"
var.paths: ["/var/log/httpd/*access.log"]
input:
processors:
- add_tags:
tags: ['webserver_logs']

error:
enabled: true
var.paths:
- "/var/log/httpd/*error.log"
- "/var/log/httpd/error_log"
var.paths: ["/var/log/httpd/*error.log"]
input:
processors:
- add_tags:
tags: ['webserver_logs']

{% endif%}

Expand All @@ -120,13 +175,72 @@ output.logstash:
# -------------------------------- Kafka Output --------------------------------
output.kafka:
enabled: true
hosts: {{ hostvars[inventory_hostname]['mfkfk_hosts'] }}
hosts:
{% for mfkfk_host in hostvars[inventory_hostname]['mfkfk_hosts'] %}
- "{{mfkfk_host}}"
{% endfor %}
topic: "{{ hostvars[inventory_hostname]['mfkfk_topic_name'] }}"
topics:
- topic: "logs-auth"
when.contains:
tags: 'auth_logs'
- topic: "logs-dns"
when.contains:
tags: 'dns_logs'
- topic: "logs-vpn"
when.contains:
tags: 'vpn_logs'
- topic: "logs-mail-central"
when.contains:
tags: 'mail_central_logs'
- topic: "logs-ptp"
when.contains:
tags: 'ptp_logs'
- topic: "logs-data-sw"
when.contains:
tags: 'data-sw_logs'
- topic: "logs-mgmt-sw"
when.contains:
tags: 'mgmt-sw_logs'
- topic: "logs-storage"
when.contains:
tags: 'storage_logs'
- topic: "logs-srx"
when.contains:
tags: 'srx_logs'
- topic: "logs-nat64"
when.contains:
tags: 'nat64_logs'
- topic: "logs-webserver"
when.contains:
event.module: 'apache'
- topic: "logs-openstack"
when.contains:
tags: 'openstack_logs'
- topic: "logs-openstack"
when.contains:
event.module: 'rabbitmq'
- topic: "logs-messages"
when.contains:
event.dataset: 'system.syslog'
- topic: "logs-dnf"
when.contains:
tags: 'dnf_logs'
- topic: "logs-webssh"
when.contains:
tags: 'webssh_logs'
- topic: "logs-nginx"
when.contains:
event.module: 'nginx'

username: "{{ hostvars[inventory_hostname]['mfkfk_username'] }}"
password: "{{ hostvars[inventory_hostname]['mfkfk_password'] }}"
sasl.mechanism: SCRAM-SHA-256
ssl.verification_mode: certificate
ssl.certificate_authorities: {{ hostvars[inventory_hostname]['ssl']['certificate_authorities'] }}
ssl.certificate_authorities:
{% for ssl_cert_authority in hostvars[inventory_hostname]['ssl']['certificate_authorities'] %}
- "{{ssl_cert_authority}}"
{% endfor %}
{% endif%}

processors:
Expand Down
Loading