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:
parent
cfb3faf3e4
commit
b4de236938
@ -6,7 +6,7 @@ x11_display_host: "192.168.1.101"
|
||||
|
||||
proxmox_node: "Olimp"
|
||||
admin_user: root
|
||||
|
||||
# Устанвливаем базовые пакеты
|
||||
base_packages:
|
||||
- curl
|
||||
- wget
|
||||
@ -26,7 +26,6 @@ base_packages:
|
||||
- mc
|
||||
- iftop
|
||||
- ntp
|
||||
- gparted
|
||||
- pv
|
||||
|
||||
system_scripts: []
|
||||
@ -34,6 +33,10 @@ custom_directories:
|
||||
- /opt/scripts
|
||||
- /etc/apt/keyrings
|
||||
|
||||
# Удаляем мусорные пакеты везде
|
||||
cleanup_packages:
|
||||
- gparted
|
||||
|
||||
# ------------ gateway (192.168.1.201) ------------
|
||||
npm_base_dir: "/opt/npm"
|
||||
npm_data_dir: "/opt/npm/data"
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
- hosts: all
|
||||
roles:
|
||||
- {role: base_setup, tags: deploy_base}
|
||||
- {role: system_cleanup, tags: deploy_cleanup}
|
||||
|
||||
- hosts: gateway-server
|
||||
roles:
|
||||
|
||||
18
roles/system_cleanup/defaults/main.yml
Normal file
18
roles/system_cleanup/defaults/main.yml
Normal 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: []
|
||||
43
roles/system_cleanup/tasks/main.yml
Normal file
43
roles/system_cleanup/tasks/main.yml
Normal 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
|
||||
Loading…
Reference in New Issue
Block a user