Network Automation Made Easy by Ivo Pinto

Network Automation Made Easy by Ivo Pinto

Author:Ivo Pinto [Ivo Pinto]
Language: eng
Format: epub
Publisher: Cisco Press
Published: 2021-11-23T16:00:00+00:00


* * *

Example 4-19 shows the playbook from Example 4-17 adapted to use the keyword with_items.

Example 4-19 A Playbook to Configure Two VLANs on a Switch by Using with_items

$ cat vlans.yaml --- - name: Ansible Playbook to configure vlans for IOS Devices hosts: ios tasks: - name: print facts debug: msg: "{{ ansible_net_hostname }}" - name: Configure vlans cisco.ios.ios_vlans: config: - name: test_vlan vlan_id: "{{ item }}” state: active shutdown: disabled with_items: - 656 - 668

* * *

Note

The Ansible keyword is actually with_<word>, where <word> can be replaced with a value other than items that you might want to use in specific scenarios. For example, you might want to use the keyword with_indexed_items.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.