Files
Maison/Migration/Ansible/diagnostic.yml
2026-02-10 12:12:11 +01:00

65 lines
2.0 KiB
YAML

---
# Diagnostic Playbook for Troubleshooting
- name: System Diagnostic
hosts: all
become: yes
gather_facts: yes
tasks:
- name: Display system information
debug:
msg:
- "Distribution: {{ ansible_distribution }} {{ ansible_distribution_version }}"
- "Architecture: {{ ansible_architecture }}"
- "Kernel: {{ ansible_kernel }}"
- "Service Manager: {{ ansible_service_mgr }}"
- "Python Version: {{ ansible_python_version }}"
- name: Check available services
service_facts:
- name: Display logging services
debug:
msg: "Available logging services: {{ ansible_facts.services.keys() | select('match', '.*log.*') | list }}"
- name: Check if rsyslog package is installed
package_facts:
manager: apt
- name: Display rsyslog package info
debug:
msg: "Rsyslog installed: {{ 'rsyslog' in ansible_facts.packages }}"
- name: Test basic connectivity
ping:
- name: Check disk space
debug:
msg: "Available space: {{ ansible_mounts | selectattr('mount', 'equalto', '/') | map(attribute='size_available') | first | human_readable }}"
- name: Create diagnostic script
template:
src: system-diagnostic.sh.j2
dest: /tmp/diagnostic.sh
mode: '0755'
delegate_to: localhost
run_once: true
- name: Run diagnostic on target
shell: |
echo "=== System Information ==="
uname -a
echo ""
echo "=== Distribution ==="
cat /etc/os-release 2>/dev/null || echo "No os-release file"
echo ""
echo "=== Services ==="
systemctl list-units --type=service --state=active | head -10 || echo "No systemctl"
echo ""
echo "=== Packages ==="
dpkg -l | grep rsyslog || echo "No rsyslog package found"
register: diagnostic_output
- name: Display diagnostic output
debug:
var: diagnostic_output.stdout_lines