Ansible 临时命令搭建安装仓库

创建一个名为/ansible/yum.sh 的 shell 脚本,该脚本将使用 Ansible 临时命令在各个受管节点上安装 yum 存储库.

存储库1:

存储库的名称为 EX294_BASE

描述为 EX294 base software

基础 URL 为 http://content/rhel8.0/x86_64/dvd/BaseOS

GPG 签名检查为启用状态

GPG 密钥 URL 为 http://content/rhel8.0/x86_64/dvd/RPM-GPG-KEY-redhat-release

存储库为启用状态

存储库2:

存储库的名称为 EX294_STREAM

描述为 EX294 stream software

基础 URL 为 http://content/rhel8.0/x86_64/dvd/AppStream

GPG 签名检查为启用状态

GPG 密钥 URL 为 http://content/rhel8.0/x86_64/dvd/RPM-GPG-KEY-redhat-release

存储库为启用状态

bash 复制代码
#创建文件yum.sh(注意在ansible目录下)

vim yum.sh


#根据要求内容如下(注意其中不能乱有空格出现)

#!/bin/bash

ansible all -m yum_repository -a 'name=EX294_BASE description="EX294 base software" \
        baseurl=http://content/rhel8.0/x86_64/dvd/BaseOS \
        gpgcheck=yes \
        gpgkey=http://content/rhel8.0/x86_64/dvd/RPM-GPG-KEY-redhat-release \
        enabled=yes'

ansible all -m yum_repository -a 'name=EX294_STREAM description="EX294 stream software" \
        baseurl=http://content/rhel8.0/x86_64/dvd/AppStream \
        gpgcheck=yes \
        gpgkey=http://content/rhel8.0/x86_64/dvd/RPM-GPG-KEY-redhat-release \
        enabled=yes'

#给予运行权限

chmod +x yum.sh

#运行脚本

bash yum.sh

出现类似主机完成即可

bash 复制代码
#临时命令查看

ansible all -m shell -a 'yum repolist'
相关推荐
庸子9 小时前
Ansible & AWX 自动化运维
运维·自动化·ansible
孙克旭_6 天前
day051-ansible循环、判断与jinja2模板
linux·运维·服务器·网络·ansible
leo__5208 天前
自动化运维:使用Ansible简化日常任务
运维·自动化·ansible
风清再凯13 天前
自动化工具ansible,以及playbook剧本
运维·自动化·ansible
IT乌鸦坐飞机13 天前
ansible部署数据库服务随机启动并创建用户和设置用户有完全权限
数据库·ansible·centos7
遇见火星1 个月前
如何使用Ansible一键部署MinIO集群?
ansible
粥周粥1 个月前
ANSIBLE
ansible
码农101号1 个月前
Linux中ansible模块补充和playbook讲解
linux·运维·ansible
码农101号1 个月前
Linux的Ansible软件基础使用讲解和ssh远程连接
ansible
烟雨书信1 个月前
ANSIBLE运维自动化管理端部署
运维·自动化·ansible