【发布时间】:2017-09-18 10:43:02
【问题描述】:
有没有一种简单的方法可以找回精确的 ansible 脚本(剧本)正在尝试做的事情?
例如我有
- name: Install required packages
yum: name={{item}} state=present
with_items:
- nmp
become: True
我想得到:
sudo yum install nmp
也就是说,我想知道 ansible 正在运行哪些命令(操作系统级别)。 基本上,我需要相反的过程:Ansible and Playbook. How to convert shell commands into yaml syntax?
【问题讨论】:
-
详细
-vvvv -
但 Ansible 有时只运行外部命令(实际上在极少数情况下总体上是这样),它主要是 Python 代码和 Python 库。
-
有趣的一点@techraf - 所以你是说从文件(docs.ansible.com/ansible/file_module.html)之类的模块到操作系统级别的命令没有简单的“翻译”?只有像 command (docs.ansible.com/ansible/command_module.html) 这样的模块 - 只是运行 shell + command 本身才能被“翻译” - 我理解正确吗?
-
是的,您理解正确。它甚至更复杂,因为单个模块(如
yum)的行为取决于参数和安装的库。其他模块也必须处理不同的操作系统类型等。 -
@techraf - 把它写成答案 - 我相信它是有效的
标签: ansible