Thank you the problem is before updating to Rhel 8 also when it reboots in
the last below task (line#99) the alternatives is updating to python3 link
which is not present . Do you suggest to use subscription module in line#79
instead of shell?
1. name: Get root volume size
2. set_fact:
3. root_size: "{{ (ansible_mounts |selectattr('mount', 'equalto',
'/') | list)[0].size_total }}"
4.
5. - name: Get root volume free size
6. set_fact:
7. root_available: "{{ (ansible_mounts |selectattr('mount',
'equalto', '/') | list)[0].size_available }}"
8.
9. - name: root filesystem expansion
10. block:
11.
12. - name: Calculte required additional root space
13. set_fact:
14. root_reqd: "{{ ((root_size | int + (4294967296 -
root_available | int)) / 1024 / 1024) | int }}"
15.
16. - name: Resize root filesystem to {{ root_reqd }}MB
17. lvol:
18. vg: rootvg
19. lv: LogVol00
20. size: "{{ root_reqd }}M"
21. resizefs: true
22.
23. when: root_available | int < 4294967296
24.
25. - name: Get /var volume size
26. set_fact:
27. var_size: "{{ (ansible_mounts |selectattr('mount', 'equalto',
'/var') | list)[0].size_total }}"
28.
29. - name: Get /var volume free size
30. set_fact:
31. var_available: "{{ (ansible_mounts |selectattr('mount',
'equalto', '/var') | list)[0].size_available }}"
32.
33. - name: /var filesystem expansion
34. block:
35.
36. - name: Calculte required additional var space
37. set_fact:
38. var_reqd: "{{ ((var_size | int + (5368709120 - var_available
| int)) / 1024 / 1024) | int }}"
39.
40. - name: Resize /var filesystem to {{ var_reqd }}MB
41. lvol:
42. vg: rootvg
43. lv: LogVol03
44. size: "{{ var_reqd }}M"
45. resizefs: true
46.
47. when: var_available | int < 5368709120
48.
49. #### Pre-upgrade tasks ####
50. - name: Remove unwanted packages
51. yum:
52. name: "{{ item }}"
53. state: absent
54. loop: "{{ remove_rpms }}"
55.
56. - name: Remove unwanted data
57. file:
58. path: "{{ item }}"
59. state: absent
60. loop: "{{ remove_files }}"
61.
62. - name: Get contents of /usr/openv/ folder
63. find:
64. paths: /usr/openv/
65. file_type: any
66. register: openv
67.
68. - name: Remove contents of /usr/openv/ folder
69. file:
70. path: "{{ item.path }}"
71. state: absent
72. loop: "{{ openv.files }}"
73. loop_control:
74. label: "{{ item.path }}"
75.
76. - name: Subscribe to RHEL7 Repo
77. shell: |
78. yum clean all
79. subscription-manager register --org="Xxxxx"
--activationkey="rhel7-prod" --force
80.
81. - name: Yum update
82. yum:
83. state: latest
84.
85. - name: Backup /etc/fstab file
86. copy:
87. src: /etc/fstab
88. dest: /etc/fstab.PreUpgrade
89. remote_src: yes
90. force: false
91.
92. - name: Remove non system entries from /etc/fstab
93. shell: |
94. cat /etc/fstab|egrep -w '/ |/opt |/boot |/tmp |/var |swap |^#' >
/tmp/fstab
95. /bin/cp /tmp/fstab /etc/fstab
96.
97. - debug: var=ansible_python_version
98.
99. - name: Reboot server
100. reboot:
101. reboot_timeout: 3600
102.
103. - debug: var=ansible_python_version
104.
105. #### Leapp pre-upgrade tasks ####
106. - name: Unsubscribe from satellite
107. shell: |
108. yum clean all
109. subscription-manager unsubscribe --all
110. subscription-manager clean
Regards
On Thu, 22 Feb 2024 at 05:00, Evan Hisey <[email protected]> wrote:
> That is a Rhel7 to RHEL 8 change. The default python in REHL7 is Python
> 2.7 while RHEL 8 is python3.6. I would also consider moving the
> subscription tasks to community.general.redhat_subscription module. That
> is should automatically change python version, but you may need to
> disconnect and reconnect to update the user environment.
>
> On Wed, Feb 21, 2024 at 5:07 AM Prady A <[email protected]> wrote:
>
>> Hello all,
>>
>>
>> Upgrading from Rhel7-> 8 using ansible. In the pre upgrade task I
>> performed few checks like space check and yum update and
>> subscription-manager registration. No issues in the beginning tasks..
>>
>> But when performing below task post reboot task Shell:
>> Yum clean all
>> Subscription-manager unsubscribe —all
>> Subscription-manager clean
>>
>> * It is giving me no such file /usr/bin/python *
>>
>> Before running the job In RHEl 7 the python version was pointing to
>>
>> Python2 /usr/bin/python-> /etc/alternatives/python
>> /etc/alternatives/python -> /usr/bin/python2
>>
>> but after the above task is executed somehow it is changing to
>> /usr/bin/python-> /etc/alternatives/python /etc/alternatives/python ->
>> /usr/bin/python3
>>
>> When I performed manually the task command there is no issue .. could
>> you pls suggest..
>>
>> Regards
>> PD
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Ansible Project" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/ansible-project/CAEuB3ApKqRhVmC3DzvX-EpBpebQCk5EKEq3CWkRv_uGH1ni50A%40mail.gmail.com
>> <https://groups.google.com/d/msgid/ansible-project/CAEuB3ApKqRhVmC3DzvX-EpBpebQCk5EKEq3CWkRv_uGH1ni50A%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/CAEcFzYze6zADiEdjcLWUnoN4s5b42bXnmqdkBttF4nQCmYvozQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/ansible-project/CAEcFzYze6zADiEdjcLWUnoN4s5b42bXnmqdkBttF4nQCmYvozQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/CAEuB3ApMvbk3iOXOHSzKFDixNkcGnnz6XiPhbuRiGmDnAH8QkA%40mail.gmail.com.