|
1 | 1 | --- |
| 2 | +- name: Start spines and leafs and add them to inventory |
| 3 | + hosts: localhost |
| 4 | + vars: |
| 5 | + leafs_list: |
| 6 | + - leaf-0 |
| 7 | + - leaf-1 |
| 8 | + - leaf-2 |
| 9 | + - leaf-3 |
| 10 | + - leaf-4 |
| 11 | + - leaf-5 |
| 12 | + spines_list: |
| 13 | + - spine-0 |
| 14 | + - spine-1 |
| 15 | + routers_list: |
| 16 | + - router-0 |
| 17 | + fabric_list: "{{ leafs_list + spines_list + routers_list }}" |
| 18 | + tasks: |
| 19 | + - name: Start spine and leaf VMs |
| 20 | + delegate_to: hypervisor |
| 21 | + become: true |
| 22 | + community.libvirt.virt: |
| 23 | + name: "cifmw-{{ item }}" |
| 24 | + state: running |
| 25 | + loop: "{{ fabric_list }}" |
| 26 | + |
| 27 | + - name: Add leafs group to inventory |
| 28 | + when: '"leafs" not in groups' |
| 29 | + ansible.builtin.add_host: |
| 30 | + name: "{{ item }}.utility" |
| 31 | + group: leafs |
| 32 | + loop: "{{ leafs_list }}" |
| 33 | + |
| 34 | + - name: Add spines group to inventory |
| 35 | + when: '"spines" not in groups' |
| 36 | + ansible.builtin.add_host: |
| 37 | + name: "{{ item }}.utility" |
| 38 | + group: spines |
| 39 | + loop: "{{ spines_list }}" |
| 40 | + |
| 41 | + - name: Add routers group to inventory |
| 42 | + when: '"routers" not in groups' |
| 43 | + ansible.builtin.add_host: |
| 44 | + name: "{{ item }}.utility" |
| 45 | + group: routers |
| 46 | + loop: "{{ routers_list }}" |
| 47 | + |
| 48 | + - name: Check SSH connectivity |
| 49 | + delegate_to: hypervisor |
| 50 | + ansible.builtin.wait_for: |
| 51 | + port: 22 |
| 52 | + host: "{{ item }}.utility" |
| 53 | + search_regex: OpenSSH |
| 54 | + delay: 10 |
| 55 | + timeout: 120 |
| 56 | + loop: "{{ fabric_list }}" |
| 57 | + |
2 | 58 | - name: Common spines and leaves configuration |
3 | 59 | hosts: "spines,leafs{{ router_bool | default(false) | ternary(',routers', '') }}" |
4 | 60 | tasks: |
|
183 | 239 | autoconnect: true |
184 | 240 | conn_name: "{{ item }}" |
185 | 241 | type: ethernet |
| 242 | + ifname: "{{ router_downlink_ifs[loop_index | int] }}" |
186 | 243 | method4: disabled |
187 | 244 | method6: link-local |
188 | 245 | state: present |
189 | 246 | loop: "{{ router_downlink_conns }}" |
| 247 | + loop_control: |
| 248 | + index_var: loop_index |
190 | 249 |
|
191 | 250 | # uplink router IPv4 is configured for both IPv4 and IPv6 jobs |
192 | 251 | - name: Configure uplink router connections with nmcli when IPv4 |
|
453 | 512 | autoconnect: true |
454 | 513 | conn_name: "{{ item }}" |
455 | 514 | ip4: "{{ leaf_ds_ip4 }}/30" |
| 515 | + type: ethernet |
| 516 | + ifname: "{{ downlink_ifs_rack3[loop_index | int] }}" |
456 | 517 | method4: manual |
457 | 518 | method6: link-local |
458 | 519 | state: present |
|
470 | 531 | autoconnect: true |
471 | 532 | conn_name: "{{ item }}" |
472 | 533 | ip4: "{{ leaf_ds_ip4 }}/30" |
| 534 | + type: ethernet |
| 535 | + ifname: "{{ leaf_downlink_ifs[loop_index | int] }}" |
473 | 536 | method4: manual |
474 | 537 | method6: link-local |
475 | 538 | state: present |
|
513 | 576 | conn_name: "{{ item }}" |
514 | 577 | ip4: "{{ _leaf_ds_ip4 }}/30" |
515 | 578 | ip6: "{{ _leaf_ds_ip6 }}/126" |
| 579 | + type: ethernet |
| 580 | + ifname: "{{ leaf_downlink_ifs[loop_index | int] }}" |
516 | 581 | method4: manual |
517 | 582 | method6: manual |
518 | 583 | state: present |
|
549 | 614 | conn_name: "{{ item }}" |
550 | 615 | method4: disabled |
551 | 616 | method6: link-local |
| 617 | + type: ethernet |
| 618 | + ifname: "{{ uplink_ifs[loop_index | int] }}" |
552 | 619 | state: present |
553 | 620 | loop: "{{ uplink_conns }}" |
| 621 | + loop_control: |
| 622 | + index_var: loop_index |
554 | 623 |
|
555 | 624 | - name: Enable FRR Zebra daemon |
556 | 625 | become: true |
|
0 commit comments