目的:
迁移到新的环境后,linux共46台,需要统一管理
参考连接:
安装ansible:
Control环境为ubuntu,在官网上选择ubuntu安装方式,如下图
47 apt update
48 apt install software-properties-common
49 apt-add-repository --yes --update ppa:ansible/ansible
50 apt install ansible
安装好后,可执行ansible --version查看安装版本
为了方便管理,对涉及到的被控端添加免密登录
77 ssh-keygen -t rsa -f /root/.ssh/id_rsa -N ''
78 ls /root/.ssh/
79 ssh-copy-id x.x.x.x
在ansible的hosts下编排主机分组,这里全部用分组来管理,更方便
此处分为5组:
[testserver] #做测试的分组
[hlwubuntu] #互联网下所有ubuntu服务器分组
[zwwwubuntu] #政务网下所有ubuntu服务器分组
[jszxcentos] #计算分组
[allserver] #所有服务器分组
利用ansible对所有被控端安装EDR
先将文件分发下去
root@ansible:/mnt/tool# ansible allserver -m synchronize -a "src=/mnt/tool/edr dest=/opt/"
在执行安装
root@ansible:/mnt/tool# ansible allserver -m shell -a "cd /opt/edr/ && chmod +x install_edr.sh && ./install_edr.sh"
*这里分发文件不用copy,是因为copy文件一直失败,原因暂时未锁定。
本文介绍了如何在Ubuntu环境中安装Ansible,并通过配置hosts文件和免密登录管理46台Linux服务器。通过分发文件和执行shell命令,实现对所有服务器安装EDR的过程。
5721

被折叠的 条评论
为什么被折叠?



