Network Automation Cookbook
上QQ阅读APP看书,第一时间看更新

How it works..

Ansible supports looping over two main iterable data structures: lists and dictionaries. We use the loops keyword when we need to iterate over lists (snmp_servers is a list data structure) and we use with_dicts when we loop over a dictionary (users is a dictionary data structure where the username is the key and the passwords are the values). In both cases, we use the item keyword to specify the value in the current iteration. In the case of with_dicts, we get the key using item.key and we get the value using item.value.

The output of the preceding playbook run is shown here: