gather facts

From wikieduonline
(Redirected from Gather facts:)
Jump to navigation Jump to search

Ansible gather_facts module, new in Ansible 2.8 (May 2019), allows to gather useful variables about remote hosts that can be used in playbooks

gather_facts: [ no | yes ]


#!/usr/bin/env ansible-playbook

- hosts: localhost
  gather_facts: no

Using facts:

 - name: Shut down Debian flavored systems
   ansible.builtin.command: /sbin/shutdown -t now
   when: ansible_facts['os_family'] == "Debian"

TASK [Gathering Facts] *********************************************************************************************************

Related terms[edit]

See also[edit]