这里介绍一些ansible常用的模块,以后有用到其他的会再补充进来。
1.shell
在被管理机统一执行shell命令
参数:
- 命令
- chdir=目录 切换到指定目录执行命令
ansible [web] -m shell -a "uptime" - name: shell: uptime
2.command
与shell命令类似,但是不支持一些特殊符号,比如”<“, “>”, “|”, “;” 和 “&”
参数:
- creates 指定一个路径,表示该文件存在时就不执行命令
- removes 与creates相反,表示文件不存在时执行命令
3.yum
4.script
推送脚本并执行,不需要把脚本发送到被管理机
参数:
- 脚本文件
- file
- archive/unarchive
- copy
- ping
- service