-
Notifications
You must be signed in to change notification settings - Fork 3
/
install.yaml
108 lines (93 loc) · 4.24 KB
/
install.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
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
---
- hosts: guest
vars:
os: "{{ lookup('env', 'TEST_OS') }}"
gcp_project: "{{ lookup('env', 'GCP_PROJECT') }}"
aws_region: "{{ lookup('env', 'AWS_REGION') }}"
aws_profile: "default"
vsphere_server: "{{ lookup('env', 'VSPHERE_SERVER') }}"
vsphere_username: "{{ lookup('env', 'VSPHERE_USERNAME') }}"
vsphere_password: "{{ lookup('env', 'VSPHERE_PASSWORD') }}"
esxi_datacenter: "{{ lookup('env', 'ESXI_DATACENTER') }}"
tasks:
- name: copy kernel to guest
copy:
src: "{{ kernel_folder }}"
dest: "/home/admin"
- block:
- name: apply new SELinux file context to /var/lib/rpm
command: restorecon -Rv /var/lib/rpm
become: yes
when:
- "'rhel-9' in os"
- cloud_platform == "esxi"
- name: converting database from bdb_ro to sqlite backend
command: rpmdb --rebuilddb
become: yes
when:
- "'rhel-9' in os"
- cloud_platform == "esxi"
- name: install kernel on guest
dnf:
name: "/home/admin/{{ cloud_platform }}-{{ kernel_nvr }}/kernel-{{ kernel_nvr }}.rpm, /home/admin/{{ cloud_platform }}-{{ kernel_nvr }}/kernel-core-{{ kernel_nvr }}.rpm, /home/admin/{{ cloud_platform }}-{{ kernel_nvr }}/kernel-modules-{{ kernel_nvr }}.rpm, /home/admin/{{ cloud_platform }}-{{ kernel_nvr }}/kernel-modules-extra-{{ kernel_nvr }}.rpm"
state: present
allow_downgrade: yes
disable_gpg_check: yes
become: yes
- name: reboot guest for new kernel to make effect
reboot:
reboot_timeout: 1200
become: yes
always:
- block:
- name: get boot diagnostic logs uri
command: /usr/bin/az vm boot-diagnostics get-boot-log-uris --resource-group {{ resource_group_name }} --name {{ instance }}
register: result_diag_log_uri
- set_fact:
screenshot_uri: "{{ result_diag_log_uri.stdout | from_json | json_query('consoleScreenshotBlobUri') }}"
seriallog_uri: "{{ result_diag_log_uri.stdout | from_json | json_query('serialConsoleLogBlobUri') }}"
- name: download screenshot bmp file
get_url:
url: "{{ screenshot_uri }}"
dest: "{{ playbook_dir }}/{{ instance_type }}-upgrade-screenshot.bmp"
- name: download serial console log
get_url:
url: "{{ seriallog_uri }}"
dest: "{{ playbook_dir }}/{{ instance_type }}-upgrade-serial-console.log"
when: cloud_platform == "azure"
ignore_errors: true
delegate_to: localhost
- name: gcp check and save the progress of an instance using
shell: gcloud compute instances get-serial-port-output {{ instance }} --zone=us-central1-a --project={{ gcp_project }} > {{ instance_type }}.upgrade.serial.log
delegate_to: localhost
when: cloud_platform == "gcp"
ignore_errors: true
- name: aws check and save the progress of an instance using
shell: aws --profile {{ aws_profile }} --region {{ aws_region }} ec2 get-console-output --instance-id {{ instance }} --output text > {{ instance_type }}.upgrade.serial.log
delegate_to: localhost
when: cloud_platform == "aws"
ignore_errors: true
- name: esxi take guest screenshoot
community.vmware.vmware_guest_screenshot:
hostname: "{{ vsphere_server }}"
username: "{{ vsphere_username }}"
password: "{{ vsphere_password }}"
datacenter: "{{ esxi_datacenter }}"
uuid: "{{ instance }}"
validate_certs: no
local_path: "{{ playbook_dir }}"
delegate_to: localhost
when: cloud_platform == "esxi"
ignore_errors: true
- name: get current kernel version
shell: uname -r
register: kernel_version
- name: show current kernel version
debug:
var: kernel_version.stdout
- name: checking kernel version
assert:
that:
- kernel_version.stdout == kernel_nvr
fail_msg: "Upgrade kernel to {{ kernel_nvr }} failed"
success_msg: "Upgrade kernel to {{ kernel_version.stdout }}"