renheshi 发表于 2018-1-3 12:56:50

ansible 的 shell模块和command模块

  shell模块:在远程主机上执行主控端的shell/python脚本
  用法:可执行多条命令,例如需要在node-1上创建3个ceph osd pool:
  ansible node-1 -m shell -a 'ceph osd pool create volumes 256 ; ceph osd pool create images 256; ceph osd pool create vms 256 || true'
  command模块:在远程主机上执行远程命令
  用法:不能调用shell指令,没有bash的环境变量,也不能使用shell的一些操作,在遇到"<",">","|","&"将会终止。如果我们要在node-1上安装ceph:
  ansible node-1 -m command -a 'apt-get install ceph -y'
页: [1]
查看完整版本: ansible 的 shell模块和command模块