community.openwrt.setup module – Gather facts about OpenWrt systems

Note

This module is part of the community.openwrt collection (version 1.2.0).

It is not included in ansible-core. To check whether it is installed, run ansible-galaxy collection list.

To install it, use: ansible-galaxy collection install community.openwrt.

To use it in a playbook, specify: community.openwrt.setup.

Synopsis

  • The community.openwrt.setup module gathers facts about OpenWrt systems.

  • It collects system information including distribution details, hostname, network interfaces, services, and device information through ubus.

  • This module is automatically called by playbooks to gather useful variables about remote hosts.

Note

This module has a corresponding action plugin.

Attributes

Attribute

Support

Description

check_mode

Support: full

This action does not modify state.

Can run in check_mode and return changed status prediction without modifying target.

diff_mode

Support: N/A

This action does not modify state.

Returns details on what has changed (or possibly needs changing in check_mode), when in diff mode.

facts

Support: full

Action returns an ansible_facts dictionary that updates existing host facts.

platform

Platform: OpenWrt

Target platform for this module.

Notes

Note

  • This module gathers OpenWrt-specific facts including ubus data for network interfaces, devices, services, and system information.

  • Facts are returned in the ansible_facts namespace.

  • The fact ansible_date_time was added in community.openwrt 1.1.0.

  • The facts ansible_date_time.iso8601_micro and ansible_date_time.iso8601_basic are meant to include microseconds, but the busybox implementation of date does not provide time with that precision, so those facts are reported with 000000 as the value for the microseconds fraction.

  • Note: If you install the package coreutils-date, community.openwrt.setup generates the actual microseconds for ansible_date_time factoids.

  • In ansible.builtin.setup, the fact ansible_date_time.epoch_int is the epoch number, transformed to int, and then back to str, which is ineffective in a shell script. The fact is provided to ensure compatibility with the standard module, but its value is always the same as of ansible_date_time.epoch.

  • Conversely, ansible_date_time.tz_dst is obtained in the standard module through an internal Python function, so in order to provide compatibility, that fact is returned by community.openwrt.setup with the exact same value as ansible_date_time.tz.

Examples

- name: Gather facts from OpenWrt device
  community.openwrt.setup:

- name: Show distribution version
  ansible.builtin.debug:
    msg: "{{ ansible_distribution_version }}"

Returned Facts

Facts returned by this module are added/updated in the hostvars host facts and can be referenced by name just like any other host fact. They do not need to be registered in order to use them.

Key

Description

ansible_date_time

dictionary

System date and time.

Returned: always

ansible_distribution

string

The distribution name.

Returned: always

Sample: "OpenWrt"

ansible_distribution_major_version

string

The major version of the distribution.

Returned: always

Sample: "22"

ansible_distribution_release

string

The distribution release codename.

Returned: always

Sample: ""

ansible_distribution_version

string

The distribution version.

Returned: always

Sample: "22.03.5"

ansible_hostname

string

The hostname of the system.

Returned: always

Sample: "router"

ansible_is_chroot

boolean

Whether the system is running in a chroot.

Returned: always

Sample: false

ansible_os_family

string

The OS family.

Returned: always

Sample: "OpenWrt"

openwrt_board

dictionary

Board information from ubus.

Returned: when available

openwrt_devices

dictionary

Network device status from ubus.

Returned: when available

openwrt_info

dictionary

System information from ubus.

Returned: when available

openwrt_interfaces

dictionary

Network interface status from ubus.

Returned: when available

openwrt_services

dictionary

Service list from ubus.

Returned: when available

openwrt_wireless

dictionary

Wireless status from ubus.

Returned: when available

Authors

  • Markus Weippert (@gekmihesg)