Skip to content
Open

Main #15

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
c2b556f
Использовать Zabbix для мониторинга
bulatzamilov Jul 5, 2023
053777c
Update README.md
ElenaPalagina Sep 14, 2023
f99a808
Update README.md
ElenaPalagina Oct 5, 2023
0f14e66
Update README.md
ElenaPalagina Oct 5, 2023
afd3ac5
Update README.md
ElenaPalagina Oct 5, 2023
28e46a5
Update README.md
udjin10 Oct 6, 2023
a7a8493
Update README.md
udjin10 Oct 6, 2023
1709692
Merge pull request #7 from netology-code/diplom-zabbix-updaterules
udjin10 Oct 6, 2023
4a3954c
Update README.md
udjin10 Oct 18, 2023
afc8015
Update README.md
udjin10 Oct 26, 2023
fda29dd
Update README.md
udjin10 Nov 25, 2023
1e7473e
Update README.md
udjin10 May 21, 2024
488c073
Update README.md
udjin10 Jun 11, 2024
ed86844
Update README.md
udjin10 Aug 8, 2024
494ab3d
ready1
stimul25 Oct 5, 2025
fa1c19b
ready1
stimul25 Oct 5, 2025
6dba2c6
ready1
stimul25 Oct 5, 2025
c09feab
ready1
stimul25 Oct 5, 2025
42e83e2
ready1
stimul25 Oct 5, 2025
ed719d9
1 changes
stimul25 Oct 12, 2025
1030cf6
2 changes
stimul25 Oct 12, 2025
5943c32
2 changes
stimul25 Oct 12, 2025
a93eaf5
2 changes
stimul25 Oct 12, 2025
95ac253
2 changes
stimul25 Oct 12, 2025
7fd7042
3 changes
stimul25 Oct 12, 2025
b7ec7f0
3 changes
stimul25 Oct 12, 2025
cdbac7c
3 changes
stimul25 Oct 12, 2025
a5b983e
4 changes
stimul25 Oct 12, 2025
9864edf
4 changes
stimul25 Oct 12, 2025
0926896
4 changes
stimul25 Oct 12, 2025
c7c9176
5 changes
stimul25 Oct 13, 2025
02af8b6
5 changes
stimul25 Oct 13, 2025
697163b
6 changes
stimul25 Oct 13, 2025
8c291ab
7 changes
stimul25 Oct 13, 2025
18ed5ae
7 changes
stimul25 Oct 13, 2025
0f3cf13
7 changes
stimul25 Oct 13, 2025
718c3af
8 changes
stimul25 Oct 13, 2025
93fcc07
8 changes
stimul25 Oct 13, 2025
3e28990
8 changes
stimul25 Oct 13, 2025
d602829
9 changes
stimul25 Oct 13, 2025
91abcc0
9 changes
stimul25 Oct 13, 2025
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
314 changes: 297 additions & 17 deletions README.md

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions ansible/ansible.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[defaults]
inventory = /home/diploma1/.ansible/hosts
host_key_checking = false
remote_user = diploma1
private_key_file = ~/.ssh/id_ed25519
pipelining = True

