# Ansible nxos\_static\_routes multiple destination address same next\_hops

**URL:** <https://forum.ansible.com/t/ansible-nxos-static-routes-multiple-destination-address-same-next-hops/35235>\
**Category:** Ansible Project\
**Created:** [May 27, 2021, 7:36am UTC](https://forum.ansible.com/t/ansible-nxos-static-routes-multiple-destination-address-same-next-hops/35235 "2021-05-27T07:36:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Arnau\_Amargant\_Domen](https://avatars.discourse-cdn.com/v4/letter/a/edb3f5/32.png) [@Arnau\_Amargant\_Domen](https://forum.ansible.com/u/Arnau_Amargant_Domen)\
**Post date:** [May 27, 2021, 7:36am UTC](https://forum.ansible.com/t/ansible-nxos-static-routes-multiple-destination-address-same-next-hops/35235/1 "2021-05-27T07:36:52Z")

</div>

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:

 ![Screen Shot 2021-05-27 at 09.28.06.png](https://us1.discourse-cdn.com/ansible/original/2X/d/d5945708c3bdd0df49f5a6959c5315546a47319c.png)

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.

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [May 27, 2021, 7:55am UTC](https://forum.ansible.com/t/ansible-nxos-static-routes-multiple-destination-address-same-next-hops/35235/2 "2021-05-27T07:55:49Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [May 27, 2021, 4:48pm UTC](https://forum.ansible.com/t/ansible-nxos-static-routes-multiple-destination-address-same-next-hops/35235/3 "2021-05-27T16:48:01Z")

</div>

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

- name: Cisco stuff  
&nbsp;&nbsp;&nbsp;cisco.nxos.nxos\_static\_routes:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;config:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- afi: ipv4  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;routes:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- dest: 192.168.2.0/24  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;next\_hops: &hops  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- interface: eth1/8  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;forward\_router\_address: 20.0.0.5  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- interface: eth1/9  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;forward\_router\_address: 20.0.0.13  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- dest: 192.168.4.0/24  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;next\_hops: \*hops  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- dest: 192.168.6.0/24  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;next\_hops: \*hops
