Skip to content

Commit

Permalink
First commit
Browse files Browse the repository at this point in the history
  • Loading branch information
iscs2021 committed Mar 28, 2021
1 parent b021821 commit 25dac1b
Show file tree
Hide file tree
Showing 16 changed files with 3,044 additions and 2 deletions.
491 changes: 491 additions & 0 deletions Ansible/ansible.cfg

Large diffs are not rendered by default.

Binary file added Ansible/files/.filebeat-playbook.yml.swp
Binary file not shown.
2,064 changes: 2,064 additions & 0 deletions Ansible/files/filebeat-config.yml

Large diffs are not rendered by default.

36 changes: 36 additions & 0 deletions Ansible/files/filebeat-playbook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
- name: Installing and Launch Filebeat
hosts: webservers
become: yes
tasks:
# Use command module
- name: Download filebeat .deb file
command: curl -L -O https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-7.4.0-amd64.deb

# Use command module
- name: Install filebeat .deb
command: dpkg -i filebeat-7.4.0-amd64.deb

# Use copy module
- name: Drop in filebeat.yml
copy:
src: /etc/ansible/files/filebeat-config.yml
dest: /etc/filebeat/filebeat.yml

# Use command module
- name: Enable and Configure System Module
command: filebeat modules enable system

# Use command module
- name: Setup filebeat
command: filebeat setup

# Use command module
- name: Start filebeat service
command: service filebeat start

# Use systemd module
- name: Enable service filebeat on boot
systemd:
name: filebeat
enabled: yes
163 changes: 163 additions & 0 deletions Ansible/files/metricbeat-config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
###################### Metricbeat Configuration Example #######################

# This file is an example configuration file highlighting only the most common
# options. The metricbeat.reference.yml file from the same directory contains all the
# supported options with more comments. You can use it as a reference.
#
# You can find the full configuration reference here:
# https://www.elastic.co/guide/en/beats/metricbeat/index.html

#========================== Modules configuration ============================

