Ansible có thể thu thập sự thật về bất kỳ máy chủ lưu trữ nào mà bạn nói với nó, cho dù đó là máy chủ từ xa hay máy chủ lưu trữ cục bộ từ nơi bạn đang thực hiện ansible / ansible-playbook.
Thí dụ
Hàng tồn kho mẫu:
$ cat local_inv
[local]
localhost ansible_connection=local
Mẫu vở kịch:
$ cat os.yml
- name: OS family
hosts: all
tasks:
- name: print OS Family
debug: var=ansible_os_family
Chạy ví dụ:
$ ansible-playbook -i local_inv os.yml
PLAY [OS family] *********************************************************************************************************************************************************************************************************************************
TASK [Gathering Facts] ***************************************************************************************************************************************************************************************************************************
ok: [localhost]
TASK [print OS Family] ***************************************************************************************************************************************************************************************************************************
ok: [localhost] => {
"ansible_os_family": "Darwin"
}
PLAY RECAP ***************************************************************************************************************************************************************************************************************************************
localhost : ok=2 changed=0 unreachable=0 failed=0