---
- name: Pre-installation checks
  hosts: test_hosts
  become: yes
  tasks:
    - name: Check system information
      setup:
        gather_subset: 
          - '!all'
          - '!any'
          - 'distribution'
          - 'distribution_version'
          - 'os_family'

    - name: Display system info
      debug:
        msg:
          - "OS: {{ ansible_distribution }} {{ ansible_distribution_version }}"
          - "Family: {{ ansible_os_family }}"
          - "Architecture: {{ ansible_architecture }}"

    - name: Check available space
      shell: df -h / | tail -1 | awk '{print "Available:", $4, "Used:", $5}'
      register: space_info

    - name: Display space info
      debug:
        var: space_info.stdout

    - name: Check if Zabbix is already installed
      package_facts:

    - name: Display Zabbix installation status
      debug:
        msg: "Zabbix Agent2 is {{ 'already installed' if 'zabbix-agent2' in ansible_facts.packages else 'not installed' }}"
