拓冰建站拓冰建站
首页 / 资讯中心 / 正文

ansible command和ansible shell

ansible command -a后面跟的是简单的命令,不能使用 |、 等ansible shell -a后面可以跟复杂的命令,如:| 等1.ansible command模块为ansible默认模块, 主要用于执行linux基础命令,可以执行远程服务器命令执行、任务执行等操作。command模块使用详解:chdir执行命令前,切换到目录;[root@cent79-2 ~]# ansible all -m command -a "pwd" 192.168.10.100 | CHANGED | rc=0 /root [root@cent79-2 ~]# ansible all -m command -a "pwd chdir=/etc" 192.168.10.100 | CHANGED | rc=0 /etc [root@cent79-2 ~]# ansible all -m command -a "chdir=/etc pwd" 192.168.10.100 | CHANGED | rc=0 /etc [root@cent79-2 ~]#creates当该文件存在时,则不执行该步骤;(不涉及创建)[root@cent79-2 ~]# ansible all -m command -a "creates=/tmp/filesystem.txt echo 'hello'" 192.168.10.100 | SUCCESS | rc=0 skipped, since /tmp/filesystem.txt exists [root@cent79-2 ~]# [root@cent79-2 ~]# ansible all -m command -a "creates=/tmp/filesystem1.txt echo 'hello'" 192.168.10.100 | CHANGED | rc=0
分享:

看完干货,该让你的企业上线了

免费需求沟通 · 48 小时内出具建站方案 · 河南本地可上门