知乎專欄 | 多維度架構 | 微信號 netkiller-ebook | QQ群:128659835 請註明“讀者” |
Your first commands
/etc/ansible/hosts
# vim /etc/ansible/hosts 192.168.2.10 192.168.2.11 192.168.2.12 192.168.2.13 192.168.2.14 192.168.2.15
創建SSH公鑰與私鑰
ssh-keygen
將公鑰檔案複製到目標伺服器
ssh-copy-id root@192.168.2.10 ssh-copy-id root@192.168.2.11 ssh-copy-id root@192.168.2.12 ssh-copy-id root@192.168.2.13 ssh-copy-id root@192.168.2.14 ssh-copy-id root@192.168.2.15
連接與驗證測試 ansible all -m ping
# ansible all -m ping 192.168.2.10 | success >> { "module": "ping", "ping": "pong" } 192.168.2.13 | success >> { "module": "ping", "ping": "pong" } 192.168.2.14 | success >> { "module": "ping", "ping": "pong" } 192.168.2.11 | success >> { "module": "ping", "ping": "pong" } 192.168.2.15 | success >> { "module": "ping", "ping": "pong" } 192.168.2.12 | success >> { "module": "ping", "ping": "pong" }