-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathprep-rhvh-pxe.yml
89 lines (76 loc) · 3.17 KB
/
prep-rhvh-pxe.yml
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
# TODO: mount /nas/ISOs/RHVH.iso at /var/www/html/rhvh (because inst.stage2 -- grub.cfg-- expects it there)
#
# 6.1.3.2.1 - Preparing the Installation Environment
# https://access.redhat.com/documentation/en-us/red_hat_virtualization/4.3/html-single/installing_red_hat_virtualization_as_a_self-hosted_engine_using_the_cockpit_web_interface/index#Advanced_RHVH_Install_SHE_cockpit_deploy
---
- hosts: localhost
gather_facts: no
vars_prompt:
- prompt: "Where is the source RHVH ISO file?"
name: iso_location
default: "/nas/ISOs/RHVH-4.3-20190512.3-RHVH-x86_64-dvd1.iso"
private: no
- prompt: "Where should I put the vmlinuz/initrd.img files --PXE/tftpboot location--"
name: tftp_location
default: "/var/lib/tftpboot/"
private: no
- prompt: "Where should I put the (large) hypervisor image --HTTP/HTML location--"
name: http_location
default: "/var/www/html/"
private: no
tasks:
- name: Get version number from ISO name (e.g. RHVH-4.3-20190512.3)
set_fact:
rhvh_version: "{{ iso_location | regex_search('RHVH-[0-9.-]+') | regex_replace('([^0-9a-z])$') }}"
- name: Create a temporary directory
command: mktemp -d
register: results
- set_fact:
tmp_location: "{{ results.stdout }}"
no_log: true
- name: List ISO's table of contents
command: isoinfo -R -f -i {{ iso_location }}
register: iso_contents
- name: Find which RPM has the squashfs.img (RHVH image)
set_fact:
hypervisor_image_rpm: "{{ iso_contents.stdout | regex_search('^.*host-image.*$', multiline=true) }}"
- name: Extract the ks.cfg, vmlinuz, initrd.img and RHVH images
shell: isoinfo -R -i {{ iso_location }} -x {{ item.source }} > {{ item.dest }}
loop:
- { source: "/ks.cfg", dest: "{{ http_location }}/ks.cfg-{{ rhvh_version }}" }
- { source: "/images/pxeboot/vmlinuz", dest: "{{ tftp_location }}/vmlinuz-{{ rhvh_version }}" }
- { source: "/images/pxeboot/initrd.img", dest: "{{ tftp_location }}/initrd.img-{{ rhvh_version }}" }
- { source: "{{ hypervisor_image_rpm }}", dest: "{{ tmp_location }}/{{ hypervisor_image_rpm | basename }}" }
- name: Pull the squashfs.img out of the RPM (cpio copy-in mode)
shell: rpm2cpio "{{ hypervisor_image_rpm | basename }}" | cpio -dimv "*squashfs.img"
args:
chdir: "{{ tmp_location }}"
register: results
- name: Get the name and path of the squashfs.img (from stderr)
set_fact:
squashfs_image: "{{ results.stderr | regex_search('^.*squashfs.img$', multiline=true) }}"
- name: Move the squashfs.img into place
copy:
remote_src: true
src: "{{ tmp_location }}/{{ squashfs_image }}"
dest: "{{ http_location }}"
- name: Cleanup temporary directory
file:
path: "{{ tmp_location }}"
state: absent
- name: Remove previous stage2 ISO mount
become: true
mount:
path: /var/www/html/rhvh
state: absent
- name: Create new stage2 ISO mount
become: true
mount:
path: /var/www/html/rhvh
src: "{{ iso_location }}"
fstype: iso9660
state: mounted
- debug:
msg: |
Please make sure to update {{ tftp_location }}grub.cfg
and any url=... references in your kickstart file