<title>community.routeros.api_facts module – Collect facts from remote devices running MikroTik RouterOS using the API — Community.Routeros Collection documentation</title>
<linkrel="next"title="community.routeros.api_find_and_modify module – Find and modify information using the API"href="api_find_and_modify_module.html"/>
<linkrel="prev"title="community.routeros.api module – Ansible module for RouterOS API"href="api_module.html"/><!-- extra head elements for Ansible beyond RTD Sphinx Theme -->
</head>
<bodyclass="wy-body-for-nav"><!-- extra body elements for Ansible beyond RTD Sphinx Theme -->
<liclass="toctree-l1"><aclass="reference internal"href="api_find_and_modify_module.html">community.routeros.api_find_and_modify module – Find and modify information using the API</a></li>
<liclass="toctree-l1"><aclass="reference internal"href="api_info_module.html">community.routeros.api_info module – Retrieve information from API</a></li>
<liclass="toctree-l1"><aclass="reference internal"href="api_modify_module.html">community.routeros.api_modify module – Modify data at paths with API</a></li>
<liclass="toctree-l1"><aclass="reference internal"href="command_module.html">community.routeros.command module – Run commands on remote devices running MikroTik RouterOS</a></li>
<liclass="toctree-l1"><aclass="reference internal"href="routeros_cliconf.html">community.routeros.routeros cliconf – Use routeros cliconf to run command on MikroTik RouterOS platform</a></li>
</ul>
<ul>
<liclass="toctree-l1"><aclass="reference internal"href="join_filter.html">community.routeros.join filter – Join a list of arguments to a command</a></li>
<liclass="toctree-l1"><aclass="reference internal"href="list_to_dict_filter.html">community.routeros.list_to_dict filter – Convert a list of arguments to a dictionary</a></li>
<liclass="toctree-l1"><aclass="reference internal"href="quote_argument_filter.html">community.routeros.quote_argument filter – Quote an argument</a></li>
<liclass="toctree-l1"><aclass="reference internal"href="quote_argument_value_filter.html">community.routeros.quote_argument_value filter – Quote an argument value</a></li>
<liclass="toctree-l1"><aclass="reference internal"href="split_filter.html">community.routeros.split filter – Split a command into arguments</a></li>
<liclass="breadcrumb-item active">community.routeros.api_facts module – Collect facts from remote devices running MikroTik RouterOS using the API</li>
<liclass="wy-breadcrumbs-aside">
<!-- User defined GitHub URL -->
<ahref="https://github.com/ansible-collections/community.routeros/edit/main/plugins/modules/api_facts.py?description=%23%23%23%23%23%20SUMMARY%0A%3C!—%20Your%20description%20here%20–%3E%0A%0A%0A%23%23%23%23%23%20ISSUE%20TYPE%0A-%20Docs%20Pull%20Request%0A%0A%2Blabel:%20docsite_pr"class="fa fa-github"> Edit on GitHub</a>
<h1>community.routeros.api_facts module – Collect facts from remote devices running MikroTik RouterOS using the API<aclass="headerlink"href="#community-routeros-api-facts-module-collect-facts-from-remote-devices-running-mikrotik-routeros-using-the-api"title="Permalink to this heading"></a></h1>
<p>This module is part of the <aclass="reference external"href="https://galaxy.ansible.com/community/routeros">community.routeros collection</a> (version 2.8.2).</p>
You need further requirements to be able to use this module,
see <aclass="reference internal"href="#ansible-collections-community-routeros-api-facts-module-requirements"><spanclass="std std-ref">Requirements</span></a> for details.</p>
<p>To use it in a playbook, specify: <codeclass="code docutils literal notranslate"><spanclass="pre">community.routeros.api_facts</span></code>.</p>
</div>
<pclass="ansible-version-added">New in community.routeros 2.1.0</p>
<li><p>Collects a base set of device facts from a remote device that is running RouterOS. This module prepends all of the base network fact keys with <codeclass="docutils literal notranslate"><spanclass="pre">ansible_net_<fact></span></code>. The facts module will always collect a base set of facts from the device and can enable or disable collection of additional facts.</p></li>
<li><p>As opposed to the <aclass="reference internal"href="facts_module.html#ansible-collections-community-routeros-facts-module"><spanclass="std std-ref">community.routeros.facts</span></a> module, it uses the RouterOS API, similar to the <aclass="reference internal"href="api_module.html#ansible-collections-community-routeros-api-module"><spanclass="std std-ref">community.routeros.api</span></a> module.</p></li>
<spanid="ansible-collections-community-routeros-api-facts-module-requirements"></span><h2><aclass="toc-backref"href="#id2"role="doc-backlink">Requirements</a><aclass="headerlink"href="#requirements"title="Permalink to this heading"></a></h2>
<h2><aclass="toc-backref"href="#id3"role="doc-backlink">Parameters</a><aclass="headerlink"href="#parameters"title="Permalink to this heading"></a></h2>
<aclass="ansibleOptionLink"href="#parameter-ca_path"title="Permalink to this option"></a><pclass="ansible-option-type-line"><spanclass="ansible-option-type">path</span></p>
<p><spanclass="ansible-option-versionadded">added in community.routeros 1.2.0</span></p>
</div></td>
<td><divclass="ansible-option-cell"><p>PEM formatted file that contains a CA certificate to be used for certificate validation.</p>
<p>See also <codeclass="ansible-option docutils literal notranslate"><strong><aclass="reference internal"href="#ansible-collections-community-routeros-api-facts-module-parameter-validate-cert-hostname"><spanclass="std std-ref"><spanclass="pre">validate_cert_hostname</span></span></a></strong></code>. Only used when <codeclass="ansible-option-value docutils literal notranslate"><aclass="reference internal"href="#ansible-collections-community-routeros-api-facts-module-parameter-tls"><spanclass="std std-ref"><spanclass="pre">tls=true</span></span></a></code> and <codeclass="ansible-option-value docutils literal notranslate"><aclass="reference internal"href="#ansible-collections-community-routeros-api-facts-module-parameter-validate-certs"><spanclass="std std-ref"><spanclass="pre">validate_certs=true</span></span></a></code>.</p>
<aclass="ansibleOptionLink"href="#parameter-encoding"title="Permalink to this option"></a><pclass="ansible-option-type-line"><spanclass="ansible-option-type">string</span></p>
<p><spanclass="ansible-option-versionadded">added in community.routeros 2.1.0</span></p>
</div></td>
<td><divclass="ansible-option-cell"><p>Use the specified encoding when communicating with the RouterOS device.</p>
<aclass="ansibleOptionLink"href="#parameter-force_no_cert"title="Permalink to this option"></a><pclass="ansible-option-type-line"><spanclass="ansible-option-type">boolean</span></p>
<p><spanclass="ansible-option-versionadded">added in community.routeros 2.4.0</span></p>
<td><divclass="ansible-option-cell"><p>Set to <codeclass="ansible-value docutils literal notranslate"><spanclass="pre">true</span></code> to connect without a certificate when <codeclass="ansible-option-value docutils literal notranslate"><aclass="reference internal"href="#ansible-collections-community-routeros-api-facts-module-parameter-tls"><spanclass="std std-ref"><spanclass="pre">tls=true</span></span></a></code>.</p>
<p>See also <codeclass="ansible-option docutils literal notranslate"><strong><aclass="reference internal"href="#ansible-collections-community-routeros-api-facts-module-parameter-validate-certs"><spanclass="std std-ref"><spanclass="pre">validate_certs</span></span></a></strong></code>.</p>
<p><strong>Note:</strong> this forces the use of anonymous Diffie-Hellman (ADH) ciphers. The protocol is susceptible to Man-in-the-Middle attacks, because the keys used in the exchange are not authenticated. Instead of simply connecting without a certificate to “make things work” have a look at <codeclass="ansible-option docutils literal notranslate"><strong><aclass="reference internal"href="#ansible-collections-community-routeros-api-facts-module-parameter-validate-certs"><spanclass="std std-ref"><spanclass="pre">validate_certs</span></span></a></strong></code> and <codeclass="ansible-option docutils literal notranslate"><strong><aclass="reference internal"href="#ansible-collections-community-routeros-api-facts-module-parameter-ca-path"><spanclass="std std-ref"><spanclass="pre">ca_path</span></span></a></strong></code>.</p>
<aclass="ansibleOptionLink"href="#parameter-gather_subset"title="Permalink to this option"></a><pclass="ansible-option-type-line"><spanclass="ansible-option-type">list</span> / <spanclass="ansible-option-elements">elements=string</span></p>
<td><divclass="ansible-option-cell"><p>When supplied, this argument will restrict the facts collected to a given subset. Possible values for this argument include <codeclass="ansible-value docutils literal notranslate"><spanclass="pre">all</span></code>, <codeclass="ansible-value docutils literal notranslate"><spanclass="pre">hardware</span></code>, <codeclass="ansible-value docutils literal notranslate"><spanclass="pre">interfaces</span></code>, and <codeclass="ansible-value docutils literal notranslate"><spanclass="pre">routing</span></code>.</p>
<p>Can specify a list of values to include a larger subset. Values can also be used with an initial <codeclass="ansible-value docutils literal notranslate"><spanclass="pre">!</span></code> to specify that a specific subset should not be collected.</p>
<aclass="ansibleOptionLink"href="#parameter-hostname"title="Permalink to this option"></a><pclass="ansible-option-type-line"><spanclass="ansible-option-type">string</span> / <spanclass="ansible-option-required">required</span></p>
<aclass="ansibleOptionLink"href="#parameter-password"title="Permalink to this option"></a><pclass="ansible-option-type-line"><spanclass="ansible-option-type">string</span> / <spanclass="ansible-option-required">required</span></p>
</div></td>
<td><divclass="ansible-option-cell"><p>RouterOS user password.</p>
<aclass="ansibleOptionLink"href="#parameter-port"title="Permalink to this option"></a><pclass="ansible-option-type-line"><spanclass="ansible-option-type">integer</span></p>
<td><divclass="ansible-option-cell"><p>RouterOS api port. If <codeclass="ansible-option docutils literal notranslate"><strong><aclass="reference internal"href="#ansible-collections-community-routeros-api-facts-module-parameter-tls"><spanclass="std std-ref"><spanclass="pre">tls</span></span></a></strong></code> is set, port will apply to TLS/SSL connection.</p>
<p>Defaults are <codeclass="ansible-value docutils literal notranslate"><spanclass="pre">8728</span></code> for the HTTP API, and <codeclass="ansible-value docutils literal notranslate"><spanclass="pre">8729</span></code> for the HTTPS API.</p>
<aclass="ansibleOptionLink"href="#parameter-timeout"title="Permalink to this option"></a><pclass="ansible-option-type-line"><spanclass="ansible-option-type">integer</span></p>
<p><spanclass="ansible-option-versionadded">added in community.routeros 2.3.0</span></p>
</div></td>
<td><divclass="ansible-option-cell"><p>Timeout for the request.</p>
<aclass="ansibleOptionLink"href="#parameter-tls"title="Permalink to this option"></a><pclass="ansible-option-type-line"><spanclass="ansible-option-aliases">aliases: ssl</span></p>
<aclass="ansibleOptionLink"href="#parameter-username"title="Permalink to this option"></a><pclass="ansible-option-type-line"><spanclass="ansible-option-type">string</span> / <spanclass="ansible-option-required">required</span></p>
<aclass="ansibleOptionLink"href="#parameter-validate_cert_hostname"title="Permalink to this option"></a><pclass="ansible-option-type-line"><spanclass="ansible-option-type">boolean</span></p>
<p><spanclass="ansible-option-versionadded">added in community.routeros 1.2.0</span></p>
<td><divclass="ansible-option-cell"><p>Set to <codeclass="ansible-value docutils literal notranslate"><spanclass="pre">true</span></code> to validate hostnames in certificates.</p>
<p>See also <codeclass="ansible-option docutils literal notranslate"><strong><aclass="reference internal"href="#ansible-collections-community-routeros-api-facts-module-parameter-validate-certs"><spanclass="std std-ref"><spanclass="pre">validate_certs</span></span></a></strong></code>. Only used when <codeclass="ansible-option-value docutils literal notranslate"><aclass="reference internal"href="#ansible-collections-community-routeros-api-facts-module-parameter-tls"><spanclass="std std-ref"><spanclass="pre">tls=true</span></span></a></code> and <codeclass="ansible-option-value docutils literal notranslate"><aclass="reference internal"href="#ansible-collections-community-routeros-api-facts-module-parameter-validate-certs"><spanclass="std std-ref"><spanclass="pre">validate_certs=true</span></span></a></code>.</p>
<aclass="ansibleOptionLink"href="#parameter-validate_certs"title="Permalink to this option"></a><pclass="ansible-option-type-line"><spanclass="ansible-option-type">boolean</span></p>
<p><spanclass="ansible-option-versionadded">added in community.routeros 1.2.0</span></p>
<td><divclass="ansible-option-cell"><p>Set to <codeclass="ansible-value docutils literal notranslate"><spanclass="pre">false</span></code> to skip validation of TLS certificates.</p>
<p>See also <codeclass="ansible-option docutils literal notranslate"><strong><aclass="reference internal"href="#ansible-collections-community-routeros-api-facts-module-parameter-validate-cert-hostname"><spanclass="std std-ref"><spanclass="pre">validate_cert_hostname</span></span></a></strong></code>. Only used when <codeclass="ansible-option-value docutils literal notranslate"><aclass="reference internal"href="#ansible-collections-community-routeros-api-facts-module-parameter-tls"><spanclass="std std-ref"><spanclass="pre">tls=true</span></span></a></code>.</p>
<p><strong>Note:</strong> instead of simply deactivating certificate validations to “make things work”, please consider creating your own CA certificate and using it to sign certificates used for your router. You can tell the module about your CA certificate with the <codeclass="ansible-option docutils literal notranslate"><strong><aclass="reference internal"href="#ansible-collections-community-routeros-api-facts-module-parameter-ca-path"><spanclass="std std-ref"><spanclass="pre">ca_path</span></span></a></strong></code> option.</p>
<h2><aclass="toc-backref"href="#id4"role="doc-backlink">Attributes</a><aclass="headerlink"href="#attributes"title="Permalink to this heading"></a></h2>
<td><divclass="ansible-option-cell"><p>Use <codeclass="docutils literal notranslate"><spanclass="pre">group/community.routeros.api</span></code> in <codeclass="docutils literal notranslate"><spanclass="pre">module_defaults</span></code> to set defaults for this module.</p>
<td><divclass="ansible-option-cell"><p>Can run in <codeclass="docutils literal notranslate"><spanclass="pre">check_mode</span></code> and return changed status prediction without modifying target.</p>
<td><divclass="ansible-option-cell"><p>Will return details on what has changed (or possibly needs changing in <codeclass="docutils literal notranslate"><spanclass="pre">check_mode</span></code>), when in diff mode.</p>
<td><divclass="ansible-option-cell"><p>Action returns an <codeclass="docutils literal notranslate"><spanclass="pre">ansible_facts</span></code> dictionary that will update existing host facts.</p>
<dt><aclass="reference internal"href="api_find_and_modify_module.html#ansible-collections-community-routeros-api-find-and-modify-module"><spanclass="std std-ref">community.routeros.api_find_and_modify</span></a></dt><dd><p>Find and modify information using the API.</p>
<dt><aclass="reference internal"href="api_info_module.html#ansible-collections-community-routeros-api-info-module"><spanclass="std std-ref">community.routeros.api_info</span></a></dt><dd><p>Retrieve information from API.</p>
<dt><aclass="reference internal"href="api_modify_module.html#ansible-collections-community-routeros-api-modify-module"><spanclass="std std-ref">community.routeros.api_modify</span></a></dt><dd><p>Modify data at paths with API.</p>
<dt><aclass="reference internal"href="docsite/api-guide.html#ansible-collections-community-routeros-docsite-api-guide"><spanclass="std std-ref">How to connect to RouterOS devices with the RouterOS API</span></a></dt><dd><p>How to connect to RouterOS devices with the RouterOS API</p>
<divclass="highlight-yaml+jinja notranslate"><divclass="highlight"><pre><span></span><spanclass="p p-Indicator">-</span><spanclass="w"></span><spanclass="nt">name</span><spanclass="p">:</span><spanclass="w"></span><spanclass="l l-Scalar l-Scalar-Plain">Collect all facts from the device</span>
<h2><aclass="toc-backref"href="#id7"role="doc-backlink">Returned Facts</a><aclass="headerlink"href="#returned-facts"title="Permalink to this heading"></a></h2>
<p>Facts returned by this module are added/updated in the <codeclass="docutils literal notranslate"><spanclass="pre">hostvars</span></code> 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.</p>
<aclass="ansibleOptionLink"href="#return-ansible_facts/ansible_net_all_ipv4_addresses"title="Permalink to this return value"></a><pclass="ansible-option-type-line"><spanclass="ansible-option-type">list</span> / <spanclass="ansible-option-elements">elements=string</span></p>
</div></td>
<td><divclass="ansible-option-cell"><p>All IPv4 addresses configured on the device.</p>
<aclass="ansibleOptionLink"href="#return-ansible_facts/ansible_net_all_ipv6_addresses"title="Permalink to this return value"></a><pclass="ansible-option-type-line"><spanclass="ansible-option-type">list</span> / <spanclass="ansible-option-elements">elements=string</span></p>
</div></td>
<td><divclass="ansible-option-cell"><p>All IPv6 addresses configured on the device.</p>
<aclass="ansibleOptionLink"href="#return-ansible_facts/ansible_net_arch"title="Permalink to this return value"></a><pclass="ansible-option-type-line"><spanclass="ansible-option-type">string</span></p>
</div></td>
<td><divclass="ansible-option-cell"><p>The CPU architecture of the device.</p>
<aclass="ansibleOptionLink"href="#return-ansible_facts/ansible_net_bgp_instance"title="Permalink to this return value"></a><pclass="ansible-option-type-line"><spanclass="ansible-option-type">dictionary</span></p>
</div></td>
<td><divclass="ansible-option-cell"><p>A dictionary with BGP instance information.</p>
<aclass="ansibleOptionLink"href="#return-ansible_facts/ansible_net_bgp_peer"title="Permalink to this return value"></a><pclass="ansible-option-type-line"><spanclass="ansible-option-type">dictionary</span></p>
</div></td>
<td><divclass="ansible-option-cell"><p>A dictionary with BGP peer information.</p>
<aclass="ansibleOptionLink"href="#return-ansible_facts/ansible_net_bgp_vpnv4_route"title="Permalink to this return value"></a><pclass="ansible-option-type-line"><spanclass="ansible-option-type">dictionary</span></p>
</div></td>
<td><divclass="ansible-option-cell"><p>A dictionary with BGP vpnv4 route information.</p>
<aclass="ansibleOptionLink"href="#return-ansible_facts/ansible_net_cpu_load"title="Permalink to this return value"></a><pclass="ansible-option-type-line"><spanclass="ansible-option-type">string</span></p>
</div></td>
<td><divclass="ansible-option-cell"><p>Current CPU load.</p>
<aclass="ansibleOptionLink"href="#return-ansible_facts/ansible_net_gather_subset"title="Permalink to this return value"></a><pclass="ansible-option-type-line"><spanclass="ansible-option-type">list</span> / <spanclass="ansible-option-elements">elements=string</span></p>
</div></td>
<td><divclass="ansible-option-cell"><p>The list of fact subsets collected from the device.</p>
<aclass="ansibleOptionLink"href="#return-ansible_facts/ansible_net_hostname"title="Permalink to this return value"></a><pclass="ansible-option-type-line"><spanclass="ansible-option-type">string</span></p>
</div></td>
<td><divclass="ansible-option-cell"><p>The configured hostname of the device.</p>
<aclass="ansibleOptionLink"href="#return-ansible_facts/ansible_net_interfaces"title="Permalink to this return value"></a><pclass="ansible-option-type-line"><spanclass="ansible-option-type">dictionary</span></p>
</div></td>
<td><divclass="ansible-option-cell"><p>A hash of all interfaces running on the system.</p>
<aclass="ansibleOptionLink"href="#return-ansible_facts/ansible_net_memfree_mb"title="Permalink to this return value"></a><pclass="ansible-option-type-line"><spanclass="ansible-option-type">integer</span></p>
</div></td>
<td><divclass="ansible-option-cell"><p>The available free memory on the remote device in MiB.</p>
<aclass="ansibleOptionLink"href="#return-ansible_facts/ansible_net_memtotal_mb"title="Permalink to this return value"></a><pclass="ansible-option-type-line"><spanclass="ansible-option-type">integer</span></p>
</div></td>
<td><divclass="ansible-option-cell"><p>The total memory on the remote device in MiB.</p>
<aclass="ansibleOptionLink"href="#return-ansible_facts/ansible_net_model"title="Permalink to this return value"></a><pclass="ansible-option-type-line"><spanclass="ansible-option-type">string</span></p>
</div></td>
<td><divclass="ansible-option-cell"><p>The model name returned from the device.</p>
<aclass="ansibleOptionLink"href="#return-ansible_facts/ansible_net_neighbors"title="Permalink to this return value"></a><pclass="ansible-option-type-line"><spanclass="ansible-option-type">dictionary</span></p>
</div></td>
<td><divclass="ansible-option-cell"><p>The list of neighbors from the remote device.</p>
<aclass="ansibleOptionLink"href="#return-ansible_facts/ansible_net_ospf_instance"title="Permalink to this return value"></a><pclass="ansible-option-type-line"><spanclass="ansible-option-type">dictionary</span></p>
</div></td>
<td><divclass="ansible-option-cell"><p>A dictionary with OSPF instances.</p>
<aclass="ansibleOptionLink"href="#return-ansible_facts/ansible_net_ospf_neighbor"title="Permalink to this return value"></a><pclass="ansible-option-type-line"><spanclass="ansible-option-type">dictionary</span></p>
</div></td>
<td><divclass="ansible-option-cell"><p>A dictionary with OSPF neighbors.</p>
<aclass="ansibleOptionLink"href="#return-ansible_facts/ansible_net_route"title="Permalink to this return value"></a><pclass="ansible-option-type-line"><spanclass="ansible-option-type">dictionary</span></p>
</div></td>
<td><divclass="ansible-option-cell"><p>A dictionary for routes in all routing tables.</p>
<aclass="ansibleOptionLink"href="#return-ansible_facts/ansible_net_serialnum"title="Permalink to this return value"></a><pclass="ansible-option-type-line"><spanclass="ansible-option-type">string</span></p>
</div></td>
<td><divclass="ansible-option-cell"><p>The serial number of the remote device.</p>
<aclass="ansibleOptionLink"href="#return-ansible_facts/ansible_net_spacefree_mb"title="Permalink to this return value"></a><pclass="ansible-option-type-line"><spanclass="ansible-option-type">dictionary</span></p>
</div></td>
<td><divclass="ansible-option-cell"><p>The available disk space on the remote device in MiB.</p>
<aclass="ansibleOptionLink"href="#return-ansible_facts/ansible_net_spacetotal_mb"title="Permalink to this return value"></a><pclass="ansible-option-type-line"><spanclass="ansible-option-type">dictionary</span></p>
</div></td>
<td><divclass="ansible-option-cell"><p>The total disk space on the remote device in MiB.</p>
<aclass="ansibleOptionLink"href="#return-ansible_facts/ansible_net_uptime"title="Permalink to this return value"></a><pclass="ansible-option-type-line"><spanclass="ansible-option-type">string</span></p>
</div></td>
<td><divclass="ansible-option-cell"><p>The uptime of the device.</p>
<aclass="ansibleOptionLink"href="#return-ansible_facts/ansible_net_version"title="Permalink to this return value"></a><pclass="ansible-option-type-line"><spanclass="ansible-option-type">string</span></p>
</div></td>
<td><divclass="ansible-option-cell"><p>The operating system version running on the remote device.</p>
<ahref="https://github.com/ansible-collections/community.routeros/issues/new?assignees=&labels=&template=bug_report.md"aria-role="button"target="_blank"rel="noopener external">Submit a bug report</a>
<ahref="https://github.com/ansible-collections/community.routeros/issues/new?assignees=&labels=&template=feature_request.md"aria-role="button"target="_blank"rel="noopener external">Request a feature</a>
<ahref="api_find_and_modify_module.html"class="btn btn-neutral float-right"title="community.routeros.api_find_and_modify module – Find and modify information using the API"accesskey="n"rel="next">Next <spanclass="fa fa-arrow-circle-right"aria-hidden="true"></span></a>