[privilege_escalation]
become = True
101 changes: 101 additions & 0 deletions ansible/elastic-conf.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
# ======================== Elasticsearch Configuration =========================
#
# NOTE: Elasticsearch comes with reasonable defaults for most settings.
# Before you set out to tweak and tune the configuration, make sure you
# understand what are you trying to accomplish and the consequences.
#
# The primary way of configuring a node is via this file. This template lists
# the most important settings you may want to configure for a production cluster.
#
# Please consult the documentation for further information on configuration options:
# https://www.elastic.co/guide/en/elasticsearch/reference/index.html
#
# ---------------------------------- Cluster -----------------------------------
#
# Use a descriptive name for your cluster:
#
cluster.name: diploma1
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
node.name: node-1
#
# Add custom attributes to the node:
#
#node.attr.rack: r1
#
# ----------------------------------- Paths ------------------------------------
#
# Path to directory where to store the data (separate multiple locations by comma):
#
path.data: /var/lib/elasticsearch
#
# Path to log files:
#
path.logs: /var/log/elasticsearch
#
# ----------------------------------- Memory -----------------------------------
#
# Lock the memory on startup:
#
#bootstrap.memory_lock: true
#
# Make sure that the heap size is set to about half the memory available
# on the system and that the owner of the process is allowed to use this
# limit.
#
# Elasticsearch performs poorly when the system is swapping the memory.
#
# ---------------------------------- Network -----------------------------------
#
# By default Elasticsearch is only accessible on localhost. Set a different
# address here to expose this node on the network:
#
#network.host: 0.0.0.0
#
# By default Elasticsearch listens for HTTP traffic on the first free port it
# finds starting at 9200. Set a specific HTTP port here:
#
#http.port: 9200
#
# For more information, consult the network module documentation.
#
# --------------------------------- Discovery ----------------------------------
#
# Pass an initial list of hosts to perform discovery when this node is started:
# The default list of hosts is ["127.0.0.1", "[::1]"]
#
discovery.seed_hosts: ["127.0.0.1", "[::1]"]
#
# Bootstrap the cluster using an initial set of master-eligible nodes:
#
#cluster.initial_master_nodes: ["node-1", "node-2"]
#
# For more information, consult the discovery and cluster formation module documentation.
#
# ---------------------------------- Various -----------------------------------
#
# Require explicit names when deleting indices:
#
#action.destructive_requires_name: true
#
# ---------------------------------- Security ----------------------------------
#
# *** WARNING ***
#
# Elasticsearch security features are not enabled by default.
# These features are free, but require configuration changes to enable them.
# This means that users don’t have to provide credentials and can get full access
# to the cluster. Network connections are also not encrypted.
#
# To protect your data, we strongly encourage you to enable the Elasticsearch security features.
# Refer to the following documentation for instructions.
#
# https://www.elastic.co/guide/en/elasticsearch/reference/7.16/configuring-stack-security.html
network.host: 127.0.0.1
http.host: 0.0.0.0
http.port: 9200
discovery.type: single-node

25 changes: 25 additions & 0 deletions ansible/elastic-play.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
- name: 1 install Elastic
hosts: elasticsearch
become: yes
gather_facts: true

tasks:
- name: Установка elasticsearch
apt:
deb: "https://mirror.yandex.ru/mirrors/elastic/7/pool/main/e/elasticsearch/elasticsearch-7.17.1-amd64.deb"

- name: 2 copy elasticsearch
copy:
src: /home/diploma1/.ansible/elastic-conf.yaml
dest: /etc/elasticsearch/elasticsearch.yml

- name: daemon_reload
systemd:
daemon_reload: true

- name: 3 Перезапуск elasticsearch и добавляем в автозагрузку
service:
name: elasticsearch
state: restarted
enabled: yes
27 changes: 27 additions & 0 deletions ansible/filebeat-play.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
- name: 1 installFilebeat
hosts: nginx-web
become: yes
gather_facts: true
vars:
kibana_host: 192.168.40.30:5601
elastic_host: 192.168.10.30:9200
tasks:
- name: 2 Устанавливаем filebeat
apt:
deb: "https://mirror.yandex.ru/mirrors/elastic/7/pool/main/f/filebeat/filebeat-7.17.1-amd64.deb"

- name: 3 copy file filebeat
template:
src: /home/diploma1/.ansible/filebeat.j2
dest: /etc/filebeat/filebeat.yml

- name: daemon_reload
systemd:
daemon_reload: true

- name: 4 Перезапускаем filebeat и добавляем в автозагрузку
service:
name: filebeat
state: restarted
enabled: yes
30 changes: 30 additions & 0 deletions ansible/filebeat.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#=========================== Filebeat inputs =============================

filebeat.inputs:
- type: log
enabled: true
paths:
- /var/log/nginx/access.log
- /var/log/nginx/error.log

#============================= Filebeat modules ===============================

