ansible“raw”、“shell”和“command”之间有什么区别?

ansible“raw”、“shell”和“command”之间有什么区别?,ansible,Ansible,ansible剧本中的原始、shell和命令之间有什么区别?以及何时使用哪个?:在目标主机上执行远程命令,与其他playbook任务相同。 它可以用于启动脚本.sh或执行简单命令。例如: - name: Cat a file command: cat somefile.txt - name: Execute a script command: somescript.sh param1 param2 - name: Look for something in a file shel

ansible剧本中的原始、shell和命令之间有什么区别?以及何时使用哪个?

:在目标主机上执行远程命令,与其他playbook任务相同。 它可以用于启动脚本.sh或执行简单命令。例如:

- name: Cat a file
  command: cat somefile.txt

- name: Execute a script
  command: somescript.sh param1 param2
- name: Look for something in a file
  shell: cat somefile.txt | grep something
:在目标主机上执行远程命令,打开新的shell/bin/sh。 如果要执行更复杂的命令,例如与管道连接的命令,可以使用它。例如:

- name: Cat a file
  command: cat somefile.txt

- name: Execute a script
  command: somescript.sh param1 param2
- name: Look for something in a file
  shell: cat somefile.txt | grep something
:在目标主机上缺少解释器的情况下执行低级命令,常见的用例是安装python。此模块不应用于建议使用命令和shell的所有其他情况

:在目标主机上,在其他playbook任务的同一shell中执行远程命令。 它可以用于启动脚本.sh或执行简单命令。例如:

- name: Cat a file
  command: cat somefile.txt

- name: Execute a script
  command: somescript.sh param1 param2
- name: Look for something in a file
  shell: cat somefile.txt | grep something
:在目标主机上执行远程命令,打开新的shell/bin/sh。 如果要执行更复杂的命令,例如与管道连接的命令,可以使用它。例如:

- name: Cat a file
  command: cat somefile.txt

- name: Execute a script
  command: somescript.sh param1 param2
- name: Look for something in a file
  shell: cat somefile.txt | grep something

:在目标主机上缺少解释器的情况下执行低级命令,常见的用例是安装python。本模块不应用于建议使用command和shell的所有其他情况

,因为我遇到了同样的问题,我也想在这里分享我的发现

命令和shell模块以及事实取决于远程主机上正确安装的Python解释器。如果该要求未得到满足,那么如果无法执行,则可能会出现错误

python <ansiblePython.py>
这就像

/bin/sh -c 'ln -s /usr/bin/python3 /usr/bin/python'

在远程系统上。

由于我在同一个问题上结结巴巴,我也想在这里分享我的发现

命令和shell模块以及事实取决于远程主机上正确安装的Python解释器。如果该要求未得到满足,那么如果无法执行,则可能会出现错误

python <ansiblePython.py>
这就像

/bin/sh -c 'ln -s /usr/bin/python3 /usr/bin/python'
在远程系统上