ansible常用模块

ansible 核心模块之 script

2020-12-15  本文已影响0人  wh0am11

script模块

script 模块用于在远程主机上执行 ansible 管理主机上的脚本

参数 (=号后面的参数强制要求):

在执行对应的命令之前,会先进入到此参数指定的目录中
[Default: (null)]
version_added: 0.6

当指定的文件存在时,就不执行对应命令
[Default: (null)]

当指定的文件不存在时,就不执行对应命令
[Default: (null)]
version_added: 0.8

必须参数,指定需要远程执行的命令,但是并没有具体的一个参数名叫 free_form

注意:

区别:

实例:

# Example from Ansible Playbooks
- script: /some/local/script.sh --some-arguments 1234

# Run a script that creates a file, but only if the file is not yet created
- script: /some/local/create_file.sh --some-arguments 1234
  args:
    creates: /the/created/file.txt

# Run a script that removes a file, but only if the file is not yet removed
- script: /some/local/remove_file.sh --some-arguments 1234
  args:
    removes: /the/removed/file.txt

# Run a script using a executable in a non-system path
- script: /some/local/script
  args:
    executable: /some/remote/executable

# Run a script using a executable in a system path
- script: /some/local/script.py
  args:
    executable: python3
上一篇 下一篇

猜你喜欢

热点阅读