|
11 | 11 | ---
|
12 | 12 | - name: Configure Loopback Networks on Each Switch
|
13 | 13 | hosts: switches
|
14 |
| - connection: local |
| 14 | + gather_facts: False |
| 15 | + |
| 16 | + # Ansible added new connection options for networking devices |
| 17 | + # to replace connection: local |
| 18 | + # Now connection: network_cli or httpapi are recommended |
| 19 | + # Doc: https://docs.ansible.com/ansible/2.9/network/user_guide/platform_nxos.html |
| 20 | + connection: network_cli |
15 | 21 |
|
16 | 22 | tasks:
|
17 | 23 | - name: Create Loopback Interface
|
18 |
| - with_items: "{{ local_loopbacks }}" |
| 24 | + # Note: The "with_items" syntax has been replaced by "loop" |
| 25 | + # - https://docs.ansible.com/ansible/2.9/user_guide/playbooks_loops.html#with-items |
| 26 | + loop: "{{ local_loopbacks }}" |
| 27 | + # with_items: "{{ l3_fabric.interfaces }}" |
| 28 | + # Note: the nxos_interface module has been replaced with nxos_interfaces |
| 29 | + # and will be deprecated/removed soon. However the new nxos_interfaces |
| 30 | + # module has a bug in Ansible 2.9 when trying to create loopbacks. Keeping |
| 31 | + # this example using nxos_interface for now. |
| 32 | + # Info: |
| 33 | + # - https://docs.ansible.com/ansible/2.9/modules/nxos_interfaces_module.html |
| 34 | + # - https://docs.ansible.com/ansible/2.9/modules/nxos_interface_module.html |
19 | 35 | nxos_interface:
|
20 |
| - host: "{{ inventory_hostname }}" |
21 | 36 | interface: "{{ item.name }}"
|
22 | 37 | mode: layer3
|
23 | 38 | description: "{{ item.desc }}"
|
24 |
| - admin_state: up |
25 | 39 |
|
| 40 | + |
| 41 | + |
| 42 | + # Note: The module nxos_ip_interface was obsoleted by Ansible and replaced with |
| 43 | + # nxos_l3_interfaces. This module provides the same purpose, but with different |
| 44 | + # syntax. See details at: |
| 45 | + # - https://docs.ansible.com/ansible/2.9/modules/nxos_l3_interfaces_module.html |
26 | 46 | - name: Configure IPv4 Address on Interface
|
27 |
| - with_items: "{{ local_loopbacks }}" |
28 |
| - nxos_ip_interface: |
29 |
| - host: "{{ inventory_hostname }}" |
30 |
| - state: present |
31 |
| - interface: "{{ item.name }}" |
32 |
| - version: v4 |
33 |
| - addr: "{{ item.ip_address }}" |
34 |
| - mask: "{{ item.prefix }}" |
| 47 | + # Note: The "with_items" syntax has been replaced by "loop" |
| 48 | + # - https://docs.ansible.com/ansible/2.9/user_guide/playbooks_loops.html#with-items |
| 49 | + loop: "{{ local_loopbacks }}" |
| 50 | + # Note: to stay consistent with the videos for the lesson, this playbook |
| 51 | + # uses the loop construct for configuring interfaces. The current module |
| 52 | + # does support multiple interfaces in one task execution, and that would |
| 53 | + # be a more efficient configuration. |
| 54 | + nxos_l3_interfaces: |
| 55 | + state: merged |
| 56 | + config: |
| 57 | + - name: "{{ item.name }}" |
| 58 | + ipv4: |
| 59 | + - address: "{{ item.ip_address }}/{{ item.prefix }}" |
0 commit comments