-
Notifications
You must be signed in to change notification settings - Fork 98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ACI lookup plugin (DCNE-110) #272
Comments
I like it. It would be great to export the results to a CSV file as an option. |
So I wrote it myself to fulfill my project requirements and it's really helpful to fillout variables based on lookups within a single task. |
Hi @netgab, I am not sure what you mean with your remark: "The problem here is, that there is no way to register a variable for aci_rest operations to store the output". Could you please elaborate a bit more what your exact requirement is and why this is not possible with current aci_rest module? |
Hi @akinross, so the "problem" is as follows (maybe it's because of lacking Ansible skills) :) If someone wants to query information from ACI using - name: "ACI REST query operation"
cisco.aci.aci_rest:
#...
method: get
path: "/api/class/fvTenant.json"
delegate_to: localhost
register: aci_query_result If I want to query a lot of stuff, I need one task per query and register one "fact" per query.
is not quite correct, because However a - name: "Check if baremetal EPGs exists"
vars:
queryFilter:
filters:
- attribute: "fvAEPg.name"
value: "{{ item.name }}"
epgQuery: "{{ lookup('aci_lookup',
host=apic_connection,
username=apic_username,
password=apic_password,
validate_certs=(apic_validate_cert | default(True) | bool),
query_object='fvAEPg',
query_target_filter=queryFilter) }}"
ansible.builtin.assert:
that: "epgQuery | length == 1"
fail_msg: "EPG {{ item.name }} does not exist - abort"
success_msg: "EPG {{ item.name }} exists - continue"
loop: "{{ epgs }}"
loop_control:
label: "{{ item.name }}" I'm (right now) not saying you cannot solve this using Based on a list of EPG names (variable We cannot do an Now we need to check whether our EPGs (names in the list I'm keen to learn how to solve my little |
Hi @netgab, Yes you would need two tasks but is that a bad thing? A possibility would be to do some sort of assert like:
|
Hi @akinross, Anyway - I solved it myself and wrote such a plugin. Since there are not a lot of "thumbsup" regarding this issue here, you may close it. |
Hi @netgab, We will keep this issue open in case there is more interest in time. For now this has low priority, but in time perhaps there will be more interest from the community. Thank you for the idea contribution. |
Community Note
Description
An Ansible lookup plugin would be helpful to query the REST API from the APIC and directly store the returned data (list) in a task / role variable or to define an Ansible
loop
. Currently, anaci_rest
operation is needed as a dedicated task. The problem here is, that there is no way to register a variable foraci_rest
operations to store the output. Therefore, a lookup plugin would be helpfulExample usage:
Of course, all possible REST options shall be implemented (e.g.
rsp_subtree
,rsp_subtree_class
, ....)New or Affected Module(s):
aci_lookup
APIC version and APIC Platform
not relevant, because this is a generic approach
Collection versions
References
The text was updated successfully, but these errors were encountered: