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'
相关推荐
淼淼爱喝水1 天前
Ansible 入门实战:四种变量优先级比较实验
ansible·变量
淼淼爱喝水1 天前
ansible实战:「磁盘空间 ≥ 2G 时自动创建文件」
前端·ansible·自动创建
红茶要加冰2 天前
四、ansible的templates
linux·运维·服务器·ansible
红茶要加冰2 天前
五、ansible的流程控制
linux·运维·服务器·ansible
Cat_Rocky2 天前
Linux学习-ansible自动化
linux·学习·ansible
大白菜和MySQL3 天前
ansible使用简记
ansible
灰色人生qwer3 天前
入门 Ansible
ansible·ansible tower
终端行者4 天前
企业级Jenkins Pipeline 实战 Docker构建+Ansible发布
ci/cd·docker·ansible·jenkins
悠悠121385 天前
Jenkins + Ansible 集成实战:把配置管理焊进流水线里
运维·ansible·jenkins
JiaWen技术圈5 天前
IaC 双引擎:Terraform + Ansible 完整最佳实践
云原生·ansible·terraform