---
- name: 预检新节点
  hosts: new_nodes
  gather_facts: yes
  tasks:
    - name: 检查系统信息
      debug:
        msg: |
          主机: {{ inventory_hostname }}
          当前内核: {{ ansible_kernel }}
          内存: {{ ansible_memtotal_mb }}MB
          CPU: {{ ansible_processor_count }}核
          操作系统: {{ ansible_distribution }} {{ ansible_distribution_version }}

    - name: 检查端口占用
      wait_for:
        port: "{{ item }}"
        state: stopped
        timeout: 1
      with_items:
        - 6443
        - 10250
        - 10259
        - 10257
      ignore_errors: yes

    - name: 检查磁盘空间
      shell: df -Th
      register: disk_space
      become: yes

    - name: 显示磁盘空间
      debug:
        msg: "{{ disk_space.stdout }}"

