Showcase update - f20be312
Quote Bot CI/CD Pipeline / check (push) Waiting to run
Quote Bot CI/CD Pipeline / Security Scan (push) Waiting to run
Quote Bot CI/CD Pipeline / Build and push to Docker Hub (push) Blocked by required conditions
Quote Bot CI/CD Pipeline / Deploy to VPS via Ansible (push) Blocked by required conditions
Quote Bot CI/CD Pipeline / check (push) Waiting to run
Quote Bot CI/CD Pipeline / Security Scan (push) Waiting to run
Quote Bot CI/CD Pipeline / Build and push to Docker Hub (push) Blocked by required conditions
Quote Bot CI/CD Pipeline / Deploy to VPS via Ansible (push) Blocked by required conditions
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
# deploy.yml
|
||||
- name: Автоматический деплой Telegram-бота
|
||||
hosts: all
|
||||
|
||||
vars:
|
||||
image_name: "leor156/quote-bot:{{ image_tag | default('latest') }}"
|
||||
container_name: "quote-bot"
|
||||
container_state: "started"
|
||||
|
||||
tasks:
|
||||
- name: Убеждаемся, что установлена библиотека Docker для Python
|
||||
apt:
|
||||
name: python3-docker
|
||||
state: present
|
||||
update_cache: yes
|
||||
|
||||
- name: Скачиваем образ бота с Docker Hub
|
||||
community.docker.docker_image:
|
||||
name: "{{ image_name }}"
|
||||
source: pull
|
||||
|
||||
- name: Запускаем контейнер
|
||||
community.docker.docker_container:
|
||||
name: "{{ container_name }}"
|
||||
image: "{{ image_name }}"
|
||||
state: "{{ container_state }}"
|
||||
restart_policy: unless-stopped
|
||||
pull: always
|
||||
env:
|
||||
TOKEN: "{{ lookup('env', 'BOT_TOKEN') }}"
|
||||
ADMIN_IDS: "{{ lookup('env', 'ADMIN_ID_TG') }}"
|
||||
|
||||
- name: Чистка
|
||||
community.docker.docker_prune:
|
||||
images: yes
|
||||
images_filters:
|
||||
dangling: true
|
||||
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
[server-bot]
|
||||
quote-bot-prod ansible_host="{{ lookup('env', 'BOT_SERVER_IP') }}" ansible_user=root ansible_ssh_private_key_file=~/.ssh/id_ed25519
|
||||
@@ -0,0 +1,44 @@
|
||||
resource "yandex_compute_filesystem" "shared_disk" {
|
||||
name = "my-shared-30gb-disk"
|
||||
type = "network-hdd"
|
||||
size = 30
|
||||
zone = "ru-central1-d"
|
||||
}
|
||||
|
||||
data "yandex_compute_image" "ubuntu" {
|
||||
family = "ubuntu-2404-lts"
|
||||
}
|
||||
|
||||
resource "yandex_compute_instance" "servers" {
|
||||
count = 2
|
||||
name = "server-${count.index + 1}"
|
||||
platform_id = "standard-v3"
|
||||
zone = "ru-central1-d"
|
||||
|
||||
resources {
|
||||
cores = 2
|
||||
memory = 2
|
||||
}
|
||||
|
||||
|
||||
|
||||
# Указываем загрузочный диск с Ubuntu
|
||||
boot_disk {
|
||||
initialize_params {
|
||||
image_id = data.yandex_compute_image.ubuntu.id
|
||||
size = 10 # Размер загрузочного диска
|
||||
}
|
||||
}
|
||||
# Подключаем наш общий диск на 30 ГБ
|
||||
filesystem {
|
||||
filesystem_id = yandex_compute_filesystem.shared_disk.id
|
||||
device_name = "shared-disk"
|
||||
}
|
||||
# Подключаем сервер к подсети (которая лежит в файле network.tf)
|
||||
network_interface {
|
||||
subnet_id = yandex_vpc_subnet.subnet.id
|
||||
|
||||
# Даем белый IP только первому серверу
|
||||
nat = count.index == 0 ? true : false
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
resource "yandex_vpc_network" "network" {
|
||||
name = "my-network"
|
||||
}
|
||||
|
||||
resource "yandex_vpc_subnet" "subnet" {
|
||||
name = "my-internal-subnet"
|
||||
v4_cidr_blocks = ["10.0.0.0/24"]
|
||||
zone = "ru-central1-d"
|
||||
network_id = yandex_vpc_network.network.id
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
output "public_ip_server_1" {
|
||||
value = yandex_compute_instance.servers[0].network_interface.0.nat_ip_address
|
||||
description = "Белый IP первого сервера"
|
||||
}
|
||||
output "internal_ips" {
|
||||
value = yandex_compute_instance.servers[*].network_interface.0.ip_address
|
||||
description = "Внутренние IP адреса обоих серверов"
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
yandex = {
|
||||
source = "yandex-cloud/yandex"
|
||||
}
|
||||
}
|
||||
required_version = ">= 0.13"
|
||||
}
|
||||
provider "yandex" {
|
||||
service_account_key_file = "authorized_key.json"
|
||||
cloud_id = "b1gl9hdpdr35i83uh5t5"
|
||||
folder_id = "b1gbb5kej5tlskp8i5oq"
|
||||
zone = "ru-central1-a"
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
variable "zone" {
|
||||
type = string
|
||||
default = "ru-central1-d"
|
||||
}
|
||||
|
||||
variable "network" {
|
||||
type = string
|
||||
default = "ya-network"
|
||||
}
|
||||
|
||||
variable "subnet" {
|
||||
type = string
|
||||
default = "ya-network"
|
||||
}
|
||||
|
||||
variable "subnet_v4_cidr_blocks" {
|
||||
type = list(string)
|
||||
default = ["192.168.10.0/24"]
|
||||
}
|
||||
|
||||
variable "nat" {
|
||||
type = bool
|
||||
default = true
|
||||
}
|
||||
|
||||
variable "image_family" {
|
||||
type = string
|
||||
default = "ubuntu-2404-lts"
|
||||
}
|
||||
|
||||
variable "name" {
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "cores" {
|
||||
type = number
|
||||
default = 2
|
||||
}
|
||||
|
||||
variable "memory" {
|
||||
type = number
|
||||
default = 4
|
||||
}
|
||||
|
||||
variable "disk_size" {
|
||||
type = number
|
||||
default = 50
|
||||
}
|
||||
|
||||
variable "disk_type" {
|
||||
type = string
|
||||
default = "network-nvme"
|
||||
}
|
||||
|
||||
variable "user_name" {
|
||||
default = ""
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "user_pass" {
|
||||
default = ""
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "admin_pass" {
|
||||
default = ""
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "timeout_create" {
|
||||
default = "10m"
|
||||
}
|
||||
|
||||
variable "timeout_delete" {
|
||||
default = "10m"
|
||||
}
|
||||
Reference in New Issue
Block a user