RHEC——ansible配置yum源仓库

1.挂载本地光盘到/mnt

2.配置yum源仓库文件通过多种方式实现

        1)、仓库1 : Name: RH294_Base Description: RH294 base software Base urt: file:///mnt/BaseOS 不需要验证钦件包 GPG 签名 启用此软件仓库

        2)、仓库 2: Name: RH294_Stream Description : RH294 stream software Base url:file:///mnt/AppStream 不需要验证软件包 GPG 签名

3.配置成功后安装http软件包(多种方法实现)


1.挂载本地光盘到/mnt

挂载成功

2.配置yum源仓库文件通过多种方式实现

        1)、仓库1 : Name: RH294_Base Description: RH294 base software Base urt: file:///mnt/BaseOS 不需要验证钦件包 GPG 签名 启用此软件仓库

[root@server ~]#  ansible node1,node2 -m yum_repository -a 'name=BaseOS description=RHEL8-Base baseurl=file://mnt/BaseOS gpgcheck=no file=BaseOS'

        2)、仓库 2: Name: RH294_Stream Description : RH294 stream software Base url:file:///mnt/AppStream 不需要验证软件包 GPG 签名

[root@server ~]#  ansible node1,node2 -m yum_repository -a 'name=AppStream description=RHEL8-app baseurl=file://mnt/AppStream gpgcheck=no file=AppStream'

                       控制端主机编辑配置文件发送到受控主机

[root@server ~]# vim base.repo
    [BaseOS]
    name=BaseOS
    baseurl=file:///mnt/BaseOS
    gpgcheck=0
    [Appstream]
    name=AppStream
    baseurl=file:///mnt/AppSrteam
    gpgcheck=0

                        使用 copy 和synchronize模块建库

[root@server ~]# ansible node1,node2 -m copy -a 'src=./base.repo dest=/etc/yum.repos.d/ force=yes backup=yes'
node2 | CHANGED => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/libexec/platform-python"
    },
    "backup_file": "/etc/yum.repos.d/base.repo.13081.2023-01-05@16:37:14~",
    "changed": true,
    "checksum": "ada65dec1a1a979483a7a9e4b5017e90ab2571ba",
    "dest": "/etc/yum.repos.d/base.repo",
    "gid": 0,
    "group": "root",
    "md5sum": "d79def8d3375d7c914270323798e4660",
    "mode": "0644",
    "owner": "root",
    "secontext": "unconfined_u:object_r:system_conf_t:s0",
    "size": 151,
    "src": "/root/.ansible/tmp/ansible-tmp-1672907833.7229834-46769-196696496066083/source",
    "state": "file",
    "uid": 0
}
node1 | CHANGED => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/libexec/platform-python"
    },
    "backup_file": "/etc/yum.repos.d/base.repo.16334.2023-01-05@16:37:14~",
    "changed": true,
    "checksum": "ada65dec1a1a979483a7a9e4b5017e90ab2571ba",
    "dest": "/etc/yum.repos.d/base.repo",
    "gid": 0,
    "group": "root",
    "md5sum": "d79def8d3375d7c914270323798e4660",
    "mode": "0644",
    "owner": "root",
    "secontext": "unconfined_u:object_r:system_conf_t:s0",
    "size": 151,
    "src": "/root/.ansible/tmp/ansible-tmp-1672907833.8494093-46767-115492435434508/source",
    "state": "file",
    "uid": 0
}

[root@server ~]# ansible node1,node2 -m synchronize -a 'src=./base.repo dest=/etc/yum.repos.d/ mode=push'
node2 | CHANGED => {
    "changed": true,
    "cmd": "/usr/bin/rsync --delay-updates -F --compress --archive --rsh='/usr/bin/ssh -S none -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null' --out-format='<<CHANGED>>%i %n%L' /root/base.repo node2:/etc/yum.repos.d/",
    "msg": "<f..t...... base.repo\n",
    "rc": 0,
    "stdout_lines": [
        "<f..t...... base.repo"
    ]
}
node1 | CHANGED => {
    "changed": true,
    "cmd": "/usr/bin/rsync --delay-updates -F --compress --archive --rsh='/usr/bin/ssh -S none -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null' --out-format='<<CHANGED>>%i %n%L' /root/base.repo node1:/etc/yum.repos.d/",
    "msg": "<f..t...... base.repo\n",
    "rc": 0,
    "stdout_lines": [
        "<f..t...... base.repo"
    ]
}
[root@server ~]# 

                        创建文件使用blockinfile建库

[root@server ~]# ansible node1,node2 -m file -a 'path=/etc/yum.repos.d/base.repo state=touch'

node2 | CHANGED => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/libexec/platform-python"
    },
    "changed": true,
    "dest": "/etc/yum.repos.d/base.repo",
    "gid": 0,
    "group": "root",
    "mode": "0644",
    "owner": "root",
    "secontext": "unconfined_u:object_r:system_conf_t:s0",
    "size": 151,
    "state": "file",
    "uid": 0
}
node1 | CHANGED => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/libexec/platform-python"
    },
    "changed": true,
    "dest": "/etc/yum.repos.d/base.repo",
    "gid": 0,
    "group": "root",
    "mode": "0644",
    "owner": "root",
    "secontext": "unconfined_u:object_r:system_conf_t:s0",
    "size": 151,
    "state": "file",
    "uid": 0
}
[root@server ~]# ansible node1,node2 -m blockinfile -a 'path=/etc/yum.repos.d/base.repo block="[baseOS]\name=base\nbaseurl=file:///mnt/BaseOS\ngpgcheck=0\n[APPStream]\n..." marker="#{mark} yum con" insertbefore=BOF state=present'
node2 | CHANGED => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/libexec/platform-python"
    },
    "changed": true,
    "msg": "Block inserted"
}
node1 | CHANGED => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/libexec/platform-python"
    },
    "changed": true,
    "msg": "Block inserted"
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值