cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2772
Views
0
Helpful
1
Replies

ACI configuration using Ansible

defreiro
Level 1
Level 1

Anyone have any luck or experience sending REST commands to ACI? I am running ACI version 1.2(3c) and having no luck using two specific Ansible modules to send REST code to the APIC. Wanted to know if anyone has any advice or suggestions on the best way to accomplish this.

1 Accepted Solution

Accepted Solutions

dcrown
Level 1
Level 1

The aci_rest module is the way to go. if you use the API inspector to get the post payload, you can convert it from json to YAML and put it in line, like so

- name: create vpc interface selectors

  aci_rest:

  hostname: "{{ apic_address }}"

  username: "{{ apic_user }}"

  password: "{{ apic_password }}"

  validate_certs: no

  method: post

  path: /api/node/mo/uni/infra/accportprof-{{device.0.name}}.json

  content:

    infraAccPortP:

       attributes:

            dn: uni/infra/accportprof-{{device.0.name}}

            name: "{{device.0.name}}"

            rn: accportprof-{{device.0.name}}

       children:

          - infraHPortS:

                 attributes:

                 dn: uni/infra/accportprof-{{device.0.name}}/hports-eth{{device.1}}-typ-range

                 name: eth{{device.1}}

                 rn: hports-eth{{device.1}}-typ-range

                 children:

            - infraPortBlk:

                 attributes:

                 fromPort: "{{device.1}}"

                 toPort: "{{device.1}}"

                 name: block2

                 children: []

            - infraRsAccBaseGrp:

                 attributes:

                      tDn: uni/infra/funcprof/accbundle-{{device.0.name}}

                 children: []

  with_subelements:

  - "{{ devices }}"

  - interfaces

  loop_control:

  loop_var: device

View solution in original post

1 Reply 1

dcrown
Level 1
Level 1

The aci_rest module is the way to go. if you use the API inspector to get the post payload, you can convert it from json to YAML and put it in line, like so

- name: create vpc interface selectors

  aci_rest:

  hostname: "{{ apic_address }}"

  username: "{{ apic_user }}"

  password: "{{ apic_password }}"

  validate_certs: no

  method: post

  path: /api/node/mo/uni/infra/accportprof-{{device.0.name}}.json

  content:

    infraAccPortP:

       attributes:

            dn: uni/infra/accportprof-{{device.0.name}}

            name: "{{device.0.name}}"

            rn: accportprof-{{device.0.name}}

       children:

          - infraHPortS:

                 attributes:

                 dn: uni/infra/accportprof-{{device.0.name}}/hports-eth{{device.1}}-typ-range

                 name: eth{{device.1}}

                 rn: hports-eth{{device.1}}-typ-range

                 children:

            - infraPortBlk:

                 attributes:

                 fromPort: "{{device.1}}"

                 toPort: "{{device.1}}"

                 name: block2

                 children: []

            - infraRsAccBaseGrp:

                 attributes:

                      tDn: uni/infra/funcprof/accbundle-{{device.0.name}}

                 children: []

  with_subelements:

  - "{{ devices }}"

  - interfaces

  loop_control:

  loop_var: device