W3cubDocs

/Ansible

avi_api_session - Avi API Module

New in version 2.3.

Synopsis

  • This module can be used for calling any resources defined in Avi REST API. https://avinetworks.com/
  • This module is useful for invoking HTTP Patch methods and accessing resources that do not have an REST object associated with them.

Requirements (on host that executes module)

  • avisdk

Options

parameter required default choices comments
api_version
no
Avi API version of to use for Avi API and objects.
controller
no
IP address or hostname of the controller. The default value is the environment variable AVI_CONTROLLER.
data
no
HTTP body in YAML or JSON format.
http_method
yes
  • get
  • put
  • post
  • patch
  • delete
Allowed HTTP methods for RESTful services and are supported by Avi Controller.
params
no
Query parameters passed to the HTTP API.
password
no
Password of Avi user in Avi controller. The default value is the environment variable AVI_PASSWORD.
path
no
Path for Avi API resource. For example, path: virtualservice will translate to api/virtualserivce.
tenant
no admin
Name of tenant used for all Avi API calls and context of object.
tenant_uuid
no
UUID of tenant used for all Avi API calls and context of object.
timeout
no
Timeout (in seconds) for Avi API calls.
username
no
Username used for accessing Avi controller. The default value is the environment variable AVI_USERNAME.

Examples

- name: Get Pool Information using avi_api_session
  avi_api_session:
    controller: "{{ controller }}"
    username: "{{ username }}"
    password: "{{ password }}"
    http_method: get
    path: pool
    params:
      name: "{{ pool_name }}"
    api_version: 16.4
  register: pool_results

- name: Patch Pool with list of servers
  avi_api_session:
    controller: "{{ controller }}"
    username: "{{ username }}"
    password: "{{ password }}"
    http_method: patch
    path: "{{ pool_path }}"
    api_version: 16.4
    data:
      add:
        servers:
          - ip:
              addr: 10.10.10.10
              type: V4
          - ip:
              addr: 20.20.20.20
              type: V4
  register: updated_pool

- name: Fetch Pool metrics bandwidth and connections rate
  avi_api_session:
    controller: "{{ controller }}"
    username: "{{ username }}"
    password: "{{ password }}"
    http_method: get
    path: analytics/metrics/pool
    api_version: 16.4
    params:
      name: "{{ pool_name }}"
      metric_id: l4_server.avg_bandwidth,l4_server.avg_complete_conns
      step: 300
      limit: 10
  register: pool_metrics

Return Values

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

name description returned type sample
obj
Avi REST resource
success, changed dict

Status

This module is flagged as preview which means that it is not guaranteed to have a backwards compatible interface.

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

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