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'
相关推荐
The star"'1 天前
04-管理变量和事实
运维·云计算·ansible
tzhou644521 天前
自动化运维利器Ansible
运维·自动化·ansible
可爱又迷人的反派角色“yang”1 天前
ansible的概念及基本操作(一)
运维·ansible
乾元2 天前
网络遥测(Telemetry/gNMI)的结构化建模与特征化体系—— 从“采集指标”到“可被 AI 推理的状态向量”
运维·服务器·网络·人工智能·网络协议·华为·ansible
原神启动12 天前
Ansible(一)—— 自动化运维工具 Ansible:集中化管理服务器
运维·自动化·ansible
The star"'2 天前
02-Ansible 基本使用
运维·云计算·ansible
元气满满-樱2 天前
Ansible变量定义以及引用
ansible
Xyz996_2 天前
Ansible进行Nginx编译安装的详细步骤
运维·ansible
元气满满-樱4 天前
ansible-hoc 模块使用
运维·ansible
南山nash4 天前
Ansible安装使用详细教程
ansible