ansible自动化工具安装部署

1Ansible的搭建

       接下来我们来学习Ansible的安装和部署。Ansible的安装部署非常简单,以RPM安装为例,配置好阿里云的yum源直接安装就可以了, Ansible 的管理端只能是Linux,如Redhat,Debian.CentOS。下面介绍在CentOS7.x上安装部署Ansible。

实验环境

环境准备(主机能够上网)

Ansible

《1》:cd /etc/yum.repos/   切换目录

《2》:wget http://mirrors.aliyun.com/repo/Centos-7.repo

 wget http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm 下载镜像

《3》:rpm -ivh epel-release-latest-7.noarch.rpm

《4》:yum -y install ansible

《5》:vim /etc/hosts  编辑

《6》:写入:

192.168.100.10   ansible

192.168.100.20  client1

192.168.100.30  client2

《7》:scp /etc/hosts 192.168.100.20:/etc/hosts   

          scp /etc/hosts 192.168.100.30:/etc/hosts

《8》:hostname ansible  修改名称

            hostname client1

            hostname client2

           bash

《9》:systemctl stop firewalld

            iptables -F

            setenforce  0

《10》:vim /etc/ansible/hosts   编辑文件

《11》:写入:

[webserver]

192.168.100.20

192.168.100.30

《12》:ansible webserver -m ping  测试

报错说明,没有创建密钥对

《13》:ssh-keygen  创建密钥对

《14》:ssh-copy-id root@192.168.100.20 发送密钥对

             ssh-copy-id root@192.168.100.30 

《15》:ansible webserver -m ping 

《16》:ansible webserver -a "df -Th"   查看后两台主机的磁盘

《17》:ansible webserver -a "free -m" 查看后两台主机的内存

《18》:ansible --version 查看版本

《19》:ssh-keygen -t rsa -P " " -f .ssh/id_rsa  创建密钥对时,,不需要回车,一气呵成

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

BK_小小关

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值