简介
让我们回顾一下我们是如何通过命令行来执行三个不同的模块:
每个模块都能接收参数. 几乎所有的模块都接受键值对()参数,空格分隔.一些模块不接收参数,只需在命令行输入相关的命令就能调用.
- - name: reboot the servers
- action: command /sbin/reboot -t now
也可以简写成:
另一种给模块传递参数的方式是使用 ymal 语法,这也被称为 ‘complex args’
- - name: restart webserver
- service:
- name: httpd
模块努力使自身幂等,这意味着它们会尽可能避免对系统做出改动除非那是必须的.当使用 Ansibleplaybooks 时,这些模块能够触发 ‘change events’,以这种形式通知 ‘handlers’ 去运行附加任务.
每个模块的文档能够通过命令行的 ansible-doc 工具来获取:
- ansible-doc -l
See also
- Introduction To Ad-Hoc Commands
- Examples of using modules in /usr/bin/ansible
- Examples of using modules with /usr/bin/ansible-playbook
- Developing Modules
- Examples of using modules with the Python API
- Mailing List
- Questions? Help? Ideas? Stop by the list on Google Groups
ansible IRC chat channel