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
+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' }}"