Ansible-从远程Windows主机获取事实

Ansible-从远程Windows主机获取事实,ansible,ansible-playbook,ansible-facts,Ansible,Ansible Playbook,Ansible Facts,我正在使用Ansible/Ansible Tower,希望确定我的Windows主机上有哪些可用的事实。我可以运行以下命令的状态: ansible hostname -m setup - hosts: 127.0.0.1 gather_facts: true tasks: - setup: register: ansible_facts - debug: item with_dict: ansible_facts 我该如何将其纳入我从塔台运行的剧本中,以便从

我正在使用Ansible/Ansible Tower,希望确定我的Windows主机上有哪些可用的事实。我可以运行以下命令的状态:

ansible hostname -m setup
- hosts: 127.0.0.1
  gather_facts: true

  tasks:
  - setup:
    register: ansible_facts
  - debug: item
    with_dict: ansible_facts
我该如何将其纳入我从塔台运行的剧本中,以便从主持人那里收集信息

以下是根据所提供协助的当前行动手册:

# 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
但是,运行此命令会产生以下错误:

错误!此任务“调试”具有额外的参数,仅在 以下模块:命令、shell、脚本、include、include_vars、, 添加主机、分组依据、设置事实、原始、元


使用默认情况下为true的
收集事实。这相当于运行
设置
模块

- hosts: ....
  gather_facts: yes
事实保存在ansible变量中,以便在剧本中使用。看

有许多方法可以显示可解释的事实。要了解其工作原理,请尝试以下操作:

ansible hostname -m setup
- hosts: 127.0.0.1
  gather_facts: true

  tasks:
  - setup:
    register: ansible_facts
  - debug: item
    with_dict: ansible_facts

通过测试和工作,这对我来说很有用:

- name: Gather Windows Facts 
  hosts: "{{ target }}"
  tasks:
    - debug: var=vars
    - debug: var=hostvars[inventory_hostname]

输出显示在哪里/如何将其输出?是否有方法输出大列表以便我知道变量是什么?在他们的示例中,它提供了一个大型Ubuntu输出。通过列出这些,我现在可以知道我可以使用什么作为变量。下面列出了一个事实路径,但不确定它在playbook中如何工作-debug上收到一个错误(比playbook更新):违规行似乎是:register:ansible\u facts-debug:item^在此发布您的playbook或尝试我发布的playbook。完成后,我收集了一个事实:是,而您有true