W3cubDocs

/Ansible

ops_facts - Collect device specific facts from OpenSwitch

New in version 2.1.

Synopsis

Collects facts from devices running the OpenSwitch operating system. Fact collection is supported over both Cli and Rest transports. This module prepends all of the base network fact keys with ansible_net_<fact>. The facts module will always collect a base set of facts from the device and can enable or disable collection of additional facts. The facts collected from pre Ansible 2.2 are still available and are collected for backwards compatibility; however, these facts should be considered deprecated and will be removed in a future release.

Options

parameter required default choices comments
config
no
  • True
  • False
When enabled, this argument will collect the current running configuration from the remote device. If the transport=rest then the collected configuration will be the full system configuration.
endpoints
no
Accepts a list of endpoints to retrieve from the remote device using the REST API. The endpoints should be valid endpoints available on the device. This argument is only valid when the transport=rest.
gather_subset
(added in 2.2)
no !config
When supplied, this argument will restrict the facts collected to a given subset. Possible values for this argument include all, hardware, config, legacy, and interfaces. Can specify a list of values to include a larger subset. Values can also be used with an initial ! to specify that a specific subset should not be collected.
host
yes
Specifies the DNS host name or address for connecting to the remote device over the specified transport. The value of host is used as the destination address for the transport. Note this argument does not affect the SSH argument.
password
no
Specifies the password to use to authenticate the connection to the remote device. This is a common argument used for either cli or rest transports. Note this argument does not affect the SSH transport. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_PASSWORD will be used instead.
port
no 0 (use common port)
Specifies the port to use when building the connection to the remote device. This value applies to either cli or rest. The port value will default to the appropriate transport common port if none is provided in the task. (cli=22, http=80, https=443). Note this argument does not affect the SSH transport.
provider
no
Convenience method that allows all openswitch arguments to be passed as a dict object. All constraints (required, choices, etc) must be met either by individual arguments or values in this dict.
ssh_keyfile
no
Specifies the SSH key to use to authenticate the connection to the remote device. This argument is only used for the cli transports. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_SSH_KEYFILE will be used instead.
transport
yes ssh
  • ssh
  • cli
  • rest
Configures the transport connection to use when connecting to the remote device. The transport argument supports connectivity to the device over ssh, cli or REST.
use_ssl
no True
  • yes
  • no
Configures the transport to use SSL if set to true only when the transport argument is configured as rest. If the transport argument is not rest, this value is ignored.
username
no
Configures the username to use to authenticate the connection to the remote device. This value is used to authenticate either the CLI login or the eAPI authentication depending on which transport is used. Note this argument does not affect the SSH transport. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_USERNAME will be used instead.

Examples

# Note: examples below use the following provider dict to handle
#       transport and authentication to the node.
vars:
  cli:
    host: "{{ inventory_hostname }}"
    username: netop
    password: netop
    transport: cli
  rest:
    host: "{{ inventory_hostname }}"
    username: netop
    password: netop
    transport: rest

- ops_facts:
    gather_subset: all
    provider: "{{ rest }}"

# Collect only the config and default facts
- ops_facts:
    gather_subset: config
    provider: "{{ cli }}"

# Do not collect config facts
- ops_facts:
    gather_subset:
      - "!config"
    provider: "{{ cli }}"

- name: collect device facts
  ops_facts:
    provider: "{{ cli }}"

- name: include the config
  ops_facts:
    config: yes
    provider: "{{ rest }}"

- name: include a set of rest endpoints
  ops_facts:
    endpoints:
      - /system/interfaces/1
      - /system/interfaces/2
    provider: "{{ rest }}"

Return Values

Common return values are documented here Common Return Values, the following are the fields unique to this module:

name description returned type sample
ansible_net_model The model name returned from the device when transport is cli str
ansible_net_hostname The configured hostname of the device always string
ansible_net_config The current active config from the device when config is enabled str
ansible_net_serialnum The serial number of the remote device when transport is cli str
ansible_net_gather_subset The list of fact subsets collected from the device always list
ansible_net_version The operating system version running on the remote device always str
version The current version of OpenSwitch always string 0.3.0
endpoints The JSON response from the URL endpoint when endpoints argument is defined and transport is rest list [{'....': None}, {'....': None}]
config The current system configuration when enabled string ....
hostname returns the configured hostname always string ops01
ansible_net_image The image file the device is running when transport is cli string

This is a Core Module

For more information on what this means please read Core Modules

For help in developing on modules, should you be so inclined, please read Community Information & Contributing, developing_test_pr and Developing Modules.

© 2012–2016 Michael DeHaan
© 2016 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/ops_facts_module.html