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
+2 -2
View File
@@ -7,13 +7,13 @@
roles: roles:
- role: dokploy - role: dokploy
when: applications.dokploy.enabled | bool when: (applications.dokploy.enabled and containers.docker.enabled) | bool
vars: vars:
dokploy_state: "{{ applications.dokploy.state | default('present') }}" dokploy_state: "{{ applications.dokploy.state | default('present') }}"
tags: dokploy, apps tags: dokploy, apps
- role: coolify - role: coolify
when: applications.coolify.enabled | bool when: (applications.coolify.enabled and containers.docker.enabled) | bool
vars: vars:
coolify_state: "{{ applications.coolify.state | default('present') }}" coolify_state: "{{ applications.coolify.state | default('present') }}"
tags: coolify, apps tags: coolify, apps
+1 -13
View File
@@ -3,7 +3,6 @@
hosts: servers hosts: servers
gather_facts: true gather_facts: true
become: true become: true
serial: "100%"
pre_tasks: pre_tasks:
- name: Update apt cache and upgrade system - name: Update apt cache and upgrade system
@@ -21,6 +20,7 @@
tags: system, updates tags: system, updates
- name: Check system requirements - name: Check system requirements
tags: validation
block: block:
- name: Verify Python 3 is available - name: Verify Python 3 is available
ansible.builtin.command: which python3 ansible.builtin.command: which python3
@@ -33,7 +33,6 @@
filter: ansible_memtotal_mb filter: ansible_memtotal_mb
register: memory_info register: memory_info
failed_when: memory_info.ansible_facts.ansible_memtotal_mb < 512 failed_when: memory_info.ansible_facts.ansible_memtotal_mb < 512
tags: validation
roles: roles:
- role: common - role: common
@@ -77,15 +76,4 @@
test_command: uptime test_command: uptime
when: reboot_required_file.stat.exists when: reboot_required_file.stat.exists
register: reboot_result 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 tags: system
+1 -2
View File
@@ -3,11 +3,10 @@
hosts: servers hosts: servers
gather_facts: true gather_facts: true
become: true become: true
serial: 100%
pre_tasks: pre_tasks:
- name: Ensure Docker and K3s are not both enabled - name: Ensure Docker and K3s are not both enabled
assert: ansible.builtin.assert:
that: that:
- not (containers.docker.enabled and containers.k3s.enabled) - not (containers.docker.enabled and containers.k3s.enabled)
fail_msg: "Docker and K3s cannot both be enabled at the same time." 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 - name: Import base system setup
ansible.builtin.import_playbook: base_setup.yaml ansible.builtin.import_playbook: base_setup.yaml
tags: [init]
- name: Import Docker setup - name: Import Containers setup
ansible.builtin.import_playbook: docker.yaml ansible.builtin.import_playbook: containers.yaml
tags: [containers]
- name: Import application deployment - name: Import application deployment
ansible.builtin.import_playbook: apps.yaml ansible.builtin.import_playbook: apps.yaml
tags: [apps]
- name: Import post-deployment validation - name: Import post-deployment validation
ansible.builtin.import_playbook: validation.yaml ansible.builtin.import_playbook: validation.yaml
tags: [validation]
+15 -15
View File
@@ -3,17 +3,16 @@
hosts: servers hosts: servers
gather_facts: true gather_facts: true
become: false become: false
serial: "100%"
tasks: tasks:
- name: Verify SSH connectivity on custom port - name: Verify SSH connectivity on custom port
tags: validation, networking
ansible.builtin.wait_for: ansible.builtin.wait_for:
port: "{{ security_ssh_port | default(22) }}" port: "{{ security_ssh_port | default(22) }}"
host: "{{ ansible_host | default(inventory_hostname) }}" host: "{{ ansible_host | default(inventory_hostname) }}"
timeout: 60 timeout: 60
delay: 5 delay: 5
state: started state: started
tags: validation, networking
- name: Check critical system services - name: Check critical system services
ansible.builtin.systemd: ansible.builtin.systemd:
@@ -22,39 +21,40 @@
enabled: true enabled: true
loop: loop:
- ssh - ssh
- docker
- fail2ban - fail2ban
- nftables
tags: validation tags: validation
ignore_errors: true failed_when: false
- name: Run comprehensive system health checks - name: Run comprehensive system health checks
tags: validation, health
block: block:
- name: Set root mount fact - name: Set root mount fact
ansible.builtin.set_fact: ansible.builtin.set_fact:
root_mount: "{{ ansible_mounts | selectattr('mount', 'equalto', '/') | list | first }}" root_mount: "{{ ansible_mounts | selectattr('mount', 'equalto', '/') | list | first }}"
tags: validation, health
- name: Check load average - name: Check load average
ansible.builtin.shell: cat /proc/loadavg | awk '{print $1}' ansible.builtin.command:
cmd: cat /proc/loadavg
register: load_avg register: load_avg
changed_when: false changed_when: false
- name: Set load average value
ansible.builtin.set_fact:
load_avg_1m: "{{ load_avg.stdout.split()[0] }}"
- name: Check Docker status - name: Check Docker status
ansible.builtin.shell: ansible.builtin.command:
cmd: docker info >/dev/null 2>&1 && echo "healthy" || echo "unhealthy" cmd: docker info
register: docker_status register: docker_status
changed_when: false changed_when: false
ignore_errors: true failed_when: false
- name: Display comprehensive health status - name: Display comprehensive health status
tags: always, health
ansible.builtin.debug: ansible.builtin.debug:
msg: msg:
- "Health check results for {{ inventory_hostname }}:" - "Health check results for {{ inventory_hostname }}:"
- "Disk usage: {{ ((root_mount.size_total - root_mount.size_available) / root_mount.size_total * 100) | round(2) }}%" - "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) }}%" - "Memory usage: {{ ((ansible_memtotal_mb - ansible_memfree_mb) / ansible_memtotal_mb * 100) | round(2) }}%"
- "Load average (1m): {{ load_avg.stdout }}" - "Load average (1m): {{ load_avg_1m }}"
- "Docker: {{ docker_status.stdout }}" - "Docker: {{ 'healthy' if docker_status.rc == 0 else 'unavailable' }}"
tags: always, health
tags: validation, health