W3cubDocs

/Ansible

cisco.mso.mso_rest – Direct access to the Cisco MSO REST API

Note

This plugin is part of the cisco.mso collection (version 1.2.0).

You might already have this collection installed if you are using the ansible package. 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 cisco.mso.

To use it in a playbook, specify: cisco.mso.mso_rest.

Synopsis

  • Enables the management of the Cisco MSO fabric through direct access to the Cisco MSO REST API.
  • This module is not idempotent and does not report changes.

Requirements

The below requirements are needed on the host that executes this module.

  • Multi Site Orchestrator v2.1 or newer

Parameters

Parameter Choices/Defaults Comments
content
raw
Sets the payload of the API request directly.
This may be convenient to template simple requests.
For anything complex use the template lookup plugin (see examples).

aliases: payload
host
string
IP Address or hostname of the ACI Multi Site Orchestrator host.
If the value is not specified in the task, the value of environment variable MSO_HOST will be used instead.

aliases: hostname
login_domain
string
The login domain name to use for authentication.
The default value is Local.
If the value is not specified in the task, the value of environment variable MSO_LOGIN_DOMAIN will be used instead.
method
string
    Choices:
  • delete
  • get
  • post
  • put
  • patch
The HTTP method of the request.
Using delete is typically used for deleting objects.
Using get is typically used for querying objects.
Using post is typically used for modifying objects.
Using put is typically used for modifying existing objects.
Using patch is typically also used for modifying existing objects.

aliases: action
output_level
string
    Choices:
  • debug
  • info
  • normal
Influence the output of this MSO module.
normal means the standard output, incl. current dict
info adds informational output, incl. previous, proposed and sent dicts
debug adds debugging output, incl. filter_string, method, response, status and url information
If the value is not specified in the task, the value of environment variable MSO_OUTPUT_LEVEL will be used instead.
password
string
The password to use for authentication.
If the value is not specified in the task, the value of environment variables MSO_PASSWORD or ANSIBLE_NET_PASSWORD will be used instead.
path
string / required
URI being used to execute API calls.

aliases: uri
port
integer
Port number to be used for the REST connection.
The default value depends on parameter `use_ssl`.
If the value is not specified in the task, the value of environment variable MSO_PORT will be used instead.
timeout
integer
Default:
30
The socket level timeout in seconds.
If the value is not specified in the task, the value of environment variable MSO_TIMEOUT will be used instead.
use_proxy
boolean
    Choices:
  • no
  • yes
If no, it will not use a proxy, even if one is defined in an environment variable on the target hosts.
If the value is not specified in the task, the value of environment variable MSO_USE_PROXY will be used instead.
use_ssl
boolean
    Choices:
  • no
  • yes
If no, an HTTP connection will be used instead of the default HTTPS connection.
If the value is not specified in the task, the value of environment variable MSO_USE_SSL will be used instead.
username
string
Default:
"admin"
The username to use for authentication.
If the value is not specified in the task, the value of environment variables MSO_USERNAME or ANSIBLE_NET_USERNAME will be used instead.
validate_certs
boolean
    Choices:
  • no
  • yes
If no, SSL certificates will not be validated.
This should only set to no when used on personally controlled sites using self-signed certificates.
If the value is not specified in the task, the value of environment variable MSO_VALIDATE_CERTS will be used instead.

Notes

Note

  • Most payloads are known not to be idempotent, so be careful when constructing payloads.
  • Please read the mso_guide for more detailed information on how to manage your MSO infrastructure using Ansible.
  • This module was written to support Multi Site Orchestrator v2.1 or newer. Some or all functionality may not work on earlier versions.

See Also

See also

cisco.mso.mso_tenant

The official documentation on the cisco.mso.mso_tenant module.

Examples

- name: Add schema (JSON)
  cisco.mso.mso_rest:
    host: mso
    username: admin
    password: SomeSecretPassword
    path: /mso/api/v1/schemas
    method: post
    content:
      {
          "displayName": "{{ mso_schema | default('ansible_test') }}",
          "templates": [{
              "name": "Template_1",
              "tenantId": "{{ add_tenant.jsondata.id }}",
              "displayName": "Template_1",
              "templateSubType": [],
              "templateType": "stretched-template",
              "anps": [],
              "contracts": [],
              "vrfs": [],
              "bds": [],
              "filters": [],
              "externalEpgs": [],
              "serviceGraphs": [],
              "intersiteL3outs": []
          }],
          "sites": [],
          "_updateVersion": 0
      }
  delegate_to: localhost

- name: Query schema
  cisco.mso.mso_rest:
    host: mso
    username: admin
    password: SomeSecretPassword
    path: /mso/api/v1/schemas
    method: get
  delegate_to: localhost

- name: Patch schema (YAML)
  cisco.mso.mso_rest:
    host: mso
    username: admin
    password: SomeSecretPassword
    path: "/mso/api/v1/schemas/{{ add_schema.jsondata.id }}"
    method: patch
    content:
      - op: add
        path: /templates/Template_1/anps/-
        value:
          name: AP2
          displayName: AP2
          epgs: []
        _updateVersion: 0
  delegate_to: localhost

- name: Add a tenant from a templated payload file from templates
  cisco.mso.mso_rest:
    host: mso
    username: admin
    password: SomeSecretPassword
    method: post
    path: /api/v1/tenants
    content: "{{ lookup('template', 'mso/tenant.json.j2') }}"
  delegate_to: localhost

Authors

  • Anvitha Jain (@anvitha-jain)

© 2012–2018 Michael DeHaan
© 2018–2021 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/latest/collections/cisco/mso/mso_rest_module.html