filebeat.config.modules:
path: ${path.config}/modules.d/*.yml
reload.enabled: false

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

setup.template.settings:
index.number_of_shards: 1

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

setup.kibana:
host: "{{kibana_host}}"

#-------------------------- Elasticsearch output ------------------------------

output.elasticsearch:
hosts: ["{{elastic_host}}"]

24 changes: 24 additions & 0 deletions ansible/hosts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[nginx-web]
nginx-1 ansible_ssh_user=diploma1 ansible_sudo_pass=***
nginx-2 ansible_ssh_user=diploma1 ansible_sudo_pass=***

[zabbix]
zabbix ansible_ssh_user=diploma1 ansible_sudo_pass=***

[elasticsearch]
elasticsearch

[kibana]
kibana

[nginx-web:vars]
ansible_ssh_common_args='-o ProxyCommand="ssh -W %h:%p -q diploma1@46.21.244.219"'

[zabbix:vars]
ansible_ssh_common_args='-o ProxyCommand="ssh -W %h:%p -q diploma1@46.21.244.219"'

[elasticsearch:vars]
ansible_ssh_common_args='-o ProxyCommand="ssh -W %h:%p -q diploma1@46.21.244.219"'

[kibana:vars]
ansible_ssh_common_args='-o ProxyCommand="ssh -W %h:%p -q diploma1@46.21.244.219"'
26 changes: 26 additions & 0 deletions ansible/kibana-play.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
- name: 1 install Kibana
hosts: kibana
become: yes
vars:
elastic_httphost: 192.168.10.30:9200
tasks:

- name: 2 Установка пакета kibana
apt:
deb: "https://mirror.yandex.ru/mirrors/elastic/7/pool/main/k/kibana/kibana-7.17.1-amd64.deb"

- name: 3 copy file kibana
template:
src: /home/diploma1/.ansible/kibana.j2
dest: /etc/kibana/kibana.yml

- name: daemon_reload
systemd:
daemon_reload: true

- name: 4 Перезапускаем kibana и добавляем в автозагрузку
service:
name: kibana
state: restarted
enabled: yes
3 changes: 3 additions & 0 deletions ansible/kibana.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
server.port: 5601
server.host: "0.0.0.0"
elasticsearch.hosts: ["http://{{elastic_httphost}}"]
50 changes: 50 additions & 0 deletions ansible/nginx-playbook.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
- name: test
hosts: nginx-web
become: yes

tasks:
- name: update пакетов
apt:
force_apt_get: true
upgrade: dist
update_cache: yes
become: true

- name: install nginx
apt:
name: nginx
state: latest
update_cache: yes

- name: copy ngx1.html на первый сервер
hosts: nginx-1
become: yes

tasks:
- name: copy index_new.html
ansible.builtin.copy:
src: /home/diploma1/.ansible/ngx1.html
dest: /var/www/html/index.html
owner: root
group: sudo
mode: "0644"

- name: copy ngx2.html на второй сервер
hosts: nginx-2
become: yes

tasks:
- name: copy index_new.html
ansible.builtin.copy:
src: /home/diploma1/.ansible/ngx2.html
dest: /var/www/html/index.html
owner: root
group: sudo
mode: "0644"

handlers:
- name: reload nginx
systemd:
name: nginx
state: reloaded
18 changes: 18 additions & 0 deletions ansible/ngx1.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="utf-8" />
<title>Dyplom project System administration</title>
<style>
body {
width: 45em;
margin: 0 auto;
}
</style>
</head>
<body>
<h1>Добро пожаловать на nginx-1</h1>
<h2><font color="#ff0000"></font>Tarkov Viktor</font></h2>
<h2>SYS-43<h2>
</body>
</html>
24 changes: 24 additions & 0 deletions ansible/ngx2.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="utf-8" />
<title>Welcome to nginx!</title>
<style>
body {
width: 35em;
margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif;
background-color: #a4acd3;
}
</style>
</head>
<body>
<h1>Page generated by </h1>
<h2><i><font color="#ff0000"></font> SYS-43 <br>TARKOV VIKTOR</a><br></font></i></h2>
<p>Hello, world!.</p>
<br>

<p><em>-------------------------------------------------------------</em></p>
<p><b><center>nginx-2</center></b></p>
</body>
</html>
37 changes: 37 additions & 0 deletions ansible/zabbix-agent-playbook.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---

- name: install zabbix-agent
hosts: all
become: true

tasks:
- name: apt update
apt:
upgrade: yes
update_cache: yes

- name: download zabbix-agent
get_url:
url: https://repo.zabbix.com/zabbix/7.4/release/ubuntu/pool/main/z/zabbix-release/zabbix-release_latest_7.4+ubuntu24.04_all.deb
dest: /tmp/zabbix-release_latest_7.4+ubuntu24.04_all.deb

- name: dpkg -i zabbix-agent
apt:
deb: /tmp/zabbix-release_latest_7.4+ubuntu24.04_all.deb

- name: apt update
apt:
update_cache: yes

- name: apt install zabbix-agent
apt:
name: zabbix-agent

- name: ip replacement in zabbix_agentd.conf
shell: |
sed -i 's/Server=127.0.0.1/Server=192.168.40.20/g' /etc/zabbix/zabbix_agentd.conf

- name: restart and enable zabbix-agent
shell: |
systemctl restart zabbix-agent
systemctl enable zabbix-agent
Loading