Skip to content

Instantly share code, notes, and snippets.

@Thearas
Last active July 18, 2022 09:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Thearas/c1cf93e4c57ce3c6310f1c9a7bd03144 to your computer and use it in GitHub Desktop.
Save Thearas/c1cf93e4c57ce3c6310f1c9a7bd03144 to your computer and use it in GitHub Desktop.
Migrate redhat to centos8-stream
---
- hosts: jinshannew
vars:
remote_user: root
tasks:
- name: Remove the existing repos
file:
state: absent
path: /etc/yum.repos.d/centos-base.repo
- name: Creating /etc/yum.repos.d/elrepo.repo
copy:
dest: /etc/yum.repos.d/elrepo.repo
content: |
### Name: ELRepo.org Community Enterprise Linux Repository for el8
### URL: https://elrepo.org/
[elrepo]
name=ELRepo.org Community Enterprise Linux Repository - el8
baseurl=http://elrepo.org/linux/elrepo/el8/$basearch/
http://mirrors.coreix.net/elrepo/elrepo/el8/$basearch/
http://mirror.rackspace.com/elrepo/elrepo/el8/$basearch/
http://linux-mirrors.fnal.gov/linux/elrepo/elrepo/el8/$basearch/
mirrorlist=http://mirrors.elrepo.org/mirrors-elrepo.el8
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-elrepo.org
[elrepo-testing]
name=ELRepo.org Community Enterprise Linux Testing Repository - el8
baseurl=http://elrepo.org/linux/testing/el8/$basearch/
http://mirrors.coreix.net/elrepo/testing/el8/$basearch/
http://mirror.rackspace.com/elrepo/testing/el8/$basearch/
http://linux-mirrors.fnal.gov/linux/elrepo/testing/el8/$basearch/
mirrorlist=http://mirrors.elrepo.org/mirrors-elrepo-testing.el8
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-elrepo.org
[elrepo-kernel]
name=ELRepo.org Community Enterprise Linux Kernel Repository - el8
baseurl=http://mirrors.neusoft.edu.cn/elrepo/kernel/el8/x86_64/
http://mirrors.coreix.net/elrepo/kernel/el8/$basearch/
http://mirror.rackspace.com/elrepo/kernel/el8/$basearch/
http://linux-mirrors.fnal.gov/linux/elrepo/kernel/el8/$basearch/
#mirrorlist=http://mirrors.elrepo.org/mirrors-elrepo-kernel.el8
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-elrepo.org
[elrepo-extras]
name=ELRepo.org Community Enterprise Linux Extras Repository - el8
baseurl=http://elrepo.org/linux/extras/el8/$basearch/
http://mirrors.coreix.net/elrepo/extras/el8/$basearch/
http://mirror.rackspace.com/elrepo/extras/el8/$basearch/
http://linux-mirrors.fnal.gov/linux/elrepo/extras/el8/$basearch/
mirrorlist=http://mirrors.elrepo.org/mirrors-elrepo-extras.el8
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-elrepo.org
- name: Disable subscription-manager warning
copy:
dest: /etc/yum/pluginconf.d/subscription-manager.conf
content: |
[main]
enabled=0
disable_system_repos=0
- name: Downloading /etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
shell:
cmd: wget https://www.elrepo.org/RPM-GPG-KEY-elrepo.org && gpg --quiet --with-fingerprint RPM-GPG-KEY-elrepo.org
chdir: /etc/pki/rpm-gpg
- name: Change Repositories from Redhat's to CentOS
shell:
cmd: mv redhat.repo redhat.repo.backup || subscription-manager config --rhsm.manage_repos=0
chdir: /etc/yum.repos.d
- name: Update repo
shell: |
yum clean all
# dnf -y module disable container-tools
yum remove containers-common -y
yum update -y
# - name: Reinstall all packages
# shell: rpm -qa | sort | sed 's/-[0-9].*[0-9]*//g' | xargs yum reinstall -y && yum reinstall -y yum && yum erase dnf-plugin-subscription-manager
# - name: Install and start docker
# shell: |
# dnf config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo
# dnf repolist -v
# dnf -y module enable container-tools
# dnf -y install docker-ce --nobest
# systemctl enable --now docker
- name: Install Git
yum: name=git state=latest
- name: Reboot the machine
reboot:
reboot_timeout: 300
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment