原文链接:https://www.cnblogs.com/lxmhhy/p/6813953.html
# yml 如下
---
- hosts: "{{ host }}"
gather_facts: true
remote_user: root
tasks:
- shell: ifconfig
register: output
- debug: var=output.stdout
- debug: msg=" ansible_system={{ ansible_system }}"
- debug: msg={{ ansible_selinux }}
# 执行
ansible-playbook yml/facts.yml -e host=test102 # 或者
ansible-playbook yml/facts.yml -i hosts -e host=test102