ansible安装配置

1.环境检查与安装要求:

  • 管理节点需要Python>=2.6,并OpenSSH
  • 被管理节点需要python >=2.4,并安装OpenSSH

2.YUM源检查与安装

  • 检查YUM源列表,使用命令yum repolist
  • 安装wget工具,使用命令yum install wget -y
  • 下载并安装EPEL源,使用命令wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo 或 yum install -y epel-release

3.安装ansible

  • 使用YUM命令安装Ansible,yum -y install ansible
  • 使用pip命令安装Ansible,pip install ansible

4.ansible配置文件 /etc/ansible

  • ansible配置文件 查看配置文件顺序
  1. ANSIBLE_CONFIG变量
  2. 当前目录下./ansible.cfg
  3. 家目录下~/ansible.cfg
  4. 配置文件 /etc/ansible/ansible.cfg

5.配置ssh远程连接免密码

ssh-keygen -t rsa -P '' #生成密钥
ssh-keygen -f ~/.ssh/id_rsa -N '' #生成密钥

#配置远程免密(ssh-copy-id不能使用时)
sh-copy-id命令报错:-bash: ssh-copy-id: command not found,安装openssh-client
yum -y install openssh-clients
无法安装时可以用一下方式
cat ~/.ssh/id_*.pub | ssh  被管理服务器ip 'cat >> .ssh/authorized_keys'

#复制密钥到远程主机
for i in ip1 ip2 ip3
do
 ssh-copy-id $i
done
posted @   靖11  阅读(23)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 一个费力不讨好的项目,让我损失了近一半的绩效!
· 实操Deepseek接入个人知识库
· CSnakes vs Python.NET:高效嵌入与灵活互通的跨语言方案对比
· 【.NET】调用本地 Deepseek 模型
· Plotly.NET 一个为 .NET 打造的强大开源交互式图表库
点击右上角即可分享
微信分享提示