ansible.builtin.ops_facts (v2.3.3.0-1) — module

Collect device specific facts from OpenSwitch

| "added in version" 2.1 of ansible.builtin"

Authors: Peter Sprygada (@privateip)

preview | supported by community

Install Ansible via pip

Install with pip install ansible==2.3.3.0.post1

Description

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 C(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.

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# 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 }}"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# Collect only the config and default facts
- ops_facts:
    gather_subset: config
    provider: "{{ cli }}"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# Do not collect config facts
- ops_facts:
    gather_subset:
      - "!config"
    provider: "{{ cli }}"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: collect device facts
  ops_facts:
    provider: "{{ cli }}"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: include the config
  ops_facts:
    config: yes
    provider: "{{ rest }}"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: include a set of rest endpoints
  ops_facts:
    endpoints:
      - /system/interfaces/1
      - /system/interfaces/2
    provider: "{{ rest }}"

Inputs

    
host:
    description:
    - 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.
    type: str

port:
    default: 0 (use common port)
    description:
    - Specifies the port to use when building the connection to the remote device.  This
      value applies to either I(cli) or I(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.
    type: int

config:
    choices:
    - true
    - false
    default: false
    description:
    - When enabled, this argument will collect the current running configuration from
      the remote device.  If the C(transport=rest) then the collected configuration will
      be the full system configuration.
    required: false

timeout:
    default: 10
    description:
    - Specifies the timeout in seconds for communicating with the network device for either
      connecting or sending commands.  If the timeout is exceeded before the operation
      is completed, the module will error.
    type: int

use_ssl:
    default: true
    description:
    - Configures the I(transport) to use SSL if set to C(yes) only when the I(transport)
      argument is configured as rest.  If the transport argument is not I(rest), this
      value is ignored.
    type: bool

password:
    description:
    - Specifies the password to use to authenticate the connection to the remote device.  This
      is a common argument used for either I(cli) or I(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 C(ANSIBLE_NET_PASSWORD) will be used instead.
    type: str

provider:
    description:
    - Convenience method that allows all I(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.
    type: dict

username:
    description:
    - 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 C(ANSIBLE_NET_USERNAME)
      will be used instead.
    type: str

endpoints:
    default: null
    description:
    - 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 C(transport=rest).
    required: false

transport:
    choices:
    - cli
    - rest
    - ssh
    default: ssh
    description:
    - 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.
    required: true
    type: str

ssh_keyfile:
    description:
    - Specifies the SSH key to use to authenticate the connection to the remote device.  This
      argument is only used for the I(cli) transports. If the value is not specified in
      the task, the value of environment variable C(ANSIBLE_NET_SSH_KEYFILE) will be used
      instead.
    type: path

gather_subset:
    default: '!config'
    description:
    - 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 C(M(!)) to specify that a specific subset should not be collected.
    required: false
    version_added: '2.2'
    version_added_collection: ansible.builtin

Outputs

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