---
- name: "play 1: Gather facts of h-1"
  hosts: h-1
  remote_user: root
  # gather_facts: no  # 关闭 gather_facts，默认为开启 yes
  tasks:
  - shell: "echo register_var_in_play1"
    register: shellreturn  # 注册变量

- name: "play 2: Get facts of h-1 when operating on h-2"
  hosts: h-2
  remote_user: root
  tasks:
  - debug:
      msg: "{{hostvars['h-1'].ansible_eth0.ipv4}}, {{inventory_hostname}}, {{inventory_hostname_short}}, {{play_hosts}}, {{groups}}, {{groups.testservers}}, {{group_names}}, {{inventory_dir}}"
  - debug:
      msg: "{{hostvars['h-1'].shellreturn.stdout}}"  # 跨节点输出，{{hostvars.h1.shellreturn.stdout}}
