Ansible dense configuration-free landing

0x01: a public key to the remote server to obtain local

#ssh-keyscan ip1 ip2 ip3 ip4 >> /root/.ssh/known_hosts

 Upon completion, / root / .ssh / known_hosts a lot more content

0x02: Adding IP services to the hosts ansible 

#cat >> /etc/ansible/hosts << EOF
ip1
ip2
ip3
ip4
EOF
#

0x03: Adding free secret login (my ROOT password are the same, use the -k parameter, and then enter the root password)

ansible all -m authorized_key -a "user=root state=present key=\"{{ lookup('file', '/root/.ssh/id_rsa.pub') }} \"" -k

0x04: Verify avoid dense landing

#ansible all -m ping
172.16.13.5 | SUCCESS => {
    "changed": false,
    "failed": false,
    "ping": "pong"
}
172.16.13.15 | SUCCESS => {
    "changed": false,
    "failed": false,
    "ping": "pong"
}
172.16.13.6 | SUCCESS => {
    "changed": false,
    "failed": false,
    "ping": "pong"
}
172.16.13.8 | SUCCESS => {
    "changed": false,
    "failed": false,
    "ping": "pong"
}
172.16.13.9 | SUCCESS => {
    "changed": false,
    "failed": false,
    "ping": "pong"
}
#

  

Guess you like

Origin www.cnblogs.com/fanlong0212/p/12185355.html