2分钟
11 示例2:使用迭代创建组
vim testitem2.yml
—
– hosts: all
remote_user: root
tasks:
– name: create some groups
group: name={{ item }}
when: ansible_distribution_major_version == “7”
with_items:
– g1
– g2
– g3
执行结果:当系统版本为CentOS7时,创建g1,g2,g3组
vim testitem2.yml
—
– hosts: all
remote_user: root
tasks:
– name: create some groups
group: name={{ item }}
when: ansible_distribution_major_version == “7”
with_items:
– g1
– g2
– g3
执行结果:当系统版本为CentOS7时,创建g1,g2,g3组
Copyright © 2013-2026 Tencent Cloud.All Rights Reserved. 腾讯云 版权所有
学员评价