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

aci_epg. output file is not in proper format when using loop (DCNE-323)

Open prasanthvelunny78 opened this issue 8 months ago • 9 comments

I used the below to create multiple epg's and it works fine but the output file being generated not in a proper format. Because of this i cant run NDI Pre-change analysis feature and i had to manually edit the file to make it in a proper format.

  • name: Create EPG aci_epg: host: "{{ host }}" username: username

      password: "{{ password }}"
      tenant: "{{ item.Tenant }}"
      ap: "{{ item.AP }}"
      epg: "{{ item.EPG }}"
      bd: "{{ item.Bridge_domain }}"
      description: "{{ item.Description }}"
      state: "{{ item.State }}"
      validate_certs: no
      output_level: debug
      output_path: ./output/output.json
    loop: "{{ input.list }}"
    

I have attached the output i am getting and the expected output. Can you please have a look ?

aci-epg output_not_proper_format.json

aci-epg_expected_output.json

prasanthvelunny78 avatar Mar 28 '25 06:03 prasanthvelunny78

Hi @prasanthvelunny78,

This format is expected since per task execution the output is appended to the file. When looping a task, multiple task executions are done which are unaware of each others output and thus also full config as you expect it. This accepted by NDI in the past , which version of NDI are you using for PCV?

akinross avatar Mar 28 '25 07:03 akinross

@akinross
I tried it manually uploading the file but it gives me error. NDI Version 6.5.1.32 ND. 3.2.1i

I opened a case with Cisco and they suggested to manually edit the file. But it wont work for us as we are using Gitlab pipeline.

Pipeline structure

  1. Ansible Dry run
  2. Run NDI PCV using the output created by Ansible Dry run
  3. Push the config if all ok
  4. NDI Post check

Please let me know if the format is working in this version.

prasanthvelunny78 avatar Mar 28 '25 07:03 prasanthvelunny78

Could you provide the error/traceback details of NDI?

akinross avatar Mar 28 '25 08:03 akinross

Error is Couldnt parse change file. As I mentioned if put all epg's under fvAp manually then it works.

I also noticed, If run the same script again then it creates duplicate objects

Image

prasanthvelunny78 avatar Mar 28 '25 12:03 prasanthvelunny78

I have added it to the backlog, we will update it here accordingly.

akinross avatar Mar 28 '25 13:03 akinross

Thank you very much!

prasanthvelunny78 avatar Mar 31 '25 12:03 prasanthvelunny78

Hi @prasanthvelunny78, thank you for raising this issue.

As @akinross mentioned each looping task has no context of each other and will simply append the configuration to the specified output file. This is also why you see duplicate entries written into the file when running the playbook multiple times. You would need to either delete the file if it already exists or write to a different file for each playbook execution.

Would you be able to share how you are running NDI PCV in the GitLab pipeline? Does it use the cisco.nd.nd_pcv module?

samiib avatar Apr 16 '25 06:04 samiib

@prasanthvelunny78 Any update on @samiib request?

lhercot avatar May 23 '25 16:05 lhercot

Hi There,

Apologies for the delay. Yes I am using cisco.nd.nd_pcv. Cisco provided a simple script to make it in a proper format so NDI can read it. I havent tested it but will test it soon and give you an update.

Many Thanks

prasanthvelunny78 avatar May 27 '25 10:05 prasanthvelunny78

Hi @prasanthvelunny78,

I am following up to see if you have any further updates.

I revisited this issue to test out the outputs you provided. In our NDI environment I am able to successfully start a PCV job using the aci-epg.output_not_proper_format.json file with the cisco.nd.nd_pcv module. This module is designed to parse the looping Ansible output format and converts it into a proper ACI config dictionary before sending it to NDI.

Are you able to share the error output from cisco.nd.nd_pcv?

samiib avatar Jul 11 '25 22:07 samiib

Hi @prasanthvelunny78,

Any update? Did you see the comment from @samiib above?

lhercot avatar Jul 28 '25 19:07 lhercot

Closing as we are not getting updates. Re-open an issue if this is still an issue.

lhercot avatar Aug 27 '25 19:08 lhercot