Skip to main content

setup

setup module

Gather facts about the target host. This module collects system information and makes it available as variables for use in subsequent tasks.

Examples

- name: Gather all facts
setup:

- name: Gather specific facts
setup:
facts:
- hostname
- distribution
- memory

- name: Gather network facts
setup:
facts:
- network

- name: Gather OS information
setup:
facts:
- ansible_distribution
- ansible_distribution_major_version
- ansible_os_family

- name: Use gathered facts
debug:
msg: "Running on {{ ansible_hostname }} ({{ ansible_distribution }} {{ ansible_os_family }})"

Note: The setup module is typically run automatically at the beginning of playbooks. Facts are available as variables prefixed with 'ansible_'.

Module Capabilities

  • Has Revert: false
  • Provides Variables: None

Inputs

ParameterTypeDescriptionRequiredDefaultChoices
facts[string]List of specific fact categories to gather. If not specified, all available facts are collected.falseall factshostname, distribution, memory, network, hardware, system, ansible_distribution, ansible_distribution_major_version, ansible_os_family

Outputs

No outputs.