chore(): improved core playbooks

This commit is contained in:
ITQ
2026-03-19 14:40:07 +03:00
parent dc12c91184
commit 3f5f2c4f18
5 changed files with 31 additions and 40 deletions
+3 -3
View File
@@ -7,13 +7,13 @@
roles:
- role: dokploy
when: applications.dokploy.enabled | bool
when: (applications.dokploy.enabled and containers.docker.enabled) | bool
vars:
dokploy_state: "{{ applications.dokploy.state | default('present') }}"
tags: dokploy, apps
- role: coolify
when: applications.coolify.enabled | bool
when: (applications.coolify.enabled and containers.docker.enabled) | bool
vars:
coolify_state: "{{ applications.coolify.state | default('present') }}"
tags: coolify, apps
@@ -21,7 +21,7 @@
- role: artis3n.tailscale.machine
when: applications.tailscale.enabled | bool
tags: tailscale, apps
- role: borgbase.ansible_role_borgbackup
when: applications.borgbackup.enabled | bool
tags: borgbackup, apps
+4 -16
View File
@@ -3,7 +3,6 @@
hosts: servers
gather_facts: true
become: true
serial: "100%"
pre_tasks:
- name: Update apt cache and upgrade system
@@ -21,6 +20,7 @@
tags: system, updates
- name: Check system requirements
tags: validation
block:
- name: Verify Python 3 is available
ansible.builtin.command: which python3
@@ -33,7 +33,6 @@
filter: ansible_memtotal_mb
register: memory_info
failed_when: memory_info.ansible_facts.ansible_memtotal_mb < 512
tags: validation
roles:
- role: common
@@ -56,11 +55,11 @@
Architecture: {{ ansible_architecture }}
Memory: {{ ansible_memtotal_mb }}MB
CPUs: {{ ansible_processor_vcpus }}
Storage: {{ ansible_devices.vda.size if ansible_devices.vda is defined
else (ansible_devices.sda.size if ansible_devices.sda is defined
Storage: {{ ansible_devices.vda.size if ansible_devices.vda is defined
else (ansible_devices.sda.size if ansible_devices.sda is defined
else 'N/A') }}
tags: always, info
- name: Check if a reboot is required after updates
ansible.builtin.stat:
path: /var/run/reboot-required
@@ -77,15 +76,4 @@
test_command: uptime
when: reboot_required_file.stat.exists
register: reboot_result
async: 600
poll: 0
tags: system
- name: Wait for reboot to complete
ansible.builtin.wait_for_connection:
connect_timeout: 20
sleep: 5
delay: 5
timeout: 600
when: reboot_required_file.stat.exists
tags: system
+1 -2
View File
@@ -3,11 +3,10 @@
hosts: servers
gather_facts: true
become: true
serial: 100%
pre_tasks:
- name: Ensure Docker and K3s are not both enabled
assert:
ansible.builtin.assert:
that:
- not (containers.docker.enabled and containers.k3s.enabled)
fail_msg: "Docker and K3s cannot both be enabled at the same time."
+6 -2
View File
@@ -1,12 +1,16 @@
---
- name: Import base system setup
ansible.builtin.import_playbook: base_setup.yaml
tags: [init]
- name: Import Docker setup
ansible.builtin.import_playbook: docker.yaml
- name: Import Containers setup
ansible.builtin.import_playbook: containers.yaml
tags: [containers]
- name: Import application deployment
ansible.builtin.import_playbook: apps.yaml
tags: [apps]
- name: Import post-deployment validation
ansible.builtin.import_playbook: validation.yaml
tags: [validation]
+17 -17
View File
@@ -3,17 +3,16 @@
hosts: servers
gather_facts: true
become: false
serial: "100%"
tasks:
- name: Verify SSH connectivity on custom port
tags: validation, networking
ansible.builtin.wait_for:
port: "{{ security_ssh_port | default(22) }}"
host: "{{ ansible_host | default(inventory_hostname) }}"
timeout: 60
delay: 5
state: started
tags: validation, networking
- name: Check critical system services
ansible.builtin.systemd:
@@ -22,39 +21,40 @@
enabled: true
loop:
- ssh
- docker
- fail2ban
- nftables
tags: validation
ignore_errors: true
failed_when: false
- name: Run comprehensive system health checks
tags: validation, health
block:
- name: Set root mount fact
ansible.builtin.set_fact:
root_mount: "{{ ansible_mounts | selectattr('mount', 'equalto', '/') | list | first }}"
tags: validation, health
- name: Check load average
ansible.builtin.shell: cat /proc/loadavg | awk '{print $1}'
ansible.builtin.command:
cmd: cat /proc/loadavg
register: load_avg
changed_when: false
- name: Set load average value
ansible.builtin.set_fact:
load_avg_1m: "{{ load_avg.stdout.split()[0] }}"
- name: Check Docker status
ansible.builtin.shell:
cmd: docker info >/dev/null 2>&1 && echo "healthy" || echo "unhealthy"
ansible.builtin.command:
cmd: docker info
register: docker_status
changed_when: false
ignore_errors: true
failed_when: false
- name: Display comprehensive health status
tags: always, health
ansible.builtin.debug:
msg:
- "Health check results for {{ inventory_hostname }}:"
- "Disk usage: {{ ((root_mount.size_total - root_mount.size_available) / root_mount.size_total * 100) | round(2) }}%"
- "Memory usage: {{ ((ansible_memtotal_mb - ansible_memfree_mb) / ansible_memtotal_mb * 100) | round(2) }}%"
- "Load average (1m): {{ load_avg.stdout }}"
- "Docker: {{ docker_status.stdout }}"
tags: always, health
tags: validation, health
- "Load average (1m): {{ load_avg_1m }}"
- "Docker: {{ 'healthy' if docker_status.rc == 0 else 'unavailable' }}"