tldr/pages.zh/common/ansible.md

30 lines
733 B
Markdown
Raw Normal View History

2019-02-25 10:22:51 +00:00
# ansible
> 通过SSH协议远程管理计算机组.
> 使用 /etc/ansible/hosts 文件来添加组/主机.
> 主页: <https://www.ansible.com/>.
- 列出给定组下的所有主机:
2019-02-25 14:47:09 +00:00
`ansible {{组}} --list-hosts`
2019-02-25 10:22:51 +00:00
- 调用ping模块来ping一组主机:
2019-02-25 14:47:09 +00:00
`ansible {{组}} -m ping`
2019-02-25 10:22:51 +00:00
- 通过调用安装模块来显示关于一组主机的信息:
2019-02-25 14:47:09 +00:00
`ansible {{组}} -m setup`
2019-02-25 10:22:51 +00:00
- 调用命令模块并使用给定的参数来对一组主机执行命令:
2019-02-25 14:47:09 +00:00
`ansible {{组}} -m command -a '{{命令}}'`
2019-02-25 10:22:51 +00:00
- 以管理员权限执行一个命令:
2019-02-25 14:47:09 +00:00
`ansible {{组}} --become --ask-become-pass -m command -a '{{命令}}'`
2019-02-25 10:22:51 +00:00
- 使用自定义的清单文件执行一个命令:
2019-02-25 14:47:09 +00:00
`ansible {{组}} -i {{清单文件}} -m command -a '{{命令}}'`