一、循环
循环迭代任务
1.简单循环
loop: ##赋值列表
- value1
- value2
- ...
{
{
item}} ##迭代变量名称
实例
---
- name: create file
hosts: 172.25.0.254
tasks:
- name: file module
file:
name: /mnt/{
{
item}}
state: present
loop:
- westos_file1
- westos_file2
2.循环散列或字典列表
---
- name: create file
hosts: 172.25.0.254
tasks:
- name: file module
service:
name: "{
{ item.name}}"
state: "{
{ item.state }}"
loop:
- name: httpd
state: started
-