Note
This module is part of the cisco.aci collection (version 2.12.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.aci. You need further requirements to be able to use this module, see Requirements for details.
To use it in a playbook, specify: cisco.aci.aci_rest.
The below requirements are needed on the host that executes this module.
Parameter | Comments |
|---|---|
annotation string | User-defined string for annotating an object. If the value is not specified in the task, the value of environment variable If the value is not specified in the task and environment variable Default: |
certificate_name aliases: cert_name string | The X.509 certificate name attached to the APIC AAA user used for signature-based authentication. If a If PEM-formatted content was provided for If the value is not specified in the task, the value of environment variable |
content any | When used instead of This may be convenient to template simple requests. For anything complex use the |
host aliases: hostname string | IP Address or hostname of APIC resolvable by Ansible control host. If the value is not specified in the task, the value of environment variable |
method aliases: action string | The HTTP method of the request. Using Using Using Choices:
|
output_level string | Influence the output of this ACI module.
If the value is not specified in the task, the value of environment variable Choices:
|
output_path string | Path to a file that will be used to dump the ACI JSON configuration objects generated by the module. If the value is not specified in the task, the value of environment variable |
page integer | The page number to return. |
page_size integer | The number of items to return in a single page. |
password string | The password to use for authentication. This option is mutual exclusive with If the value is not specified in the task, the value of environment variables |
path aliases: uri string / required | URI being used to execute API calls. Must end in |
port integer | Port number to be used for REST connection. The default value depends on parameter If the value is not specified in the task, the value of environment variable |
private_key aliases: cert_key string | Either a PEM-formatted private key file or the private key content used for signature-based authentication. This value also influences the default This option is mutual exclusive with If the value is not specified in the task, the value of environment variable |
rsp_subtree_preserve boolean | Preserve the response for the provided path. Choices:
|
src aliases: config_file path | Name of the absolute path of the filename that includes the body of the HTTP request being sent to the ACI fabric. If you require a templated payload, use the |
suppress_previous aliases: no_previous, ignore_previous boolean | If If the value is not specified in the task, the value of environment variable The default value is WARNING - This causes the previous return value to be empty. The previous state of the object will not be checked and the POST update will contain all properties. Choices:
|
suppress_verification aliases: no_verification, no_verify, suppress_verify, ignore_verify, ignore_verification boolean | If If the value is not specified in the task, the value of environment variable The default value is WARNING - This causes the current return value to be set to the proposed value. The current object including default values will be unverifiable in a single task. Choices:
|
timeout integer | The socket level timeout in seconds. If the value is not specified in the task, the value of environment variable The default value is 30. |
use_proxy boolean | If If the value is not specified in the task, the value of environment variable The default value is true. Choices:
|
use_ssl boolean | If If the value is not specified in the task, the value of environment variable The default value is true when the connection is local. Choices:
|
username aliases: user string | The username to use for authentication. If the value is not specified in the task, the value of environment variables The default value is admin. |
validate_certs boolean | If This should only set to If the value is not specified in the task, the value of environment variable The default value is true. Choices:
|
Note
status="created" will cause idempotency issues, use status="modified" instead. More information in :ref:`the ACI documentation <aci_guide_known_issues>`.lxml and xmljson python libraries. For JSON payloads nothing special is needed.content will take precedent over the annotation parameter.See also
Manage tenants (fv:Tenant).
More information about the APIC REST API.
Detailed information on how to manage your ACI infrastructure using Ansible.
Detailed guide on how to write your own Cisco ACI modules to contribute.
- name: Add a tenant using certificate authentication
cisco.aci.aci_rest:
host: apic
username: admin
private_key: pki/admin.key
method: post
path: /api/mo/uni.xml
src: /home/cisco/ansible/aci/configs/aci_config.xml
delegate_to: localhost
- name: Add a tenant from a templated payload file from templates/
cisco.aci.aci_rest:
host: apic
username: admin
private_key: pki/admin.key
method: post
path: /api/mo/uni.xml
content: "{{ lookup('template', 'aci/tenant.xml.j2') }}"
delegate_to: localhost
- name: Add a tenant using inline YAML
cisco.aci.aci_rest:
host: apic
username: admin
private_key: pki/admin.key
validate_certs: false
path: /api/mo/uni.json
method: post
content:
fvTenant:
attributes:
name: Sales
descr: Sales department
delegate_to: localhost
- name: Add a tenant using a JSON string
cisco.aci.aci_rest:
host: apic
username: admin
private_key: pki/admin.key
validate_certs: false
path: /api/mo/uni.json
method: post
content:
{
"fvTenant": {
"attributes": {
"name": "Sales",
"descr": "Sales department"
}
}
}
delegate_to: localhost
- name: Add a tenant using an XML string
cisco.aci.aci_rest:
host: apic
username: admin
private_key: pki/{{ aci_username }}.key
validate_certs: false
path: /api/mo/uni.xml
method: post
content: '<fvTenant name="Sales" descr="Sales departement"/>'
delegate_to: localhost
- name: Get tenants using password authentication
cisco.aci.aci_rest:
host: apic
username: admin
password: SomeSecretPassword
method: get
path: /api/node/class/fvTenant.json
delegate_to: localhost
register: query_result
- name: Get first 5 tenants using password authentication and pagination
cisco.aci.aci_rest:
host: apic
username: admin
password: SomeSecretPassword
method: get
page_size: 5
path: /api/node/class/fvTenant.json
delegate_to: localhost
register: query_result
- name: Configure contracts
cisco.aci.aci_rest:
host: apic
username: admin
private_key: pki/admin.key
method: post
path: /api/mo/uni.xml
src: /home/cisco/ansible/aci/configs/contract_config.xml
delegate_to: localhost
- name: Register leaves and spines
cisco.aci.aci_rest:
host: apic
username: admin
private_key: pki/admin.key
validate_certs: false
method: post
path: /api/mo/uni/controller/nodeidentpol.xml
content:
<fabricNodeIdentPol>
<fabricNodeIdentP name="{{ item.name }}" nodeId="{{ item.nodeid }}" status="{{ item.status }}" serial="{{ item.serial }}"/>
</fabricNodeIdentPol>
with_items:
- '{{ apic_leavesspines }}'
delegate_to: localhost
- name: Wait for all controllers to become ready
cisco.aci.aci_rest:
host: apic
username: admin
private_key: pki/admin.key
validate_certs: false
path: /api/node/class/topSystem.json?query-target-filter=eq(topSystem.role,"controller")
register: apics
until: "'totalCount' in apics and apics.totalCount|int >= groups['apic']|count"
retries: 120
delay: 30
delegate_to: localhost
run_once: true
Common return values are documented here, the following are the fields unique to this module:
Key | Description |
|---|---|
error_code integer | The REST ACI return code, useful for troubleshooting on failure Returned: always Sample: |
error_text string | The REST ACI descriptive text, useful for troubleshooting on failure Returned: always Sample: |
imdata string | Converted output returned by the APIC REST (register this for post-processing) Returned: always Sample: |
payload string | The (templated) payload send to the APIC REST API (xml or json) Returned: always Sample: |
raw string | The raw output returned by the APIC REST API (xml or json) Returned: parse error Sample: |
response string | HTTP response string Returned: always Sample: |
status integer | HTTP status code Returned: always Sample: |
totalCount string | Number of items in the imdata array Returned: always Sample: |
url string | URL used for APIC REST call Returned: success Sample: |
© 2012–2018 Michael DeHaan
© 2018–2025 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/latest/collections/cisco/aci/aci_rest_module.html