Ansible安装部署

本文介绍了Ansible的安装部署过程,包括服务器配置、SSH密钥认证、主机间通信验证等。此外,详细阐述了Ansible的自动化运维优势、工作原理、系统架构以及任务执行模式,包括ad-hoc和playbook模式,旨在帮助读者掌握Ansible在Linux环境中的使用。
摘要由CSDN通过智能技术生成

Ansible安装部署
4台虚拟机 ,全部开启防火墙
server 192.168.8.130
node1 192.168.8.131
node2 192.168.8.132
node3 192.168.8.133
1.server部署

[root@server ~]# cd /etc/yum.repos.d/
[root@server yum.repos.d]# rm -rf *
[root@server yum.repos.d]# dnf -y install centos-release-ansible-29-1-
2.el8.noarch
[root@server yum.repos.d]# ls /etc/yum.repos.d/ |grep ansible
CentOS-SIG-ansible-29.repo
[root@server yum.repos.d]# dnf -y install ansible
[root@servere yum.repos.d]# ls
CentOS-Base.repo CentOS-SIG-ansible-29.repo
//查看ansible版本
[root@server yum.repos.d]# ansible --version
ansible 2.9.27
  config file = /home/student/ansible/ansible.cfg
  configured module search path = ['/home/student/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.6/site-packages/ansible
  executable location = /usr/bin/ansible
  python version = 3.6.8 (default, Dec  3 2020, 18:11:24) [GCC 8.4.1 20200928 (Red Hat 8.4.1-1)]

2.配置/etc/hosts

在ansible节点vim /etc/hosts
[root@ansible yum . repos .d]# cd
[root@ansible ~]# vim /etc/hosts
(末行添加)
192.168.8.130 server.example.com server
192.168.8.131 node1.example.com node1
192.168.8.132 node2.example.com node2
192.168.8.133 node3.example.com node3

3.配置ssh的基于密钥认证

在ansible节点执行ssh-keygen命令,一直回车
[root@ansible ~]# ssh-keygen
[student@server ansible]$ ssh-copy-id -i ~/.ssh/id_rsa.pub student@node1
/usr/bin/ssh-copy-id: INFO: Source of key(s
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值