2016-08-15 2 views
0

나는 Ansible/Ansible Tower를 사용하고 있으며 내 Windows 호스트에서 사용할 수있는 사실을 확인하고 싶습니다. 내가 호스트의 정보를 수집 할 수 있도록가능 - 원격 Windows 호스트에서 사실 확인

ansible hostname -m setup 

어떻게 내가 타워에서 운영하는 각본에이 통합 것입니다 : 나는 다음 실행할 수 documentation 상태?

# 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 

그러나,이를 실행하면 다음과 같은 오류가 발생합니다 :

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

답변

2

사용 gather_facts 기본적으로 true입니다

여기에 주어진 지원에 따라 현재 플레이 북이다. 이것은 setup 모듈을 실행하는 것과 같습니다.

- hosts: .... 
    gather_facts: yes 

사실은 플레이 북에서 사용할 수 있도록 변수에 저장됩니다. System Facts

가능성있는 사실을 표시하는 방법은 다양합니다. 당신이 어떻게 작동하는지 이해하려면, 다음과 같은 시도 :

- hosts: 127.0.0.1 
    gather_facts: true 

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

/어떻게 출력이받을 수 있나요 ? – Kode

+1

@Kode 내 업데이트를 참조하십시오. – helloV

+0

변수가 무엇인지 알 수 있도록 큰 목록을 출력하는 방법이 있습니까? 그들의 예에서는 큰 우분투 출력을 제공합니다. 위에 열거 한 내용을 통해 이제 변수로 사용할 수있는 것을 알 수 있습니다. fact_path를 나열하지만이 기능이 회보에서 어떻게 작동하는지 잘 모르겠다. http://docs.ansible.com/ansible/setup_module.html – Kode

0

테스트하고 그것을 통해 작업이 나를 위해 노력하고 있습니다 :

출력 표시를하지
- name: Gather Windows Facts 
    hosts: "{{ target }}" 
    tasks: 
    - debug: var=vars 
    - debug: var=hostvars[inventory_hostname] 
관련 문제