御风而翔  
个人云笔记

所有步骤均在ansible server主机上执行。

一、安装Ansible

 wget -O  /etc/yum.repos.d/epel.repo   http://mirrors.aliyun.com/repo/epel-7.repo
      或者  yum install epel-release -y
 yum install ansible  -y

二、ansible 到workder节点免密登录

2.1 生成公钥

ssh-keygen -t  rsa

2.2 公钥拷贝到woker节点 

<1> 客户机比较少可以直接执行以下指令

ssh-copy-id root@20.20.45.177

<2> 或者用脚本批量执行

sh  copy_ssh_key.sh

其中脚本内容如下:

yum  install  expect  -y

#cat list

20.20.45.177
20.20.41.213

#cat copy_ssh_key.sh

复制代码
#!/bin/bash
while read line
  do
    user="root"
    ip=`echo $line | cut -d " " -f 1`
    passwd="1"
    echo ip: $ip
    echo pw: $passwd
    expect <<EOF
      set timeout 2s
      spawn  ssh-copy-id -i /root/.ssh/id_rsa.pub $user@$ip
      expect {
         "yes/no"   { send  "yes\n"; exp_continue }
         "password" { send "$passwd\n" }
       }
       expect "password" { send "$passwd\n" }
EOF
  done < list   
复制代码

3、设置inventory

cat /etc/ansible/hosts

[client01]
20.20.45.177
[client02]
20.20.41.213

4、验证测试,(不能在项目目录下测试)

 

 
posted on   个人记录  阅读(11)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
· AI与.NET技术实操系列(六):基于图像分类模型对图像进行分类
 
点击右上角即可分享
微信分享提示