I am using Ansible / Ansible Tower and would like to determine what facts are available on my Windows host. The documentation states that I can run the following:
ansible hostname -m setup
How would I incorporate this into a playbook I run from Tower so I can gather the information from hosts?
Here is the current Playbook per the assistance given:
# This play outputs the facts of the Windows targets in scope
- name: Gather Windows Facts
hosts: "{{ target }}"
gather_facts: yes
tasks:
- setup:
register: ansible_facts
- debug: item
with_dict: ansible_facts
However, running this produces the following error:
ERROR! this task 'debug' has extra params, which is only allowed in the following modules: command, shell, script, include, include_vars, add_host, group_by, set_fact, raw, meta
Use gather_facts
which is true by default. It is equivalent to running setup
module.
- hosts: ....
gather_facts: yes
The facts are saved in ansible variables to be used in playbooks. See System Facts
There are many ways to display the ansible facts. For you to understand how it works, try the following:
- hosts: 127.0.0.1
gather_facts: true
tasks:
- setup:
register: ansible_facts
- debug: item
with_dict: ansible_facts