ansible对单机进行操作

[root@www ~]# vim /etc/ansible/hosts

Ex 1: Ungrouped hosts, specify before any group headers.

green.example.com #注释掉

blue.example.com #注释掉

192.168.100.1 #注释掉

192.168.100.10 #注释掉

192.168.1.144 #增加的

Ex 2: A collection of hosts belonging to the 'webservers' group

[webservers]

alpha.example.org

beta.example.org

192.168.1.100

192.168.1.110

192.168.1.144 #增加的

总之让你的看起来跟我一样,不过新增加的ip是你想操作的主机

[root@www ~]# ansible 192.168.1.144 -m ping
192.168.1.144 | success >> {
"changed": false,
"ping": "pong"
}

[root@www ~]#
基本上我们都是基于组的操作,因为单台的话 我们直接ssh连上去想干嘛干嘛!!!
因为上一篇我们已经讲了如何设置ssh信任,所以 直接就可以!

你可能感兴趣的:(ansible对单机进行操作)