-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrhel-to-oel-switch.yaml
53 lines (42 loc) · 1.81 KB
/
rhel-to-oel-switch.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
- hosts: all
become: yes
become_user: root
become_method: sudo
remote_user: sys-admin
vars:
rhel_release:
- redhat-release
- redhat-release-eula
tasks:
- name: Uninstall unnecessary Packages
shell: rpm -e --nodeps {{ rhel_release }}
- name: Install Oracle Linux Release for OEL 7
shell: rpm -i https://yum.oracle.com/repo/OracleLinux/OL7/latest/x86_64/getPackage/oraclelinux-release-el7-1.0-17.el7.x86_64.rpm
when: (ansible_facts['distribution'] == "RedHat" and ansible_facts['distribution_major_version'] == "7")
- name: Install Oracle Linux Release for OEL 8
shell: rpm -i https://yum.oracle.com/repo/OracleLinux/OL8/baseos/latest/x86_64/getPackage/oraclelinux-release-el8-1.0-38.el8.x86_64.rpm
when: (ansible_facts['distribution'] == "RedHat" and ansible_facts['distribution_major_version'] == "8")
- name: Install Oracle Linux Release for OEL 9
shell: rpm -i https://yum.oracle.com/repo/OracleLinux/OL9/baseos/latest/x86_64/getPackage/oraclelinux-release-el9-1.0-15.el9.x86_64.rpm
when: (ansible_facts['distribution'] == "RedHat" and ansible_facts['distribution_major_version'] == "9")
- name: Install oraclelinux-release package
yum:
name: oraclelinux-release
state: latest
- name: Switch OS from RHEL to OEL
shell: yum -y distro-sync
- name: Remove Unnecessary Pacakages
yum:
name:
- subscription-manager
- insights-client
state: absent
- name: Rebuild the initial RAM filesystem
shell: dracut -f
- name: Reboot Machine after OS Version Switch
reboot:
pre_reboot_delay: 5
post_reboot_delay: 30
reboot_timeout: 300
msg: "Reboot initiated by Ansible after OS Version Switch"
test_command: w