Restore from Gitea ZIP snapshot (12.08.2026) after full instance reinstall

Git history was lost when the previous Gitea instance was wiped and
reinstalled due to an unresolved corruption bug — this commit is the
last known-good file content, exported before the reinstall. Prior
commit history is not recoverable through this path.
This commit is contained in:
Claude Sonnet 5
2026-08-12 19:23:55 +00:00
commit f2c9ab2c73
4 changed files with 325 additions and 0 deletions
+183
View File
@@ -0,0 +1,183 @@
---
- name: Validate input and add host dynamically
hosts: localhost
gather_facts: no
tasks:
- name: Check if vm_ip is provided
fail:
msg: "ERROR: VM IP address is required!"
when: vm_ip is not defined or vm_ip == ""
- name: Check if ansible_user is provided
fail:
msg: "ERROR: ansible_user is required!"
when: ansible_user is not defined or ansible_user == ""
- name: Check authentication method
fail:
msg: |
ERROR: Neither password nor SSH key provided!
Please provide either:
- ansible_password variable for password auth
- ssh_key_path variable for key auth
when: ansible_password is not defined and ssh_key_path is not defined
- name: Display target information
debug:
msg: |
========================================
Target Configuration:
- IP Address: {{ vm_ip }}
- SSH User: {{ ansible_user }}
- Auth Method: {{ 'SSH Key' if ssh_key_path is defined else 'Password' }}
========================================
- name: Add host with password authentication
add_host:
name: "{{ vm_ip }}"
groups: npm_servers
ansible_user: "{{ ansible_user }}"
ansible_ssh_pass: "{{ ansible_password }}"
ansible_become_pass: "{{ ansible_password }}"
ansible_ssh_common_args: '-o StrictHostKeyChecking=no'
when: ansible_password is defined
- name: Add host with key authentication
add_host:
name: "{{ vm_ip }}"
groups: npm_servers
ansible_user: "{{ ansible_user }}"
ansible_ssh_private_key_file: "{{ ssh_key_path }}"
ansible_ssh_common_args: '-o StrictHostKeyChecking=no'
when: ssh_key_path is defined
- name: Setup Minimal Linux with Docker and Nginx Proxy Manager
hosts: npm_servers
become: yes
gather_facts: yes
tasks:
- name: Test connection
ping:
- name: Update apt cache and install prerequisites
apt:
name:
- apt-transport-https
- ca-certificates
- curl
- gnupg
- lsb-release
state: present
update_cache: yes
- name: Add Docker GPG key (modern method)
shell: |
curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
args:
creates: /usr/share/keyrings/docker-archive-keyring.gpg
- name: Add Docker repository
shell: |
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian $(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null
args:
creates: /etc/apt/sources.list.d/docker.list
- name: Update apt cache with Docker repository
apt:
update_cache: yes
- name: Install Docker and Docker Compose Plugin
apt:
name:
- docker-ce
- docker-ce-cli
- containerd.io
- docker-compose-plugin
state: present
- name: Ensure Docker service is running and enabled
systemd:
name: docker
state: started
enabled: yes
- name: Add user to docker group
user:
name: "{{ ansible_user }}"
groups: docker
append: yes
when: ansible_user != 'root'
- name: Create directory for Nginx Proxy Manager
file:
path: /opt/npm
state: directory
mode: '0755'
- name: Create docker-compose.yml for NPM (without version)
copy:
dest: /opt/npm/docker-compose.yml
content: |
services:
app:
image: 'jc21/nginx-proxy-manager:latest'
restart: unless-stopped
ports:
- '80:80'
- '81:81'
- '443:443'
volumes:
- ./data:/data
- ./letsencrypt:/etc/letsencrypt
- name: Run Nginx Proxy Manager via Docker Compose
community.docker.docker_compose_v2:
project_src: /opt/npm
state: present
register: docker_compose_result
retries: 3
delay: 10
until: docker_compose_result is success
ignore_errors: yes
- name: Retry pulling image if failed
command: docker pull jc21/nginx-proxy-manager:latest
when: docker_compose_result is failed
register: docker_pull
retries: 5
delay: 30
until: docker_pull is success
- name: Run Docker Compose again
community.docker.docker_compose_v2:
project_src: /opt/npm
state: present
when: docker_compose_result is failed
- name: Check if containers are running
shell: docker ps --filter "name=app"
register: container_status
changed_when: false
- name: Display container status
debug:
msg: "Container status:\n{{ container_status.stdout }}"
- name: Display access information
debug:
msg: |
========================================
✅ Docker and Nginx Proxy Manager installed!
Container Status:
{{ container_status.stdout }}
Access URLs:
- Admin Panel: http://{{ vm_ip }}:81
- HTTP Proxy: http://{{ vm_ip }}
- HTTPS Proxy: https://{{ vm_ip }}
Default Admin Credentials:
- Email: admin@example.com
- Password: changeme
========================================
+2
View File
@@ -0,0 +1,2 @@
collections:
- name: community.docker
+131
View File
@@ -0,0 +1,131 @@
terraform {
required_providers {
vsphere = {
source = "hashicorp/vsphere"
version = "~> 2.4"
}
}
}
# --- Креды vCenter ---
variable "vsphere_user" {}
variable "vsphere_password" {}
variable "vsphere_server" {}
# --- Фиктивные переменные Ansible ---
variable "ansible_user" { default = "" }
variable "ansible_password" {
default = ""
sensitive = true
}
# --- Переменные Survey ---
variable "vm_name" {}
variable "vm_ip" {}
variable "vm_gateway" {}
variable "vm_cpu" {}
variable "vm_ram" {}
variable "vm_disk_size" {}
variable "vsphere_datacenter" {}
variable "vsphere_datastore" {}
variable "vsphere_pool" {}
variable "vsphere_network" {}
variable "vsphere_template" { default = "debian13-template" }
# --- Настройка провайдера ---
provider "vsphere" {
user = var.vsphere_user
password = var.vsphere_password
vsphere_server = var.vsphere_server
allow_unverified_ssl = true
}
# --- Поиск ресурсов в vCenter ---
data "vsphere_datacenter" "dc" {
name = var.vsphere_datacenter
}
data "vsphere_datastore" "datastore" {
name = var.vsphere_datastore
datacenter_id = data.vsphere_datacenter.dc.id
}
data "vsphere_resource_pool" "pool" {
name = var.vsphere_pool
datacenter_id = data.vsphere_datacenter.dc.id
}
data "vsphere_network" "network" {
name = var.vsphere_network
datacenter_id = data.vsphere_datacenter.dc.id
}
data "vsphere_virtual_machine" "template" {
name = var.vsphere_template
datacenter_id = data.vsphere_datacenter.dc.id
}
# --- Создание ВМ ---
resource "vsphere_virtual_machine" "npm_vm" {
name = var.vm_name
resource_pool_id = data.vsphere_resource_pool.pool.id
datastore_id = data.vsphere_datastore.datastore.id
num_cpus = var.vm_cpu
memory = var.vm_ram
guest_id = data.vsphere_virtual_machine.template.guest_id
network_interface {
network_id = data.vsphere_network.network.id
adapter_type = data.vsphere_virtual_machine.template.network_interface_types[0]
}
disk {
label = "disk0"
size = var.vm_disk_size
thin_provisioned = true
}
# --- Защита от удаления ---
lifecycle {
prevent_destroy = true
}
clone {
template_uuid = data.vsphere_virtual_machine.template.id
customize {
linux_options {
host_name = var.vm_name
domain = "local"
}
network_interface {
ipv4_address = var.vm_ip
ipv4_netmask = 23
}
ipv4_gateway = var.vm_gateway
dns_server_list = ["192.168.1.1", "1.1.1.1"]
}
}
provisioner "remote-exec" {
connection {
type = "ssh"
user = var.ansible_user
password = var.ansible_password
host = var.vm_ip
timeout = "5m"
}
inline = [
# Ждем, пока освободится блокировка dpkg (полезно при старте свежей ОС)
"while sudo lsof /var/lib/dpkg/lock-frontend ; do sleep 10; done;",
# Свободно используем sudo без всяких паролей!
"sudo apt-get update -y",
"sudo apt-get upgrade -y",
"sudo apt-get install -y curl htop wget git",
"echo 'VM УСПЕШНО ПОДГОТОВЛЕНА И ОБНОВЛЕНА!'"
]
}
}
+9
View File
@@ -0,0 +1,9 @@
provider_installation {
network_mirror {
url = "https://terraform-mirror.yandexcloud.net/"
include = ["registry.terraform.io/*/*"]
}
direct {
exclude = ["registry.terraform.io/*/*"]
}
}