ansible-aci icon indicating copy to clipboard operation
ansible-aci copied to clipboard

Inventory plugin (DCNE-302)

Open p3ck opened this issue 10 months ago • 7 comments

Report all devices which are part of the fabric.

Example shows how to have all spines, leafs and controller in groups.

fixes #720

p3ck avatar Feb 03 '25 14:02 p3ck

Hi @p3ck, some initial comments from my end. I am not familiar with inventory plugins development yet so might ask a bit more questions. I will in parallel also look into the https://docs.ansible.com/ansible/latest/dev_guide/developing_inventory.html#developing-inventory and the code https://github.com/ansible/ansible/blob/devel/lib/ansible/plugins/inventory/init.py. This will likely take a bit more time from my end.

akinross avatar Feb 03 '25 15:02 akinross

Also - If you're like me and wondering how to see the ansible docs for an inventory plugin you have to change the type...

ansible-doc -t inventory cisco.aci.aci_inventory

I didn't realize this at first. :-)

p3ck avatar Feb 04 '25 18:02 p3ck

please fix sanity issues

akinross avatar Feb 04 '25 19:02 akinross

@p3ck How is this plugin different from the information we're able to query using the below modules? As @akinross mentioned there's also a dedicated module called aci_system for the same purpose. Can this plugin be leveraged anyway outside of Ansible? Thanks!

---
- name: Query topSystem class in ACI
  hosts: aci
  gather_facts: no
  tasks:
    - name: Query topSystem class
      cisoc.aci.aci_rest:
        host: "{{ ansible_host }}"
        username: "{{ aci_username }}"
        password: "{{ aci_password }}"
        path: "/api/class/topSystem.json"
        method: get
        validate_certs: false
      register: top_system_response

    - name: Display topSystem information
      debug:
        var: top_system_response.response

OR

- name: Query all controllers system information
  cisco.aci.aci_system:
    host: apic
    username: userName
    password: somePassword
    validate_certs: false
    state: query

The difference is it's available as an inventory source. The request for this plugin was for inventory tracking in Ansible Automation Platform. HTH

p3ck avatar Feb 13 '25 13:02 p3ck

Ping - Are we good here? Can we merge? Thanks

p3ck avatar Apr 16 '25 11:04 p3ck

Hi @p3ck, waiting on feedback from @lhercot.

akinross avatar Apr 16 '25 11:04 akinross

I have a few issues with this plugin that I would like addressed before we take in this code:

  1. We need to decide if this plugin is aci_inventory or aci_inventory_system / aci_system_inventory. What I mean is that if this inventory plugin scope is to retrieve leaf, spines and controllers (nodes using topSystem class) and format them for inventory then we should make this plugin name more specific as I foresee a future where we will have more inventory plugins for other use cases (CDP/LLDP Neighbors, tenans, service devices, ...). On the other hand, if this plugin will be the all in be all inventory plugin we then need to allow the class types to be defined and expose a bunch of other options.

  2. How do we test this inventory plugin in our CI pipeline and make sure we do not introduce a regression in the future as this PR does not seems to include any test (unit or integration)? I do not see any documentation from Ansible/RedHat on how to test and validate inventory plugins.

  3. We need to open a enhancement issue to track the addition of certificate based authentication. (this is not blocking just a note once we take on this code)

lhercot avatar Apr 18 '25 06:04 lhercot