Ansible使用介绍

72课时
1.9K学过
8分

课程评价 (0)

请对课程作出评价:
0/300

学员评价

暂无精选评价
2分钟

10 示例1:利用迭代一次创建多个文件,安装多个命令包

vim testitem.yml

– hosts: all

remote_user: root

tasks:

– name: create some file

file: name=/data/{{ item}} state=touch

when: ansible_distribution_major_version == “7”

with_items:

​ – file1

​ – file2

​ – file3

– name: install some packages

yum: name={{ item }}

with_items:

​ – htop

​ – sl

​ – hping3

执行结果:当系统为CentOS7版本时,在/data目录下创建file1-3文件,安装htop,sl,hping3命令