我需要在临时模式下运行2个diff?有没有可能
1]主机名
2] df -h
# ansible example -s -a "hostname && df -h"错误
```[root@ansi1 ansible]# ansible example -s -a "hostname && df -h"ansi2.example.com _失败_ rc=4 _ >>
用法:主机名-v {主机名\-F文件}设置主机名(来自文件)
domainname [-v] {nisdomain|-F file} set NIS domainname (from file) hostname [-v] [-d|-f|-s|-a|-i|-y|-A|-I] display formatted name hostname [-v] display hostname hostname -V|--version|-h|--help print info and exitdnsdomainname=hostname -d, {yp,nis,}domainname=hostname -y-s, --short short host name-a, --alias alias names-i, --ip-address addresses for the hostname-I, --all-ip-addresses all addresses for the host-f, --fqdn, --long long host name (FQDN)-A, --all-fqdns all long host names (FQDNs)-d, --domain DNS domain name-y, --yp, --nis NIS/YP domainname-F, --file read hostname or NIS domainname from given file此命令可以读取或设置主机名或NIS域名称。你可以的
还可以读取DNS域或FQDN (完全限定的域名)。
除非您使用bind或NIS进行主机查找,否则可以更改
FQDN (完全限定域名)和DNS域名(
FQDN的一部分)在/etc/host文件中。
发布于 2017-05-24 08:07:47
发现了我的错误,愚蠢的错误
[root@ansi1 ansible]# ansible example -s -m shell -a "hostname && df -h"
ansi2.example.com | SUCCESS | rc=0 >>
ansi2.example.com
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_ansible2-lv_root
6.5G 980M 5.2G 16% /
tmpfs 939M 0 939M 0% /dev/shm
/dev/sda1 477M 54M 398M 12% /boot发布于 2017-05-24 08:05:27
看来ansible不使用shell来运行您的命令。但是,您显然在自定义命令&&中使用了shell语法。因此,您的一个选择是直接告诉ansible使用shell:
$ ansible localhost -s -a "bash -c 'hostname && df -h'"https://unix.stackexchange.com/questions/366906
复制相似问题