From af66a54571f4df20217ab830b8bc3aa2ea03d65e Mon Sep 17 00:00:00 2001 From: Maybe-R Date: Tue, 17 Jun 2025 12:42:45 +0300 Subject: [PATCH 01/18] Dockerfile --- Dockerfile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index d68b868d6..c4dd4eacf 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,5 +2,9 @@ FROM python:3.12-slim # Ваш код здесь # +WORKDIR /app +COPY requirements.txt ./ +RUN pip install -r requirements.txt +COPY main.py ./ # Запускаем приложение с помощью uvicorn, делая его доступным по сети -CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "5000"] \ No newline at end of file +CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "5000"] From be20064a8b62da0b33da56cbc3e27bd7a8067fff Mon Sep 17 00:00:00 2001 From: Maybe-R Date: Wed, 25 Jun 2025 14:44:07 +0300 Subject: [PATCH 02/18] Create compose.yaml --- compose.yaml | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 compose.yaml diff --git a/compose.yaml b/compose.yaml new file mode 100644 index 000000000..066eec4c8 --- /dev/null +++ b/compose.yaml @@ -0,0 +1,37 @@ +version: '3.7' +include: + - proxy.yaml + +volumes: + db_mysql: + +services: + + db: + image: mysql:8 + restart: on-failure + env_file: + - .env + volumes: + - /var/lib/docker/volumes/db_mysql/_data:/var/lib/mysql + ports: + - 3306:3306 + networks: + backend: + ipv4_address: 172.20.0.10 + + web: + build: + dockerfile: Dockerfile.python + restart: on-failure + environment: +- MYSQL_ROOT_PASSWORD: YtReWq4321 +- MYSQL_DATABASE: virtd +- MYSQL_USER: app +- MYSQL_PASSWORD: QwErTy1234" + + depends_on: + - db + networks: + backend: + ipv4_address: 172.20.0.5 From dbb161b0f1c5851db1d9b3663602f9ae80ba636f Mon Sep 17 00:00:00 2001 From: Maybe-R Date: Wed, 25 Jun 2025 17:23:51 +0300 Subject: [PATCH 03/18] Update compose.yaml --- compose.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compose.yaml b/compose.yaml index 066eec4c8..fe2c56752 100644 --- a/compose.yaml +++ b/compose.yaml @@ -22,7 +22,7 @@ services: web: build: - dockerfile: Dockerfile.python + dockerfile: Dockerfile restart: on-failure environment: - MYSQL_ROOT_PASSWORD: YtReWq4321 From d8c7b2f86163077a2b1752b337af7ad4fd4ae77b Mon Sep 17 00:00:00 2001 From: Maybe-R Date: Tue, 8 Jul 2025 15:49:33 +0300 Subject: [PATCH 04/18] Create .gitignore --- scr/.gitignore | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 scr/.gitignore diff --git a/scr/.gitignore b/scr/.gitignore new file mode 100644 index 000000000..bbf86604b --- /dev/null +++ b/scr/.gitignore @@ -0,0 +1,12 @@ +# Local .terraform directories and files +**/.terraform/* +.terraform* + +!.terraformrc + +# .tfstate files +*.tfstate +*.tfstate.* + +# own secret vars store. +personal.auto.tfvars From b5d5d16f82b77caeea51a8669f85c1ff0c3c5b2e Mon Sep 17 00:00:00 2001 From: Maybe-R Date: Tue, 8 Jul 2025 15:50:50 +0300 Subject: [PATCH 05/18] Create .terraformrc --- scr/.terraformrc | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 scr/.terraformrc diff --git a/scr/.terraformrc b/scr/.terraformrc new file mode 100644 index 000000000..17415e3e0 --- /dev/null +++ b/scr/.terraformrc @@ -0,0 +1,9 @@ +provider_installation { + network_mirror { + url = "https://terraform-mirror.yandexcloud.net/" + include = ["registry.terraform.io/*/*"] + } + direct { + exclude = ["registry.terraform.io/*/*"] + } +} From 4a23db90e190a484084445a452ca09478eb8f8e5 Mon Sep 17 00:00:00 2001 From: Maybe-R Date: Tue, 8 Jul 2025 15:57:21 +0300 Subject: [PATCH 06/18] Create console.tf --- scr/console.tf | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 scr/console.tf diff --git a/scr/console.tf b/scr/console.tf new file mode 100644 index 000000000..e5b888ed4 --- /dev/null +++ b/scr/console.tf @@ -0,0 +1,31 @@ +##Этот файл для 7 задания!! +locals { + + test_list = ["develop", "staging", "production"] + + test_map = { + admin = "John" + user = "Alex" + } + + servers = { + develop = { + cpu = 2 + ram = 4 + image = "ubuntu-21-10" + disks = ["vda", "vdb"] + }, + stage = { + cpu = 4 + ram = 8 + image = "ubuntu-20-04" + disks = ["vda", "vdb"] + }, + production = { + cpu = 10 + ram = 40 + image = "ubuntu-20-04" + disks = ["vda", "vdb", "vdc", "vdd"] + } + } +} From 3ca45788fb0f2aaf05e7eddaed9b337369ddcb69 Mon Sep 17 00:00:00 2001 From: Maybe-R Date: Tue, 8 Jul 2025 15:57:53 +0300 Subject: [PATCH 07/18] Create locals.tf --- scr/locals.tf | 1 + 1 file changed, 1 insertion(+) create mode 100644 scr/locals.tf diff --git a/scr/locals.tf b/scr/locals.tf new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/scr/locals.tf @@ -0,0 +1 @@ + From b4096b978e1d35043ae683c0571292df4264f5bb Mon Sep 17 00:00:00 2001 From: Maybe-R Date: Tue, 8 Jul 2025 15:59:05 +0300 Subject: [PATCH 08/18] Create main.tf --- scr/main.tf | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 scr/main.tf diff --git a/scr/main.tf b/scr/main.tf new file mode 100644 index 000000000..49baf600a --- /dev/null +++ b/scr/main.tf @@ -0,0 +1,41 @@ +resource "yandex_vpc_network" "develop" { + name = var.vpc_name +} +resource "yandex_vpc_subnet" "develop" { + name = var.vpc_name + zone = var.default_zone + network_id = yandex_vpc_network.develop.id + v4_cidr_blocks = var.default_cidr +} + + +data "yandex_compute_image" "ubuntu" { + family = "ubuntu-2004-lts" +} +resource "yandex_compute_instance" "platform" { + name = "netology-develop-platform-web" + platform_id = "standart-v4" + resources { + cores = 1 + memory = 1 + core_fraction = 5 + } + boot_disk { + initialize_params { + image_id = data.yandex_compute_image.ubuntu.image_id + } + } + scheduling_policy { + preemptible = true + } + network_interface { + subnet_id = yandex_vpc_subnet.develop.id + nat = true + } + + metadata = { + serial-port-enable = 1 + ssh-keys = "ubuntu:${var.vms_ssh_root_key}" + } + +} From d5d8992162a427766e17dae2826e2be64c73f562 Mon Sep 17 00:00:00 2001 From: Maybe-R Date: Tue, 8 Jul 2025 16:00:15 +0300 Subject: [PATCH 09/18] Create providers.tf --- scr/providers.tf | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 scr/providers.tf diff --git a/scr/providers.tf b/scr/providers.tf new file mode 100644 index 000000000..fae4dc372 --- /dev/null +++ b/scr/providers.tf @@ -0,0 +1,16 @@ +terraform { + required_providers { + yandex = { + source = "yandex-cloud/yandex" + } + } + required_version = ">=1.5" +} + +provider "yandex" { + # token = var.token + cloud_id = var.cloud_id + folder_id = var.folder_id + zone = var.default_zone + service_account_key_file = file("~/.authorized_key.json") +} From 25be9416f26865eed341be597506022dd0f2b870 Mon Sep 17 00:00:00 2001 From: Maybe-R Date: Tue, 8 Jul 2025 16:00:44 +0300 Subject: [PATCH 10/18] Create variables.tf --- scr/variables.tf | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 scr/variables.tf diff --git a/scr/variables.tf b/scr/variables.tf new file mode 100644 index 000000000..8e1bb4f1e --- /dev/null +++ b/scr/variables.tf @@ -0,0 +1,38 @@ +###cloud vars + + +variable "cloud_id" { + type = string + description = "https://cloud.yandex.ru/docs/resource-manager/operations/cloud/get-id" +} + +variable "folder_id" { + type = string + description = "https://cloud.yandex.ru/docs/resource-manager/operations/folder/get-id" +} + +variable "default_zone" { + type = string + default = "ru-central1-a" + description = "https://cloud.yandex.ru/docs/overview/concepts/geo-scope" +} +variable "default_cidr" { + type = list(string) + default = ["10.0.1.0/24"] + description = "https://cloud.yandex.ru/docs/vpc/operations/subnet-create" +} + +variable "vpc_name" { + type = string + default = "develop" + description = "VPC network & subnet name" +} + + +###ssh vars + +variable "vms_ssh_root_key" { + type = string + default = "" + description = "ssh-keygen -t ed25519" +} From 74860b1bbf47ea20e816f50a29a8a796de9b3593 Mon Sep 17 00:00:00 2001 From: Maybe-R Date: Tue, 8 Jul 2025 16:09:09 +0300 Subject: [PATCH 11/18] Update providers.tf --- scr/providers.tf | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scr/providers.tf b/scr/providers.tf index fae4dc372..efd2715f0 100644 --- a/scr/providers.tf +++ b/scr/providers.tf @@ -9,8 +9,8 @@ terraform { provider "yandex" { # token = var.token - cloud_id = var.cloud_id - folder_id = var.folder_id - zone = var.default_zone + cloud_id = "b1gk34aj8huam4c6qc65" + folder_id = "b1groq7lioh1rbih3b87" + zone = ru-central1-a service_account_key_file = file("~/.authorized_key.json") } From 3753cdd1cc8849bb9c1f3e78d4a2c6c7d87b81dd Mon Sep 17 00:00:00 2001 From: Maybe-R Date: Tue, 8 Jul 2025 16:09:34 +0300 Subject: [PATCH 12/18] Update providers.tf --- scr/providers.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scr/providers.tf b/scr/providers.tf index efd2715f0..c287aa1a6 100644 --- a/scr/providers.tf +++ b/scr/providers.tf @@ -11,6 +11,6 @@ provider "yandex" { # token = var.token cloud_id = "b1gk34aj8huam4c6qc65" folder_id = "b1groq7lioh1rbih3b87" - zone = ru-central1-a + zone = "ru-central1-a" service_account_key_file = file("~/.authorized_key.json") } From 57d11eb04a7edb65f3d8bfe8d5a22223fe5beedc Mon Sep 17 00:00:00 2001 From: Maybe-R Date: Tue, 8 Jul 2025 16:25:05 +0300 Subject: [PATCH 13/18] Update variables.tf --- scr/variables.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scr/variables.tf b/scr/variables.tf index 8e1bb4f1e..36ca23421 100644 --- a/scr/variables.tf +++ b/scr/variables.tf @@ -33,6 +33,6 @@ variable "vpc_name" { variable "vms_ssh_root_key" { type = string - default = "" + default = "ssh-ed25519ssh-ed25519 roRitedX9AABWbmxLpX8vBtRrMXpyTY8r2RKCc/AIjg flid@devopsserver" description = "ssh-keygen -t ed25519" } From bae310e7f90b8f3348c4b2118e1f02ac5f22a04a Mon Sep 17 00:00:00 2001 From: Maybe-R Date: Wed, 29 Oct 2025 11:21:01 +0300 Subject: [PATCH 14/18] Add files via upload --- vector-role-main/README.md | 47 ++++++++++++++++++ vector-role-main/defaults/main.yml | 2 + vector-role-main/handlers/main.yml | 8 +++ vector-role-main/meta/main.yml | 52 ++++++++++++++++++++ vector-role-main/tasks/main.yml | 18 +++++++ vector-role-main/templates/vector.service.j2 | 10 ++++ vector-role-main/templates/vector.yml.j2 | 45 +++++++++++++++++ vector-role-main/tests/inventory | 2 + vector-role-main/tests/test.yml | 5 ++ vector-role-main/vars/main.yml | 22 +++++++++ 10 files changed, 211 insertions(+) create mode 100644 vector-role-main/README.md create mode 100644 vector-role-main/defaults/main.yml create mode 100644 vector-role-main/handlers/main.yml create mode 100644 vector-role-main/meta/main.yml create mode 100644 vector-role-main/tasks/main.yml create mode 100644 vector-role-main/templates/vector.service.j2 create mode 100644 vector-role-main/templates/vector.yml.j2 create mode 100644 vector-role-main/tests/inventory create mode 100644 vector-role-main/tests/test.yml create mode 100644 vector-role-main/vars/main.yml diff --git a/vector-role-main/README.md b/vector-role-main/README.md new file mode 100644 index 000000000..8c31cab0c --- /dev/null +++ b/vector-role-main/README.md @@ -0,0 +1,47 @@ +Role Name +========= + +Deploy Vector to selected hosts. + +Requirements +------------ + +Ansible >= 2.9.9 version installed. + +Role Variables +-------------- + + +| Name | Default Value | Description | +|-------------------|---------------------------------------------------------------------|--------------------------------| +| vector_url | https://packages.timber.io/vector/0.33.1/vector-0.33.1-1.x86_64.rpm | Download source | +| vector_config_dir | /etc/vector | Install path | +| data_dir | /var/lib/vector | Vector data directory | +| sources | | For Vector configuration | +| sinks | | Connect to clickhouse settings | + +Dependencies +------------ + +No dependencies + +Example Playbook +---------------- + +Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too: + + - name: Install Vector + hosts: vector + roles: + - vector-role + tags: vector + +License +------- + +Free + +Author Information +------------------ + +Fedorchuk Dmitriy diff --git a/vector-role-main/defaults/main.yml b/vector-role-main/defaults/main.yml new file mode 100644 index 000000000..78ae8528b --- /dev/null +++ b/vector-role-main/defaults/main.yml @@ -0,0 +1,2 @@ +--- +# defaults file for vector-role diff --git a/vector-role-main/handlers/main.yml b/vector-role-main/handlers/main.yml new file mode 100644 index 000000000..b4121fd13 --- /dev/null +++ b/vector-role-main/handlers/main.yml @@ -0,0 +1,8 @@ +--- +- name: vector_start + become: true + become_method: sudo + ansible.builtin.systemd: + name: vector + state: started + daemon_reload: true \ No newline at end of file diff --git a/vector-role-main/meta/main.yml b/vector-role-main/meta/main.yml new file mode 100644 index 000000000..c572acc9f --- /dev/null +++ b/vector-role-main/meta/main.yml @@ -0,0 +1,52 @@ +galaxy_info: + author: your name + description: your role description + company: your company (optional) + + # If the issue tracker for your role is not on github, uncomment the + # next line and provide a value + # issue_tracker_url: http://example.com/issue/tracker + + # Choose a valid license ID from https://spdx.org - some suggested licenses: + # - BSD-3-Clause (default) + # - MIT + # - GPL-2.0-or-later + # - GPL-3.0-only + # - Apache-2.0 + # - CC-BY-4.0 + license: license (GPL-2.0-or-later, MIT, etc) + + min_ansible_version: 2.1 + + # If this a Container Enabled role, provide the minimum Ansible Container version. + # min_ansible_container_version: + + # + # Provide a list of supported platforms, and for each platform a list of versions. + # If you don't wish to enumerate all versions for a particular platform, use 'all'. + # To view available platforms and versions (or releases), visit: + # https://galaxy.ansible.com/api/v1/platforms/ + # + # platforms: + # - name: Fedora + # versions: + # - all + # - 25 + # - name: SomePlatform + # versions: + # - all + # - 1.0 + # - 7 + # - 99.99 + + galaxy_tags: [] + # List tags for your role here, one per line. A tag is a keyword that describes + # and categorizes the role. Users find roles by searching for tags. Be sure to + # remove the '[]' above, if you add tags to this list. + # + # NOTE: A tag is limited to a single word comprised of alphanumeric characters. + # Maximum 20 tags per role. + +dependencies: [] + # List your role dependencies here, one per line. Be sure to remove the '[]' above, + # if you add dependencies to this list. diff --git a/vector-role-main/tasks/main.yml b/vector-role-main/tasks/main.yml new file mode 100644 index 000000000..dba4f5111 --- /dev/null +++ b/vector-role-main/tasks/main.yml @@ -0,0 +1,18 @@ +--- +- name: Vector | Install RPM + become: true + ansible.builtin.yum: + name: "{{ vector_url }}" + state: present +- name: Vector | Template file + ansible.builtin.template: + src: vector.yml.j2 + dest: vector.yml + mode: '0644' +- name: Vector | Create Vector service + become: true + ansible.builtin.template: + src: vector.service.j2 + dest: /etc/systemd/system/vector.service + mode: '0644' + notify: vector_start diff --git a/vector-role-main/templates/vector.service.j2 b/vector-role-main/templates/vector.service.j2 new file mode 100644 index 000000000..9d54be7db --- /dev/null +++ b/vector-role-main/templates/vector.service.j2 @@ -0,0 +1,10 @@ +[Unit] +Description=Vector Service +After=network.target +Requires=network-online.target +[Service] +User={{ ansible_user_id }} +Group={{ ansible_user_gid }} +ExecStart=/usr/bin/vector --config-yaml {{ vector_config_dir }}/vector.yml --watch-config true +Restart=always +WantedBy=multi-user.target% \ No newline at end of file diff --git a/vector-role-main/templates/vector.yml.j2 b/vector-role-main/templates/vector.yml.j2 new file mode 100644 index 000000000..c46abdd22 --- /dev/null +++ b/vector-role-main/templates/vector.yml.j2 @@ -0,0 +1,45 @@ +#TEST config from Ansible +# __ __ __ +# \ \ / / / / +# \ V / / / +# \_/ \/ +# +# V E C T O R +# Configuration +# +# ------------------------------------------------------------------------------ +# Website: https://vector.dev +# Docs: https://vector.dev/docs +# Chat: https://chat.vector.dev +# ------------------------------------------------------------------------------ + +# Change this to use a non-default directory for Vector data storage: +# data_dir = "/var/lib/vector" + +# Random Syslog-formatted logs +[sources.dummy_logs] +type = "demo_logs" +format = "syslog" +interval = 1 + +# Parse Syslog logs +# See the Vector Remap Language reference for more info: https://vrl.dev +[transforms.parse_logs] +type = "remap" +inputs = ["dummy_logs"] +source = ''' +. = parse_syslog!(string!(.message)) +''' + +# Print parsed logs to stdout +[sinks.print] +type = "console" +inputs = ["parse_logs"] +encoding.codec = "json" + +# Vector's GraphQL API (disabled by default) +# Uncomment to try it out with the `vector top` command or +# in your browser at http://localhost:8686 +#[api] +#enabled = true +#address = "127.0.0.1:8686" \ No newline at end of file diff --git a/vector-role-main/tests/inventory b/vector-role-main/tests/inventory new file mode 100644 index 000000000..878877b07 --- /dev/null +++ b/vector-role-main/tests/inventory @@ -0,0 +1,2 @@ +localhost + diff --git a/vector-role-main/tests/test.yml b/vector-role-main/tests/test.yml new file mode 100644 index 000000000..8f0cc7425 --- /dev/null +++ b/vector-role-main/tests/test.yml @@ -0,0 +1,5 @@ +--- +- hosts: localhost + remote_user: root + roles: + - vector-role diff --git a/vector-role-main/vars/main.yml b/vector-role-main/vars/main.yml new file mode 100644 index 000000000..466f4ed0e --- /dev/null +++ b/vector-role-main/vars/main.yml @@ -0,0 +1,22 @@ +--- +vector_url: "https://packages.timber.io/vector/0.33.1/vector-0.33.1-1.x86_64.rpm" +vector_config_dir: "/etc/vector" +data_dir: "/var/lib/vector" +sources: + our_log: + type: file + include: + - "/home/cloud-user/logs/*.log" + ignore_older: 600 + read_from: beginning +sinks: + to_clickhouse: + inputs: + - our_log + type: clickhouse + database: logs + table: my_table + endpoints: "http://158.160.113.245:8123" + healthcheck: false + compression: gzip + skip_unknown_fields: true From 4a090a064c44fb8deb75114b09bc26ac005af5dd Mon Sep 17 00:00:00 2001 From: Maybe-R Date: Wed, 29 Oct 2025 11:23:34 +0300 Subject: [PATCH 15/18] Update README.md --- vector-role-main/README.md | 46 +++++--------------------------------- 1 file changed, 6 insertions(+), 40 deletions(-) diff --git a/vector-role-main/README.md b/vector-role-main/README.md index 8c31cab0c..91677f9fa 100644 --- a/vector-role-main/README.md +++ b/vector-role-main/README.md @@ -1,47 +1,13 @@ -Role Name +##Роли ========= -Deploy Vector to selected hosts. - -Requirements ------------- - -Ansible >= 2.9.9 version installed. - -Role Variables --------------- - | Name | Default Value | Description | |-------------------|---------------------------------------------------------------------|--------------------------------| -| vector_url | https://packages.timber.io/vector/0.33.1/vector-0.33.1-1.x86_64.rpm | Download source | -| vector_config_dir | /etc/vector | Install path | -| data_dir | /var/lib/vector | Vector data directory | -| sources | | For Vector configuration | -| sinks | | Connect to clickhouse settings | - -Dependencies ------------- - -No dependencies - -Example Playbook ----------------- - -Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too: - - - name: Install Vector - hosts: vector - roles: - - vector-role - tags: vector - -License -------- - -Free +| vector_url | https://packages.timber.io/vector/0.33.1/vector-0.33.1-1.x86_64.rpm | Для скачивания | +| vector_config_dir | /etc/vector | Установленный патч | +| data_dir | /var/lib/vector | Директория для Vector | +| sources | | Конфигурация Vector | +| sinks | | Подключение к clickhouse | -Author Information ------------------- -Fedorchuk Dmitriy From f7999409109390537dd8ec3832d595a755232758 Mon Sep 17 00:00:00 2001 From: Maybe-R Date: Wed, 29 Oct 2025 11:25:58 +0300 Subject: [PATCH 16/18] Update main.yml --- vector-role-main/vars/main.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/vector-role-main/vars/main.yml b/vector-role-main/vars/main.yml index 466f4ed0e..79f2a85fc 100644 --- a/vector-role-main/vars/main.yml +++ b/vector-role-main/vars/main.yml @@ -1,5 +1,5 @@ --- -vector_url: "https://packages.timber.io/vector/0.33.1/vector-0.33.1-1.x86_64.rpm" +vector_url: "https://packages.timber.io/vector/0.33.1/vector-0.33.x86_64.rpm" vector_config_dir: "/etc/vector" data_dir: "/var/lib/vector" sources: @@ -7,7 +7,7 @@ sources: type: file include: - "/home/cloud-user/logs/*.log" - ignore_older: 600 + ignore_older: 800 read_from: beginning sinks: to_clickhouse: @@ -16,7 +16,7 @@ sinks: type: clickhouse database: logs table: my_table - endpoints: "http://158.160.113.245:8123" + endpoints: "http://168.110.153.235:8125" healthcheck: false compression: gzip skip_unknown_fields: true From a1c833dd22bfeb0047630a9a8ffd572ad35cbe88 Mon Sep 17 00:00:00 2001 From: Maybe-R Date: Wed, 29 Oct 2025 11:29:39 +0300 Subject: [PATCH 17/18] Add files via upload --- lighthouse-role-main/README.md | 45 ++++++++++++++++ lighthouse-role-main/defaults/main.yml | 2 + lighthouse-role-main/handlers/main.yml | 7 +++ lighthouse-role-main/meta/main.yml | 52 +++++++++++++++++++ lighthouse-role-main/tasks/main.yml | 23 ++++++++ .../templates/lighthouse.conf.j2 | 11 ++++ lighthouse-role-main/tests/inventory | 2 + lighthouse-role-main/tests/test.yml | 5 ++ lighthouse-role-main/vars/main.yml | 5 ++ 9 files changed, 152 insertions(+) create mode 100644 lighthouse-role-main/README.md create mode 100644 lighthouse-role-main/defaults/main.yml create mode 100644 lighthouse-role-main/handlers/main.yml create mode 100644 lighthouse-role-main/meta/main.yml create mode 100644 lighthouse-role-main/tasks/main.yml create mode 100644 lighthouse-role-main/templates/lighthouse.conf.j2 create mode 100644 lighthouse-role-main/tests/inventory create mode 100644 lighthouse-role-main/tests/test.yml create mode 100644 lighthouse-role-main/vars/main.yml diff --git a/lighthouse-role-main/README.md b/lighthouse-role-main/README.md new file mode 100644 index 000000000..7a4d873ad --- /dev/null +++ b/lighthouse-role-main/README.md @@ -0,0 +1,45 @@ +Role Name +========= + +Deploy Lighthouse to selected hosts. + +Requirements +------------ + +Ansible >= 2.7 version installed. + +Role Variables +-------------- + +| Name | Default Value | Description | +|----------------------------|-----------------------------------------|-----------------| +| lighthouse_vcs | https://github.com/VKCOM/lighthouse.git | Download source | +| lighthouse_location_dir | /var/www/lighthouse | Install path | +| lighthouse_access_log_name | lighthouse | Access log name | +| nginx_user_name | nginx | Nginx user name | + +Dependencies +------------ + +Role installation requires GIT installation + +Example Playbook +---------------- + +Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too: + + - name: Install Lighthouse + hosts: lighthouse + roles: + - lighthouse-role + tags: lighthouse + +License +------- + +Free + +Author Information +------------------ + +Fedorchuk Dmitriy \ No newline at end of file diff --git a/lighthouse-role-main/defaults/main.yml b/lighthouse-role-main/defaults/main.yml new file mode 100644 index 000000000..2a92592a7 --- /dev/null +++ b/lighthouse-role-main/defaults/main.yml @@ -0,0 +1,2 @@ +--- +# defaults file for lighthouse-role diff --git a/lighthouse-role-main/handlers/main.yml b/lighthouse-role-main/handlers/main.yml new file mode 100644 index 000000000..858ebca7e --- /dev/null +++ b/lighthouse-role-main/handlers/main.yml @@ -0,0 +1,7 @@ +--- +- name: restart-nginx + ansible.builtin.service: + name: nginx + state: restarted + become: true + become_method: sudo diff --git a/lighthouse-role-main/meta/main.yml b/lighthouse-role-main/meta/main.yml new file mode 100644 index 000000000..c572acc9f --- /dev/null +++ b/lighthouse-role-main/meta/main.yml @@ -0,0 +1,52 @@ +galaxy_info: + author: your name + description: your role description + company: your company (optional) + + # If the issue tracker for your role is not on github, uncomment the + # next line and provide a value + # issue_tracker_url: http://example.com/issue/tracker + + # Choose a valid license ID from https://spdx.org - some suggested licenses: + # - BSD-3-Clause (default) + # - MIT + # - GPL-2.0-or-later + # - GPL-3.0-only + # - Apache-2.0 + # - CC-BY-4.0 + license: license (GPL-2.0-or-later, MIT, etc) + + min_ansible_version: 2.1 + + # If this a Container Enabled role, provide the minimum Ansible Container version. + # min_ansible_container_version: + + # + # Provide a list of supported platforms, and for each platform a list of versions. + # If you don't wish to enumerate all versions for a particular platform, use 'all'. + # To view available platforms and versions (or releases), visit: + # https://galaxy.ansible.com/api/v1/platforms/ + # + # platforms: + # - name: Fedora + # versions: + # - all + # - 25 + # - name: SomePlatform + # versions: + # - all + # - 1.0 + # - 7 + # - 99.99 + + galaxy_tags: [] + # List tags for your role here, one per line. A tag is a keyword that describes + # and categorizes the role. Users find roles by searching for tags. Be sure to + # remove the '[]' above, if you add tags to this list. + # + # NOTE: A tag is limited to a single word comprised of alphanumeric characters. + # Maximum 20 tags per role. + +dependencies: [] + # List your role dependencies here, one per line. Be sure to remove the '[]' above, + # if you add dependencies to this list. diff --git a/lighthouse-role-main/tasks/main.yml b/lighthouse-role-main/tasks/main.yml new file mode 100644 index 000000000..54e932a6a --- /dev/null +++ b/lighthouse-role-main/tasks/main.yml @@ -0,0 +1,23 @@ +--- +- name: Create Lighthouse directory + become: true + ansible.builtin.file: + path: /var/www/lighthouse + state: directory + recurse: yes + mode: '0755' + owner: nginx + group: nginx +- name: Lighthouse | Clone from Git + become: true + ansible.builtin.git: + repo: "{{ lighthouse_vcs }}" + version: master + dest: "{{ lighthouse_location_dir }}" +- name: Lighthouse | Create lighthouse config + become: true + ansible.builtin.template: + src: templates/lighthouse.conf.j2 + dest: /etc/nginx/conf.d/default.conf + mode: '0644' + notify: restart-nginx diff --git a/lighthouse-role-main/templates/lighthouse.conf.j2 b/lighthouse-role-main/templates/lighthouse.conf.j2 new file mode 100644 index 000000000..c666a90dc --- /dev/null +++ b/lighthouse-role-main/templates/lighthouse.conf.j2 @@ -0,0 +1,11 @@ +server { + listen 80; + server_name localhost; + + access_log /var/log/nginx/{{ lighthouse_access_log_name }}.log main; + + location / { + root {{ lighthouse_location_dir }}; + index index.html; + } +} \ No newline at end of file diff --git a/lighthouse-role-main/tests/inventory b/lighthouse-role-main/tests/inventory new file mode 100644 index 000000000..878877b07 --- /dev/null +++ b/lighthouse-role-main/tests/inventory @@ -0,0 +1,2 @@ +localhost + diff --git a/lighthouse-role-main/tests/test.yml b/lighthouse-role-main/tests/test.yml new file mode 100644 index 000000000..a6f999fc8 --- /dev/null +++ b/lighthouse-role-main/tests/test.yml @@ -0,0 +1,5 @@ +--- +- hosts: localhost + remote_user: root + roles: + - lighthouse-role diff --git a/lighthouse-role-main/vars/main.yml b/lighthouse-role-main/vars/main.yml new file mode 100644 index 000000000..68235c344 --- /dev/null +++ b/lighthouse-role-main/vars/main.yml @@ -0,0 +1,5 @@ +--- +lighthouse_vcs: "https://github.com/VKCOM/lighthouse.git" +lighthouse_location_dir: /var/www/lighthouse +lighthouse_access_log_name: lighthouse +nginx_user_name: nginx \ No newline at end of file From c3bdcfaf0b93d2645f9ebc2b63d742625e07e05c Mon Sep 17 00:00:00 2001 From: Maybe-R Date: Wed, 29 Oct 2025 11:31:59 +0300 Subject: [PATCH 18/18] Update README.md --- lighthouse-role-main/README.md | 46 ++++------------------------------ 1 file changed, 5 insertions(+), 41 deletions(-) diff --git a/lighthouse-role-main/README.md b/lighthouse-role-main/README.md index 7a4d873ad..31dd41933 100644 --- a/lighthouse-role-main/README.md +++ b/lighthouse-role-main/README.md @@ -1,45 +1,9 @@ -Role Name -========= - -Deploy Lighthouse to selected hosts. - -Requirements ------------- - -Ansible >= 2.7 version installed. - -Role Variables --------------- +Роли | Name | Default Value | Description | |----------------------------|-----------------------------------------|-----------------| -| lighthouse_vcs | https://github.com/VKCOM/lighthouse.git | Download source | -| lighthouse_location_dir | /var/www/lighthouse | Install path | -| lighthouse_access_log_name | lighthouse | Access log name | -| nginx_user_name | nginx | Nginx user name | - -Dependencies ------------- - -Role installation requires GIT installation - -Example Playbook ----------------- - -Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too: - - - name: Install Lighthouse - hosts: lighthouse - roles: - - lighthouse-role - tags: lighthouse - -License -------- - -Free - -Author Information ------------------- +| lighthouse_vcs | https://github.com/VKCOM/lighthouse.git | Ресурс для скачивания | +| lighthouse_location_dir | /var/www/lighthouse | Инсталяция патча | +| lighthouse_access_log_name | lighthouse | Наименование в логах | +| nginx_user_name | nginx | Имя Nginx | -Fedorchuk Dmitriy \ No newline at end of file