-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathapply-rpm-patch.yml
More file actions
83 lines (71 loc) · 2.93 KB
/
Copy pathapply-rpm-patch.yml
File metadata and controls
83 lines (71 loc) · 2.93 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
---
- name: Install RPM package on OpenShift nodes using rpm-ostree
hosts: "{{ target_hosts | default('all') }}"
remote_user: core
tasks:
- name: Store RPM full path in a registry
stat:
path: "{{ rpm_full_path }}"
register: rpm_file
delegate_to: localhost
run_once: true
- name: Fail if RPM file does not exist
fail:
msg: "RPM file '{{ rpm_full_path }}' not found on localhost at: {{ rpm_file.stat.path | default(rpm_full_path) }}"
when: not rpm_file.stat.exists
run_once: true
- name: Copy RPM file to nodes
copy:
src: "{{ rpm_full_path }}"
dest: /var/home/core/
owner: core
group: core
register: copy_result
- name: Install RPM package using rpm-ostree
command: rpm-ostree -C override replace /var/home/core/{{ rpm_package }}
register: rpm_ostree_result
async: 600 # 10 minutes timeout
poll: 30 # check every 30 seconds
become: yes
- name: Display rpm-ostree command output
debug:
msg: |
Command: {{ rpm_ostree_result.cmd }}
Return code: {{ rpm_ostree_result.rc }}
STDOUT: {{ rpm_ostree_result.stdout }}
STDERR: {{ rpm_ostree_result.stderr }}
when: rpm_ostree_result is defined
- name: Reboot nodes to apply changes
reboot:
msg: "Rebooting node to apply rpm-ostree changes"
connect_timeout: 5
reboot_timeout: 600 # Extended timeout for ostree boot
pre_reboot_delay: 10
post_reboot_delay: 60 # Wait longer after reboot
test_command: podman exec etcd etcdctl member list
throttle: 1 # Reboot one node at a time
become: yes
- name: Gather package facts after reboot
package_facts:
manager: rpm
- name: Extract expected RPM name without .rpm extension
set_fact:
expected_rpm_name: "{{ rpm_package | regex_replace('\\.rpm$', '') }}"
- name: Verify resource-agents package is installed
assert:
that:
- "'resource-agents' in ansible_facts.packages"
fail_msg: "resource-agents package not found in installed packages"
success_msg: "resource-agents package is installed"
- name: Extract installed version string
set_fact:
installed_version: "resource-agents-{{ ansible_facts.packages['resource-agents'][0].version }}-{{ ansible_facts.packages['resource-agents'][0].release }}.{{ ansible_facts.packages['resource-agents'][0].arch }}"
- name: Verify installed version matches expected version
assert:
that:
- installed_version == expected_rpm_name
fail_msg: "Version mismatch! Expected: {{ expected_rpm_name }}, but found: {{ installed_version }}"
success_msg: "Successfully verified installation: {{ installed_version }}"
vars:
rpm_full_path: "{{ rpm_full_path | default(lookup('env', 'RPM_FULL_PATH')) }}"
rpm_package: "{{ rpm_full_path | basename }}"