---
- hosts: testservers
  remote_user: root
  vars:
    testvar1: test1_string
  tasks:
  - shell: "echo test2_string"
    register: shellreturn
  - set_fact:
      testsv1: "{{testvar1}}"
      testsv2: "{{shellreturn.stdout}}"
  - debug:
      msg: "{{testsv1}} {{testsv2}}"
      #var: shellreturn

- hosts: testservers
  remote_user: root
  tasks:
  - name: other play get testsv1
    debug:
      msg: "{{testsv1}}"
  # - name: other play get testvar1  # 获取失败，没有定义 testvar1
    # debug:
      # msg: "{{testvar1}}"
