ansible部署

[root@vm04 ~]# yum -y install epel-release.noarch
[root@vm04 ~]# yum install -y ansible
[root@vm04 ~]# yum install -y tree
[root@vm04 ~]# tree /etc/ansible/
/etc/ansible/
├── ansible.cfg
├── hosts
└── roles
1 directory, 2 files
[root@vm04 ~]# vim /etc/ansible/hosts
[root@vm04 ~]# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Created directory '/root/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:FwtTwK3KeCzoxL2apfMxX66Rv5kHsP84Z1VFipiM92Y root@vm04
The key's randomart image is:
+---[RSA 2048]----+
| ..o. ..|
| .+.o . ..|
| +.* . .. |
| . .+ + . |
| . o + +S o E. |
| + + *... o. |
| o ++o... . |
| o+.+ =o++ |
| ++. o.BB. |
+----[SHA256]-----+
[root@vm04 ~]#
[root@vm04 ~]# vim /etc/ansible/hosts
[root@vm04 ~]# ssh-copy-id root@192.168.161.132
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
The authenticity of host '192.168.161.132 (192.168.161.132)' can't be established.
ECDSA key fingerprint is SHA256:5uR5JPMqsz41rj41ucvYjTJQXyriDSExMIxriedz/6M.
ECDSA key fingerprint is MD5:8f:c1:f9:38:a8:e2:74:ef:7d:f5:1a:b0:41:de:90:8a.
Are you sure you want to continue connecting (yes/no)? yes
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
1root@192.168.161.132's password:
Permission denied, please try again.
root@192.168.161.132's password:
Number of key(s) added: 1
Now try logging into the machine, with: "ssh 'root@192.168.161.132'"
and check to make sure that only the key(s) you wanted were added.
[root@vm04 ~]# ssh-copy-id root@192.168.161.133
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
The authenticity of host '192.168.161.133 (192.168.161.133)' can't be established.
ECDSA key fingerprint is SHA256:5uR5JPMqsz41rj41ucvYjTJQXyriDSExMIxriedz/6M.
ECDSA key fingerprint is MD5:8f:c1:f9:38:a8:e2:74:ef:7d:f5:1a:b0:41:de:90:8a.
Are you sure you want to continue connecting (yes/no)? yes
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
root@192.168.161.133's password:
Number of key(s) added: 1
Now try logging into the machine, with: "ssh 'root@192.168.161.133'"
and check to make sure that only the key(s) you wanted were added.
[root@vm04 ~]# ansible 192.168.161.132 -m command -a 'date'
192.168.161.132 | CHANGED | rc=0 >>
20240315日 星期五 00:15:12 CST
[root@vm04 ~]# ansible mysql -m command -a 'date'
192.168.161.133 | CHANGED | rc=0 >>
20240315日 星期五 00:15:37 CST
posted @   w'dwd  阅读(11)  评论(0编辑  收藏  举报
(评论功能已被禁用)
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· C#/.NET/.NET Core技术前沿周刊 | 第 29 期(2025年3.1-3.9)
· 从HTTP原因短语缺失研究HTTP/2和HTTP/3的设计差异
点击右上角即可分享
微信分享提示