002-ansible安装

该文介绍了在CentOS7系统上如何配置清华大学的EPEL源来安装Ansible。首先通过yum安装epel-release,然后使用sed命令修改epel.repo文件中的URL以指向清华大学的镜像站,最后通过yumupdate和yuminstallansible进行安装。
摘要由CSDN通过智能技术生成

环境说明:

  1. 操作系统:Centos7-2009
  2. 确保网络连接正常、yum源正常

步骤步骤:

1、安装ansible需要配置epel

配置清华大学的epel源为例子:https://mirror.tuna.tsinghua.edu.cn/help/epel/
EPEL(Extra Packages for Enterprise Linux)是由Fedora Special Interest Group维护的Enterprise Linux(RHEL、CentOS)中经 常用到的包。
下面以CentOS 7为例讲解如何使用本镜像站的epel镜像。CentOS 8同样可用该方法。
首先从CentOS Extras这个源(本镜像站也有镜像)里安装epel-release:

yum install epel-release -y

修改/etc/yum.repos.d/epel.repo,将mirrorlist和metalink开头的行注释掉。
接下来,取消注释这个文件里baseurl开头的行,并将其中的http://download.fedoraproject.org/pub替换成https://mirrors.tuna.tsinghua.edu.cn。
可以用如下命令自动替换:(来自 https://github.com/tuna/issues/issues/687)

sed -e 's!^metalink=!#metalink=!g' \
    -e 's!^#baseurl=!baseurl=!g' \
    -e 's!//download\.fedoraproject\.org/pub!//mirrors.tuna.tsinghua.edu.cn!g' \
    -e 's!//download\.example/pub!//mirrors.tuna.tsinghua.edu.cn!g' \
    -e 's!http://mirrors!https://mirrors!g' \
    -i /etc/yum.repos.d/epel*.repo

修改结果如下:(仅供参考,不同版本可能不同)

[epel] name=Extra Packages for Enterprise Linux 7 - $basearch baseurl=https://mirrors.tuna.tsinghua.edu.cn/epel/7/$basearch #mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=$basearch failovermethod=priority enabled=1 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 [epel-debuginfo] name=Extra Packages for Enterprise Linux 7 - $basearch - Debug baseurl=https://mirrors.tuna.tsinghua.edu.cn/epel/7/$basearch/debug #mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-debug-7&arch=$basearch failovermethod=priority enabled=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 gpgcheck=1 [epel-source] name=Extra Packages for Enterprise Linux 7 - $basearch - Source baseurl=https://mirrors.tuna.tsinghua.edu.cn/epel/7/SRPMS #mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-source-7&arch=$basearch failovermethod=priority enabled=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 gpgcheck=1 

运行 yum update 测试一下吧。
更新yum缓存:yum makecache

2、安装ansible

yum install ansible -y
pip install ansible 

实际效果:

image.png

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值