Ansible 更换aliyun 镜像 并下载tree

目录

这里安装一个aliyun 的镜像

本案例 仅供实验参考 生产环境中请谨慎使用

查看系统版本

先查看linux 的系统 版本

sh 复制代码
ansible slave -m shell -a 'uname -a'

找到对应 的版本

aliyun 链接:aliyun.com

找到对应版本

对当前镜像进行备份

nim 复制代码
ansible slave -m shell -a ' mkdir /etc/yum.repos.d/yuan.bak && mv /etc/yum.repos.d/*.repo  /etc/yum.repos.d/yuan.bak '

已经对原有的源备份成功

这里也是检查一下备份 可以看到已经移除了

sh 复制代码
ansible slave -m shell -a 'ls /etc/yum.repos.d/'

可以看到已经移动到 yuan.bak 文件下边

下载aliyuan

nim 复制代码
ansible slave -m shell -a ' wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo'

这里提醒我 可以使用get_url 模块 但是我使用 命令习惯了

警告:请考虑使用get_url或uri模块,而不是运行"wget"。如果需要

使用命令,因为get_url或uri不足,您可以将"warn:false"添加到此命令任务

或者在ansible.cfg中设置"command_warnings=False"以消除此消息。

检查下载

sh 复制代码
ansible slave -m shell -a 'ls /etc/yum.repos.d/'

可以看到已经下载到 aliyuan 的镜像了

清理缓存

sh 复制代码
ansible slave -m shell -a 'yum clean all'

生成缓存

sh 复制代码
ansible slave -m shell -a 'sed -i -e "/mirrors.cloud.aliyuncs.com/d" -e "/mirrors.aliyuncs.com/d" /etc/yum.repos.d/CentOS-Base.repo'

查看当前yum 源

sh 复制代码
ansible slave -m shell -a 'yum repolist'

更换成功

这里下载一个 tree 服务

安装扩展源

sh 复制代码
ansible slave -m yum -a 'name=epel-release state=present'

扩展源 安装成功

更换源之后 的三个命令

sh 复制代码
# 清理
yum clean all

# 缓存源 信息
yum makecache

# 查看源
yum repolist

补充完毕

相关推荐
爱网络爱Linux4 天前
RHCSA+RHCE 10.0全新升级!红帽Ansible自动化运维
运维·自动化·ansible·rhce认证·rhel1o·linux10·rhce10
码上上班9 天前
Ansible课程
ansible
至乐活着12 天前
Ansible自动化运维实战:从零部署高可用Nginx+静态网站集群
ansible·自动化运维·devops·playbook·配置管理
John Song14 天前
ansible-playbook常用的检查命令
windows·ansible
明航咨询_贾老师17 天前
RHCA Ansible高级自动化(DO374)认证信息整理
运维·自动化·ansible·rhca·红帽认证
有毒的教程21 天前
Ansible批量操作自动化完整教程:批量部署服务、配置同步、软件更新实战
运维·自动化·ansible
Hy行者勇哥1 个月前
用Cursor智能编写Ansible/Terraform脚本,打通CI/CD链路
ci/cd·ansible·terraform
芷栀夏1 个月前
飞牛NAS怎么部署Immich?家庭照片自动备份与远程访问教程
服务器·nginx·ansible
悠然南风1 个月前
Ansible常见模块总结及LDAP Role 编写与调试
ansible
祺风挽楠2 个月前
ansible编辑
网络·ansible