Difference between revisions of "Gather facts"

From wikieduonline
Jump to navigation Jump to search
Line 37: Line 37:
 
* Ansible <code>setup</code> module: https://docs.ansible.com/ansible/latest/modules/setup_module.html
 
* Ansible <code>setup</code> module: https://docs.ansible.com/ansible/latest/modules/setup_module.html
 
* {{Ansible modules}}
 
* {{Ansible modules}}
* {{Ansible}}
 
  
 
[[Category:Ansible]]
 
[[Category:Ansible]]
[[Category:Server administration]]
 

Revision as of 11:16, 18 October 2023

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 ]

Example:

#!/usr/bin/env ansible-playbook

- hosts: localhost
  gather_facts: no


Using facts:

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


The following modules failed to execute: ansible.legacy.setup


TASK [Gathering Facts] *********************************************************************************************************
ok: [SERVER_NAME]


Related terms

See also

Advertising: