mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2025-08-30 15:28:12 +02:00
THE HUGE REFACTORING CALENDER WEEK 33; Optimized Matrix and during this updated variables, and implemented better reset and cleanup mode handling, also solved some initial setup bugs
This commit is contained in:
43
roles/sys-svc-docker/Administration.md
Normal file
43
roles/sys-svc-docker/Administration.md
Normal file
@@ -0,0 +1,43 @@
|
||||
# Administration 🛠️
|
||||
|
||||
## List Unused Volumes
|
||||
```bash
|
||||
docker volume ls -q -f "dangling=true"
|
||||
```
|
||||
|
||||
## Remove All Unused Volumes
|
||||
```bash
|
||||
docker volume rm $(docker volume ls -q -f "dangling=true")
|
||||
```
|
||||
|
||||
## Network Issues Fixes
|
||||
```bash
|
||||
docker stop $(docker ps -a -q)
|
||||
docker rm $(docker ps -a -q)
|
||||
docker network prune -f
|
||||
systemctl stop docker
|
||||
rm -fv /var/lib/docker/network/files/local-kv.db
|
||||
systemctl start docker
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
# Warning ⚠️
|
||||
|
||||
**Caution:** The following instructions will delete **all Docker containers and volumes** on your server.
|
||||
Make sure you have backups or that you're certain you want to clean your Docker environment completely.
|
||||
|
||||
---
|
||||
|
||||
## Cleaning Up Docker Containers and Volumes 🧹
|
||||
|
||||
### Delete All Docker Containers
|
||||
```bash
|
||||
docker stop $(docker ps -a -q)
|
||||
docker rm $(docker ps -a -q)
|
||||
```
|
||||
|
||||
### Delete All Docker Volumes
|
||||
```bash
|
||||
docker volume rm $(docker volume ls -q)
|
||||
```
|
44
roles/sys-svc-docker/README.md
Normal file
44
roles/sys-svc-docker/README.md
Normal file
@@ -0,0 +1,44 @@
|
||||
# Docker Server
|
||||
|
||||
## Description
|
||||
|
||||
This role installs and maintains the Docker service, including Docker Compose, on Linux systems.
|
||||
It is part of the [Infinito.Nexus Project](https://s.infinito.nexus/code), maintained and developed by [Kevin Veen-Birkenbach](https://www.veen.world/).
|
||||
|
||||
## Overview
|
||||
|
||||
The role ensures that Docker and Docker Compose are present, integrates essential backup, repair, and health check roles, and supports cleanup or full reset modes for a fresh Docker environment.
|
||||
When enabled via `MODE_CLEANUP` or `MODE_RESET`, it will automatically prune unused Docker resources.
|
||||
`MODE_RESET` additionally restarts the Docker service after cleanup.
|
||||
|
||||
## Features
|
||||
|
||||
- **Automated Installation**
|
||||
Installs Docker and Docker Compose via the system package manager.
|
||||
|
||||
- **Integrated Dependencies**
|
||||
Includes backup, repair, and health check sub-roles:
|
||||
- `sys-bkp-docker-2-loc`
|
||||
- `user-administrator`
|
||||
- `sys-hlth-docker-container`
|
||||
- `sys-hlth-docker-volumes`
|
||||
- `sys-rpr-docker-soft`
|
||||
- `sys-rpr-docker-hard`
|
||||
|
||||
- **Cleanup & Reset Modes**
|
||||
- `MODE_CLEANUP`: Removes unused Docker containers, networks, images, and volumes.
|
||||
- `MODE_RESET`: Performs cleanup and restarts the Docker service.
|
||||
|
||||
- **Handler Integration**
|
||||
Restart handler ensures the Docker daemon is reloaded when necessary.
|
||||
|
||||
## License
|
||||
|
||||
This role is released under the Infinito.Nexus NonCommercial License (CNCL).
|
||||
See [license details](https://s.infinito.nexus/license).
|
||||
|
||||
## Author Information
|
||||
|
||||
Kevin Veen-Birkenbach
|
||||
Consulting & Coaching Solutions
|
||||
[https://www.veen.world](https://www.veen.world)
|
6
roles/sys-svc-docker/handlers/main.yml
Normal file
6
roles/sys-svc-docker/handlers/main.yml
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
- name: docker restart
|
||||
service:
|
||||
name: docker.service
|
||||
state: restarted
|
||||
enabled: yes
|
28
roles/sys-svc-docker/meta/main.yml
Normal file
28
roles/sys-svc-docker/meta/main.yml
Normal file
@@ -0,0 +1,28 @@
|
||||
---
|
||||
galaxy_info:
|
||||
author: "Kevin Veen-Birkenbach"
|
||||
description: >
|
||||
Installs and maintains Docker.
|
||||
license: "Infinito.Nexus NonCommercial License"
|
||||
license_url: "https://s.infinito.nexus/license"
|
||||
company: |
|
||||
Kevin Veen-Birkenbach
|
||||
Consulting & Coaching Solutions
|
||||
https://www.veen.world
|
||||
min_ansible_version: "2.9"
|
||||
platforms:
|
||||
- name: Linux
|
||||
versions:
|
||||
- all
|
||||
galaxy_tags:
|
||||
- docker
|
||||
- container
|
||||
- infrastructure
|
||||
- automation
|
||||
- cleanup
|
||||
- linux
|
||||
- system
|
||||
repository: "https://s.infinito.nexus/code"
|
||||
issue_tracker_url: "https://s.infinito.nexus/issues"
|
||||
documentation: "https://s.infinito.nexus/code/docker"
|
||||
|
25
roles/sys-svc-docker/tasks/01_core.yml
Normal file
25
roles/sys-svc-docker/tasks/01_core.yml
Normal file
@@ -0,0 +1,25 @@
|
||||
- name: docker & docker compose install
|
||||
community.general.pacman:
|
||||
name:
|
||||
- 'docker'
|
||||
- 'docker-compose'
|
||||
state: present
|
||||
notify: docker restart
|
||||
|
||||
- name: "Load cleanup tasks when MODE_CLEANUP or MODE_RESET is enabled"
|
||||
include_tasks: "02_cleanup.yml"
|
||||
when: MODE_CLEANUP | bool or MODE_RESET | bool
|
||||
|
||||
- name: "Load reset tasks when MODE_RESET is enabled"
|
||||
include_tasks: "03_reset.yml"
|
||||
when: MODE_RESET | bool
|
||||
|
||||
- name: Include backup, repair and health services for docker
|
||||
include_role:
|
||||
name: "{{ item }}"
|
||||
loop:
|
||||
- sys-bkp-docker-2-loc
|
||||
- sys-hlth-docker-container
|
||||
- sys-hlth-docker-volumes
|
||||
- sys-rpr-docker-soft
|
||||
- sys-rpr-docker-hard
|
3
roles/sys-svc-docker/tasks/02_cleanup.yml
Normal file
3
roles/sys-svc-docker/tasks/02_cleanup.yml
Normal file
@@ -0,0 +1,3 @@
|
||||
- name: Prune Docker resources
|
||||
become: true
|
||||
ansible.builtin.command: docker system prune -f
|
4
roles/sys-svc-docker/tasks/03_reset.yml
Normal file
4
roles/sys-svc-docker/tasks/03_reset.yml
Normal file
@@ -0,0 +1,4 @@
|
||||
- name: Trigger Docker restart
|
||||
ansible.builtin.debug:
|
||||
msg: "MODE_RESET is enabled → restarting Docker"
|
||||
notify: Restart Docker
|
5
roles/sys-svc-docker/tasks/main.yml
Normal file
5
roles/sys-svc-docker/tasks/main.yml
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
- block:
|
||||
- include_tasks: 01_core.yml
|
||||
- include_tasks: utils/run_once.yml
|
||||
when: run_once_sys_svc_docker is not defined
|
Reference in New Issue
Block a user