[WARNING] Ansible is being run in a world writable directory (/root/ansible), ignoring it as an ansible.cfg source. For more information see https://docs.ansible.com/ansible/devel/(Ansible无法执行命令解决)

提示配置文件有问题,但是配置文件没有问题,这个问题的原因是当前ansible的目录权限照成的。

 当给ansible的上层目录设置和很大的权限之后,ansible就认为当前环境是不安全的,所以不执行命令

解决办法   chmod u+x,g-wx,o-wx ansible  看看当前目录的其他目录权限,设置成一样的就可以了, 

┌──[root@vms81.liruilongs.github.io]-[~]
└─$chmod  u+x,g-wx,o-wx ansible
┌──[root@vms81.liruilongs.github.io]-[~]
└─$ll
总用量 1312128
-rw-------.  1 root root      1474 10月 18 2018 anaconda-ks.cfg
drwxr--r--  15 root root      4096 12月 22 22:56 ansible
drwxr-xr-x   2 root root         6 10月  8 20:27 baidu
-rw-r--r--   1 root root 460992512 3月  30 2021 calico_3_14.tar
-rwxr-xr-x   1 root root 399186944 11月 27 10:16 calico-3.19-img.tar
-rw-r--r--   1 root root     22464 3月  30 2021 calico.yaml
-rw-r--r--   1 root root        49 12月 12 16:28 cat
-rwxr-xr-x   1 root root  42592768 10月  7 00:12 coredns-1.21.tar
-rw-r--r--   1 root root        49 12月 12 16:28 env.txt
drwxr-xr-x  16 root root      4096 4月  22 2020 external-storage-master
-rw-r--r--   1 root root  11662350 11月 28 20:26 external-storage-master.zip
-rw-r--r--   1 root root 334879744 12月 22 22:19 ingress-nginx-controller-img.tar
-rw-r--r--   1 root root       185 12月 16 21:25 kubeapi
-rw-------   1 root root      5679 12月 16 23:11 kubeconfig.yaml
-rw-------   1 root root     25687 12月 16 22:35 kube.zYxKiH
-rwxr-xr-x   1 root root  41199616 10月  7 11:29 metrics-img.tar
-rwxr-xr-x   1 root root   6918138 10月  7 11:29 metrics-server-v0.3.6.tar.gz
-rw-r--r--   1 root root  46082048 11月 28 20:27 nfs-client-provisioner.tar
-rwxr-xr-x   1 root root       924 3月  30 2021 one-client-install.sh
-rwxr-xr-x   1 root root       651 10月  6 22:32 set.sh
┌──[root@vms81.liruilongs.github.io]-[~]
└─$

┌──[root@vms81.liruilongs.github.io]-[~/ansible]
└─$ansible node -m ping
192.168.26.83 | SUCCESS => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    },
    "changed": false,
    "ping": "pong"
}
192.168.26.82 | SUCCESS => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    },
    "changed": false,
    "ping": "pong"
}
┌──[root@vms81.liruilongs.github.io]-[~/ansible]
└─$
加油,愿被这世界温柔以待 ^_^
原文地址:https://www.cnblogs.com/liruilong/p/15721594.html