-
Notifications
You must be signed in to change notification settings - Fork 52
/
Copy pathplaybook-single.yml
149 lines (130 loc) · 4.17 KB
/
playbook-single.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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
---
##########
- name: Check installation
hosts: localhost
become: true
gather_facts: true
tasks:
- name: Ensure mkisofs and rsync is installed (Centos / RHEL)
yum:
name: "{{ packages }}"
become: true
delegate_to: localhost
vars:
packages:
- rsync
- genisoimage
when: ansible_distribution == 'CentOS' or ansible_distribution == 'Red Hat Enterprise Linux'
- name: Ensure mkisofs and rsync is installed (Ubuntu / Debian)
apt:
name: "{{ packages }}"
become: true
delegate_to: localhost
vars:
packages:
- rsync
- genisoimage
when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu'
##########
- name: Check the original RHCOS ISO
hosts: localhost
gather_facts: false
tasks:
- block:
- name: Create the download url (ppc64le)
set_fact:
dl_url: 'https://mirror.openshift.com/pub/openshift-v{{ ocp_version.split(".")[0] }}/ppc64le/dependencies/rhcos/{{ ocp_version.split(".")[0] }}.{{ ocp_version.split(".")[1] }}/{{ ocp_version }}/{{ iso_name_ppc64 }}'
my_iso: "{{ iso_name_ppc64 }}"
my_cksum: "{{ iso_checksum_ppc64 }}"
when: arch == 'ppc64le'
- name: Create the download url (x86_64)
set_fact:
dl_url: 'https://mirror.openshift.com/pub/openshift-v{{ ocp_version.split(".")[0] }}/dependencies/rhcos/{{ ocp_version.split(".")[0] }}.{{ ocp_version.split(".")[1] }}/{{ ocp_version }}/{{ iso_name }}'
my_iso: "{{ iso_name }}"
my_cksum: "{{ iso_checksum }}"
when: arch == 'x86_64'
- name: Check if ISO is already available
stat:
path: /tmp/{{ my_iso }}
checksum_algorithm: sha256
get_checksum: yes
register: iso_file
- name: Get the original ISO
get_url:
url: "{{ dl_url }}"
dest: /tmp
checksum: sha256:{{ my_cksum }}
when: not iso_file.stat.exists or iso_file.stat.checksum != my_cksum
- name: Mount ISO
mount:
src: /tmp/{{ my_iso }}
path: /mnt/iso
fstype: iso9660
opts: ro,noauto
state: mounted
become: true
- name: Copy contents of iso
synchronize:
src: /mnt/iso/
dest: /tmp/rhcos-iso/
##########
- name: Create the custom iso
hosts: all
order: sorted
gather_facts: false
tasks:
- name: Generate the webserver full path
set_fact:
webserver_ignition_fullpath: "http://{{ webserver_url }}:{{ webserver_port }}{{ webserver_ignition_path | default('') }}/"
# ppc64
- block:
- name: Relace the grub.cfg file (ppc64le)
template:
src: "grub.cfg-single.j2"
dest: /tmp/rhcos-iso/boot/grub/grub.cfg
- name: Create new ISO image (ppc64le)
command: >
/usr/bin/mkisofs -U -A 'RHCOS-CustomIso' -V 'RHCOS-CustomIso' -volset 'RHCOS-CustomIso' -J -joliet-long -r -v -T
-x ./lost+found -o /tmp/rhcos-install-cluster.iso -chrp-boot .
args:
chdir: /tmp/rhcos-iso/
become: true
delegate_to: localhost
when: arch == 'ppc64le'
# x86_64
- block:
- name: Relace the isolinux.cfg file (x86_64)
template:
src: "isolinux.cfg-single.j2"
dest: /tmp/rhcos-iso/isolinux/isolinux.cfg
- name: Relace the grub.cfg file (x86_64)
template:
src: "grub.cfg-single.j2"
dest: /tmp/rhcos-iso/EFI/redhat/grub.cfg
- name: Create new ISO image (x86_64)
command: >
/usr/bin/mkisofs -U -A 'RHCOS-CustomIso' -V 'RHCOS-CustomIso' -volset 'RHCOS-CustomIso' -J -joliet-long -r -v -T
-x ./lost+found -o /tmp/rhcos-install-cluster.iso -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 .
args:
chdir: /tmp/rhcos-iso/
become: true
delegate_to: localhost
when: arch == 'x86_64'
##########
- name: Cleanup tasks
hosts: localhost
gather_facts: false
tasks:
- block:
- name: Unmount ISO
mount:
path: /mnt/iso
state: absent
- name: Remove ISO copy
file:
path: /tmp/rhcos-iso
state: absent
become: true
...