-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild-lunchbox-iso.yml
126 lines (106 loc) · 4.35 KB
/
build-lunchbox-iso.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
---
- hosts: localhost
become: yes
vars:
local_home: "{{ lookup('env','HOME') }}"
custom_install_image_src_iso: rhel-8.1-x86_64-dvd.iso
custom_install_image_dst_iso: lunchbox-8.1-x86_64-dvd.iso
custom_install_image_ks_file: lunchbox-ks.cfg
custom_install_image_label: "Lunchbox_8.1"
custom_install_image_menu_label: "Lunchbox 8.1"
tasks:
- name: Check if src iso exists
stat:
path: "{{ local_home }}/{{ custom_install_image_src_iso }}"
get_checksum: no
get_md5: no
get_mime: no
get_attributes: no
register: custom_install_image_src_iso_stat
- name: fail if src iso doesn't exist
fail:
msg: "{{ local_home }}/{{ custom_install_image_src_iso }} not found"
when: not custom_install_image_src_iso_stat.stat.exists
- name: check if ks file exists
stat:
path: "{{ custom_install_image_ks_file }}"
get_checksum: no
get_md5: no
get_mime: no
get_attributes: no
register: custom_install_image_ks_file_stat
- name: fail if ks file doesn't exist
fail:
msg: "{{ custom_install_image_ks_file }} not found"
when: not custom_install_image_ks_file_stat.stat.exists
- name: install required packages
package:
name:
- mkisofs
- syslinux
- isomd5sum
state: present
- name: Create temporary directory
tempfile:
state: directory
register: custom_install_image_temp_dir
- name: Create src_iso mount point
file:
state: directory
path: "{{ custom_install_image_temp_dir.path }}/src_files"
- name: Create dst_files build dir
file:
state: directory
path: "{{ custom_install_image_temp_dir.path }}/dst_files"
- name: mount src_iso
command: "mount -oloop,ro {{ local_home }}/{{ custom_install_image_src_iso }} {{ custom_install_image_temp_dir.path }}/src_files"
args:
warn: false
- name: rsync src_files to dst_files
synchronize:
src: "{{ custom_install_image_temp_dir.path }}/src_files/"
dest: "{{ custom_install_image_temp_dir.path }}/dst_files"
- name: copy ks file
copy:
src: "{{ custom_install_image_ks_file }}"
dest: "{{ custom_install_image_temp_dir.path }}/dst_files/lunchbox-ks.cfg"
- name: remove troubleshooting section
replace:
path: "{{ custom_install_image_temp_dir.path }}/dst_files/EFI/BOOT/grub.cfg"
regexp: "^submenu(.*\n)*"
replace: ""
- name: change default selection
replace:
path: "{{ custom_install_image_temp_dir.path }}/dst_files/EFI/BOOT/grub.cfg"
regexp: "^set default.*$"
replace: 'set default="0"'
- name: replace RHEL disk label
replace:
path: "{{ custom_install_image_temp_dir.path }}/dst_files/EFI/BOOT/grub.cfg"
regexp: "RHEL.8\\.1(\\\\x20)?( )?Server\\.x86_64"
replace: "{{ custom_install_image_label }}"
- name: add in kickstart references
replace:
path: "{{ custom_install_image_temp_dir.path }}/dst_files/EFI/BOOT/grub.cfg"
regexp: "(inst\\.[^ ]* )+"
replace: "inst.stage2=hd:LABEL={{ custom_install_image_label }} inst.ks=hd:LABEL={{ custom_install_image_label }}:/lunchbox-ks.cfg "
- name: replace menu label
replace:
path: "{{ custom_install_image_temp_dir.path }}/dst_files/EFI/BOOT/grub.cfg"
regexp: "^(menuentry.+?nstall ).+?('.*)$"
replace: '\1{{ custom_install_image_menu_label }}\2'
- name: create dst_iso
command: >
mkisofs -r -T -J -V '{{ custom_install_image_label }}' -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot
-boot-load-size 4 -boot-info-table -eltorito-alt-boot -e images/efiboot.img -no-emul-boot
-o {{ local_home }}/{{ custom_install_image_dst_iso }} {{ custom_install_image_temp_dir.path }}/dst_files
- name: make dst_iso hybrid
command: "isohybrid {{ local_home }}/{{ custom_install_image_dst_iso }}"
- name: update dst_iso md5 checksum
command: "implantisomd5 {{ local_home }}/{{ custom_install_image_dst_iso }}"
- name: unmount src_iso
command: "umount -R -d {{ custom_install_image_temp_dir.path }}/src_files"
- name: delete temporary directories
file:
state: absent
path: "{{ custom_install_image_temp_dir.path }}"