尧图建网站 尧图建网站 YAOTU WEB BUILD 免费咨询
ARTICLE DETAIL

资讯详情

深耕网站建设与建站编程的一线实战洞察。

ansible command和ansible shell

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
返回列表