O Ansible pode coletar fatos sobre qualquer host que você informe, seja um servidor remoto ou o host local de onde você está executando uma lista de reprodução ansible / ansible.
Exemplo
Inventário de amostra:
$ cat local_inv
[local]
localhost ansible_connection=local
Exemplo de cartilha:
$ cat os.yml
- name: OS family
hosts: all
tasks:
- name: print OS Family
debug: var=ansible_os_family
Exemplo de execução:
$ 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