metricbeat.config.modules:
# Glob pattern for configuration loading
path: ${path.config}/modules.d/*.yml

# Set to true to enable config reloading
reload.enabled: false

# Period on which files under path should be checked for changes
#reload.period: 10s

#==================== Elasticsearch template setting ==========================

setup.template.settings:
index.number_of_shards: 1
index.codec: best_compression
#_source.enabled: false

#================================ General =====================================

# The name of the shipper that publishes the network data. It can be used to group
# all the transactions sent by a single shipper in the web interface.
#name:

# The tags of the shipper are included in their own field with each
# transaction published.
#tags: ["service-X", "web-tier"]

# Optional fields that you can specify to add additional information to the
# output.
#fields:
# env: staging


#============================== Dashboards =====================================
# These settings control loading the sample dashboards to the Kibana index. Loading
# the dashboards is disabled by default and can be enabled either by setting the
# options here or by using the `setup` command.
#setup.dashboards.enabled: false

# The URL from where to download the dashboards archive. By default this URL
# has a value which is computed based on the Beat name and version. For released
# versions, this URL points to the dashboard archive on the artifacts.elastic.co
# website.
#setup.dashboards.url:

#============================== Kibana =====================================

# Starting with Beats version 6.0.0, the dashboards are loaded via the Kibana API.
# This requires a Kibana endpoint configuration.
setup.kibana:
host: "10.1.0.4:5601"

# Kibana Host
# Scheme and port can be left out and will be set to the default (http and 5601)
# In case you specify and additional path, the scheme is required: http://localhost:5601/path
# IPv6 addresses should always be defined as: https://[2001:db8::1]:5601
#host: "localhost:5601"

# Kibana Space ID
# ID of the Kibana Space into which the dashboards should be loaded. By default,
# the Default Space will be used.
#space.id:

#============================= Elastic Cloud ==================================

# These settings simplify using Metricbeat with the Elastic Cloud (https://cloud.elastic.co/).

# The cloud.id setting overwrites the `output.elasticsearch.hosts` and
# `setup.kibana.host` options.
# You can find the `cloud.id` in the Elastic Cloud web UI.
#cloud.id:

# The cloud.auth setting overwrites the `output.elasticsearch.username` and
# `output.elasticsearch.password` settings. The format is `<user>:<pass>`.
#cloud.auth:

#================================ Outputs =====================================

# Configure what output to use when sending the data collected by the beat.

#-------------------------- Elasticsearch output ------------------------------
output.elasticsearch:
# Array of hosts to connect to.
hosts: ["10.1.0.4:9200"]
username: "elastic"
password: "changeme"

# Optional protocol and basic auth credentials.
#protocol: "https"
#username: "elastic"
#password: "changeme"

#----------------------------- Logstash output --------------------------------
#output.logstash:
# The Logstash hosts
#hosts: ["localhost:5044"]

# Optional SSL. By default is off.
# List of root certificates for HTTPS server verifications
#ssl.certificate_authorities: ["/etc/pki/root/ca.pem"]

# Certificate for SSL client authentication
#ssl.certificate: "/etc/pki/client/cert.pem"

# Client Certificate Key
#ssl.key: "/etc/pki/client/cert.key"

#================================ Processors =====================================

# Configure processors to enhance or manipulate events generated by the beat.

processors:
- add_host_metadata: ~
- add_cloud_metadata: ~

#================================ Logging =====================================

# Sets log level. The default log level is info.
# Available log levels are: error, warning, info, debug
#logging.level: debug

# At debug level, you can selectively enable logging only for some components.
# To enable all selectors use ["*"]. Examples of other selectors are "beat",
# "publish", "service".
#logging.selectors: ["*"]

#============================== X-Pack Monitoring ===============================
# metricbeat can export internal metrics to a central Elasticsearch monitoring
# cluster. This requires xpack monitoring to be enabled in Elasticsearch. The
# reporting is disabled by default.

# Set to true to enable the monitoring reporter.
#monitoring.enabled: false

# Sets the UUID of the Elasticsearch cluster under which monitoring data for this
# Metricbeat instance will appear in the Stack Monitoring UI. If output.elasticsearch
# is enabled, the UUID is derived from the Elasticsearch cluster referenced by output.elasticsearch.
#monitoring.cluster_uuid:

# Uncomment to send the metrics to Elasticsearch. Most settings from the
# Elasticsearch output are accepted here as well.
# Note that the settings should point to your Elasticsearch *monitoring* cluster.
# Any setting that is not set is automatically inherited from the Elasticsearch
# output configuration, so if you have the Elasticsearch output configured such
# that it is pointing to your Elasticsearch monitoring cluster, you can simply
# uncomment the following line.
#monitoring.elasticsearch:

#================================= Migration ==================================

# This allows to enable 6.7 migration aliases
#migration.6_to_7.enabled: true
36 changes: 36 additions & 0 deletions Ansible/files/metricbeat-playbook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
- name: Install metric beat
hosts: webservers
become: true
tasks:
# Use command module
- name: Download metricbeat
command: curl -L -O https://artifacts.elastic.co/downloads/beats/metricbeat/metricbeat-7.4.0-amd64.deb

# Use command module
- name: install metricbeat
command: dpkg -i metricbeat-7.4.0-amd64.deb

# Use copy module
- name: drop in metricbeat config
copy:
src: /etc/ansible/files/metricbeat-config.yml
dest: /etc/metricbeat/metricbeat.yml

# Use command module
- name: enable and configure docker module for metric beat
command: metricbeat modules enable docker

# Use command module
- name: setup metric beat
command: metricbeat setup

# Use command module
- name: start metric beat
command: service metricbeat start

# Use systemd module
- name: Enable service metricbeat on boot
systemd:
name: metricbeat
enabled: yes
50 changes: 50 additions & 0 deletions Ansible/hosts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# This is the default ansible 'hosts' file.
#
# It should live in /etc/ansible/hosts
#
# - Comments begin with the '#' character
# - Blank lines are ignored
# - Groups of hosts are delimited by [header] elements
# - You can enter hostnames or ip addresses
# - A hostname/ip can be a member of multiple groups

# Ex 1: Ungrouped hosts, specify before any group headers.

## green.example.com
## blue.example.com
## 192.168.100.1
## 192.168.100.10

# Ex 2: A collection of hosts belonging to the 'webservers' group

[webservers]
## alpha.example.org
## beta.example.org
## 192.168.1.100
## 192.168.1.110
10.0.0.5 ansible_python_interpreter=/usr/bin/python3
10.0.0.6 ansible_python_interpreter=/usr/bin/python3
10.0.0.7 ansible_python_interpreter=/usr/bin/python3

[elk]
10.1.0.4 ansible_python_interpreter=/usr/bin/python3

# If you have multiple hosts following a pattern you can specify
# them like this:

## www[001:006].example.com

# Ex 3: A collection of database servers in the 'dbservers' group

## [dbservers]
##
## db01.intranet.mydomain.net
## db02.intranet.mydomain.net
## 10.25.1.56
## 10.25.1.57

# Here's another example of host ranges, this time there are no
# leading 0s:

## db-[99:101]-node.example.com

40 changes: 40 additions & 0 deletions Ansible/roles/configvm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---

- name: Config Web VM with Docker
hosts: webservers
become: true
tasks:

- name: Uninstall apache2
apt:
name: apache2
state: absent

- name: docker.io
apt:
update_cache: yes
name: docker.io
state: present

- name: Install pip3
apt:
name: python3-pip
state: present

- name: Install Python Docker Module
pip:
name: docker
state: present

- name: Enable docker service
systemd:
name: docker
enabled: yes

- name: Download and launch a docker web container
docker_container:
name: dvwa
image: cyberxsecurity/dvwa
state: started
restart_policy: always
published_ports: 80:80
50 changes: 50 additions & 0 deletions Ansible/roles/install-elk.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---

- name: Config ELK VM with Docker
hosts: elk
remote_user: azadmin
become: true
tasks:


- name: Install docker.io
apt:
update_cache: yes
force_apt_get: yes
name: docker.io
state: present

- name: Install python3-pip3
apt:
force_apt_get: yes
name: python3-pip
state: present

- name: Install Docker Module
pip:
name: docker
state: present

- name: Enable docker service
systemd:
name: docker
enabled: yes

- name: config system control module Use more memory
sysctl:
name: vm.max_map_count
value: "262144"
state: present
reload: yes

- name: Download and launch a docker elk container
docker_container:
name: elk
image: sebp/elk:761
state: started
restart_policy: always
published_ports:
- 5601:5601
- 9200:9200
- 5044:5044

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/activity-13-1-docker-ps-sebp-elk.JPG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions Images/screenshot filenames.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
activity-13-1-dashboard-after-installing-kibana.JPG
activity-13-1-docker-ps-sebp-elk.JPG
activity-13-2-filebeat-install-success.JPG
activity-13-2-metricbeat-install-success.JPG
Cloud-VirtualNetwork-Web-Testing-Diagram.png
Loading

0 comments on commit 25dac1b

Please sign in to comment.