Update 4 files

- /group_vars/all.yml
- /roles/system_cleanup/defaults/main.yml
- /roles/system_cleanup/tasks/main.yml
- /olimp-deploy.yml
This commit is contained in:
Administrator 2025-10-30 07:50:20 +00:00
parent cfb3faf3e4
commit b4de236938
4 changed files with 67 additions and 2 deletions

View File

@ -6,7 +6,7 @@ x11_display_host: "192.168.1.101"
proxmox_node: "Olimp" proxmox_node: "Olimp"
admin_user: root admin_user: root
# Устанвливаем базовые пакеты
base_packages: base_packages:
- curl - curl
- wget - wget
@ -26,7 +26,6 @@ base_packages:
- mc - mc
- iftop - iftop
- ntp - ntp
- gparted
- pv - pv
system_scripts: [] system_scripts: []
@ -34,6 +33,10 @@ custom_directories:
- /opt/scripts - /opt/scripts
- /etc/apt/keyrings - /etc/apt/keyrings
# Удаляем мусорные пакеты везде
cleanup_packages:
- gparted
# ------------ gateway (192.168.1.201) ------------ # ------------ gateway (192.168.1.201) ------------
npm_base_dir: "/opt/npm" npm_base_dir: "/opt/npm"
npm_data_dir: "/opt/npm/data" npm_data_dir: "/opt/npm/data"

View File

@ -2,6 +2,7 @@
- hosts: all - hosts: all
roles: roles:
- {role: base_setup, tags: deploy_base} - {role: base_setup, tags: deploy_base}
- {role: system_cleanup, tags: deploy_cleanup}
- hosts: gateway-server - hosts: gateway-server
roles: roles:

View File

@ -0,0 +1,18 @@
# Пакеты для удаления (по умолчанию — пусто)
cleanup_packages: []
# Автоматически удалять неиспользуемые зависимости
cleanup_autoremove: true
# Очистка Docker
cleanup_docker: true
cleanup_docker_containers: true
cleanup_docker_images: true
cleanup_docker_volumes: true
cleanup_docker_networks: true
# SSH-ключи для удаления (опционально)
cleanup_ssh_keys: []
# Каталоги для удаления (осторожно!)
cleanup_directories: []

View File

@ -0,0 +1,43 @@
---
- name: Remove unwanted system packages
apt:
name: "{{ cleanup_packages }}"
state: absent
autoremove: "{{ cleanup_autoremove }}"
purge: true
when: cleanup_packages | length > 0
- name: Remove specific SSH authorized keys (if any defined)
authorized_key:
user: root
key: "{{ item }}"
state: absent
loop: "{{ cleanup_ssh_keys | default([]) }}"
when: cleanup_ssh_keys | length > 0
- name: Prune unused Docker containers
command: docker container prune -f
when: cleanup_docker and cleanup_docker_containers
changed_when: true
- name: Prune unused Docker images
command: docker image prune -af
when: cleanup_docker and cleanup_docker_images
changed_when: true
- name: Prune unused Docker volumes
command: docker volume prune -f
when: cleanup_docker and cleanup_docker_volumes
changed_when: true
- name: Prune unused Docker networks
command: docker network prune -f
when: cleanup_docker and cleanup_docker_networks
changed_when: true
- name: Remove custom directories (use with caution!)
file:
path: "{{ item }}"
state: absent
loop: "{{ cleanup_directories | default([]) }}"
when: cleanup_directories | length > 0