Ansible nxos_static_routes multiple destination address same next_hops

Hello,

Is there a way to have multiple destination address and the same next_hops? What I’m trying to do is shorten the lines of the playbook and better readability.

If you see the following image repeats the same next_hops for different address:

What i would like to achive is something like:

  • dest: 192.168.2.0/24, 192.168.4.0/24, 192.168.6.0/24
    next_hops:
  • interface: eth1/8
    forward_router_address: 20.0.0.5
  • interface: eth1/9
    forward_router_address: 20.0.0.13

But i dont know if its possible.
Thanks.

If that next_hops list is going to be more or less static for many
destinations, a simple option would be to define it once and then
reference it.
Note that I had to manually type this - please post real text next
time, instead of pixel images, so people can copy/paste it, and things
can get indexed by search engines for the benefit of other people
having the same problems.

Another option is to use YAML anchors, but variables are probably better.

- name: Cisco stuff
   cisco.nxos.nxos_static_routes:
     config:
       - afi: ipv4
         routes:
           - dest: 192.168.2.0/24
             next_hops: &hops
                - interface: eth1/8
                  forward_router_address: 20.0.0.5
                - interface: eth1/9
                  forward_router_address: 20.0.0.13
           - dest: 192.168.4.0/24
             next_hops: *hops
           - dest: 192.168.6.0/24
             next_hops: *hops