Compare commits

...

2 Commits

Author SHA1 Message Date
767362aceb
Various image building changes
* Add UBI container specification
* Change ouput path to simplify copying operations
* Install patches for imagefactory and fixed version of oz for RHEL in
  container
    * Please ignore the RPM in this repo for now...
* Add conversion steps for Vagrant, EC2 images
* Fix KSes if they have a $basearch variable by subtitution
* Add usefbx variable to ensure we have an output for debugging
2022-07-08 13:30:15 -04:00
9e9955a0de
Fix names for jobs 2022-07-08 13:28:44 -04:00
8 changed files with 62 additions and 15 deletions

View File

@ -1,5 +1,5 @@
--- ---
name: Build empanada container images name: Build empanada images for imagefactory
on: on:
push: push:

View File

@ -1,5 +1,5 @@
--- ---
name: Build empanada container images name: Build empanada container images for lorax
on: on:
push: push:

View File

@ -43,6 +43,12 @@ RUN dnf install -y \
RUN sed -i -e 's/# memory = 1024/memory = 2048/' /etc/oz/oz.cfg RUN sed -i -e 's/# memory = 1024/memory = 2048/' /etc/oz/oz.cfg
COPY imagefactory.patch /
COPY oz.rpm /
RUN dnf -y install /oz.rpm
RUN (cd /usr/lib/python3.10/site-packages/; patch -p1 </imagefactory.patch)
RUN ssh-keygen -t rsa -q -f "$HOME/.ssh/id_rsa" -N "" RUN ssh-keygen -t rsa -q -f "$HOME/.ssh/id_rsa" -N ""
RUN dnf clean all RUN dnf clean all
RUN rm -rf /etc/yum.repos.d/*.repo /get_arch RUN rm -rf /etc/yum.repos.d/*.repo /get_arch
@ -52,7 +58,7 @@ RUN rm -rf /etc/yum.repos.d/*.repo /get_arch
RUN pip install awscli RUN pip install awscli
ENV BRANCH r9 ENV BRANCH r9
RUN git clone https://git.rockylinux.org/rocky/kickstarts.git --branch $BRANCH /kickstarts RUN git clone https://git.resf.org/sig_core/kickstarts.git --branch $BRANCH /kickstarts
# devel only # devel only
# COPY . /empanadas # COPY . /empanadas

View File

@ -103,7 +103,7 @@ for conf in glob.iglob(f"{_rootdir}/sig/*.yaml"):
ALLOWED_TYPE_VARIANTS = { ALLOWED_TYPE_VARIANTS = {
"Azure": None, "Azure": None,
"Container": ["Base", "Minimal"], "Container": ["Base", "Minimal", "UBI"],
"EC2": None, "EC2": None,
"GenericCloud": None, "GenericCloud": None,
"Vagrant": ["Libvirt", "VBox"] "Vagrant": ["Libvirt", "VBox"]

View File

@ -84,8 +84,7 @@ class ImageBuild:
if not self.tdl_path: if not self.tdl_path:
exit(2) exit(2)
self.type_variant = self.type_variant_name() self.type_variant = self.type_variant_name()
self.outname = self.output_name() self.outdir, self.outname = self.output_name()
self.outdir = pathlib.Path(f"/tmp/{self.outname}")
self.out_type = self.image_format() self.out_type = self.image_format()
self.command_args = self._command_args() self.command_args = self._command_args()
self.package_args = self._package_args() self.package_args = self._package_args()
@ -94,14 +93,29 @@ class ImageBuild:
self.metadata = pathlib.Path(self.outdir, "metadata.json") self.metadata = pathlib.Path(self.outdir, "metadata.json")
if self.image_type == "Container": # Yes, this is gross. I'll fix it later.
if self.image_type in ["Container"]:
self.stage_commands = [ self.stage_commands = [
["tar", "-C", f"{self.outdir}", "--strip-components=1", "-x", "-f", lambda: f"{STORAGE_DIR}/{self.target_uuid}.body", "*/layer.tar"] ["tar", "-C", f"{self.outdir}", "--strip-components=1", "-x", "-f", lambda: f"{STORAGE_DIR}/{self.target_uuid}.body", "*/layer.tar"]
] ]
if self.image_type in ["GenericCloud", "EC2"]: if self.image_type in ["GenericCloud"]:
self.stage_commands = [ self.stage_commands = [
["qemu-img", "convert", "-f", "raw", "-O", "qcow2", lambda: f"{STORAGE_DIR}/{self.target_uuid}.body", f"{self.outdir}/{self.outname}.qcow2"] ["qemu-img", "convert", "-f", "raw", "-O", "qcow2", lambda: f"{STORAGE_DIR}/{self.target_uuid}.body", f"{self.outdir}/{self.outname}.qcow2"]
] ]
if self.image_type in ["EC2"]:
self.stage_commands = [
["qemu-img", "convert", "-f", "raw", "-O", "qcow2", lambda: f"{STORAGE_DIR}/{self.target_uuid}.body", f"{self.outdir}/{self.outname}.qcow2"]
]
if self.image_type in ["Vagrant"]:
_map = {
"VBox": "vmdk",
"Libvirt": "qcow2"
}
output = f"{_map[self.variant]}" #type: ignore
self.stage_commands = [
["qemu-img", "convert", "-f", "raw", "-O", output, lambda: f"{STORAGE_DIR}/{self.target_uuid}.body", f"{self.outdir}/{self.outname}.{output}"]
]
try: try:
os.mkdir(self.outdir) os.mkdir(self.outdir)
@ -122,11 +136,14 @@ class ImageBuild:
finally: finally:
f.flush() f.flush()
def output_name(self): def output_name(self) -> Tuple[pathlib.Path, str]:
return f"Rocky-{self.architecture.major}-{self.type_variant}-{self.architecture.version}-{BUILDTIME.strftime('%Y%m%d')}.{self.release}.{self.architecture.name}" directory = f"Rocky-{self.architecture.major}-{self.type_variant}-{self.architecture.version}-{BUILDTIME.strftime('%Y%m%d')}.{self.release}"
name = f"{directory}.{self.architecture.name}"
outdir = pathlib.Path(f"/tmp/", directory)
return outdir, name
def type_variant_name(self): def type_variant_name(self):
return self.image_type if not self.variant else f"{self.image_type}-{self.variant.capitalize()}" return self.image_type if not self.variant else f"{self.image_type}-{self.variant}"
def _command_args(self): def _command_args(self):
args_mapping = { args_mapping = {
@ -207,7 +224,9 @@ class ImageBuild:
def copy_command(self) -> List[str]: def copy_command(self) -> List[str]:
copy_command = ["aws", "s3", "cp", "--recursive", f"{self.outdir}/", f"s3://resf-empanadas/buildimage-{ self.outname }/{ BUILDTIME.strftime('%s') }/"] copy_command = ["aws", "s3", "cp", "--recursive", f"{self.outdir}/",
f"s3://resf-empanadas/buildimage-{self.architecture.version}-{self.architecture.name}/{ self.outname }/{ BUILDTIME.strftime('%s') }/"
]
return copy_command return copy_command
@ -215,6 +234,8 @@ class ImageBuild:
if self.base_uuid: if self.base_uuid:
return 0 return 0
self.fix_ks()
ret, out, err, uuid = self.runCmd(self.build_command()) ret, out, err, uuid = self.runCmd(self.build_command())
if uuid: if uuid:
self.base_uuid = uuid.rstrip() self.base_uuid = uuid.rstrip()
@ -238,11 +259,11 @@ class ImageBuild:
def stage(self) -> int: def stage(self) -> int:
""" Stage the artifacst from wherever they are (unpacking and converting if needed)""" """ Stage the artifacst from wherever they are (unpacking and converting if needed)"""
if not self.stage_commands: if not hasattr(self,'stage_commands'):
return 0 return 0
returns = [] returns = []
for command in self.stage_commands: for command in self.stage_commands: #type: ignore
ret, out, err, _ = self.runCmd(command, search=False) ret, out, err, _ = self.runCmd(command, search=False)
returns.append(ret) returns.append(ret)
@ -318,6 +339,9 @@ class ImageBuild:
if stderr: if stderr:
log_lines("Command STDERR", stderr) log_lines("Command STDERR", stderr)
def fix_ks(self):
self.runCmd(["sed", "-i", f"s,$basearch,{self.architecture.name},", self.kickstart_arg[-1]])
def render_kubernetes_job(self): def render_kubernetes_job(self):
commands = [self.build_command(), self.package_command(), self.copy_command()] commands = [self.build_command(), self.package_command(), self.copy_command()]
if not self.job_template: if not self.job_template:

View File

@ -7,10 +7,11 @@
<install type='url'> <install type='url'>
<url>https://dl.rockylinux.org/stg/rocky/{{major}}/BaseOS/{{architecture}}/{{installdir}}</url> <url>https://dl.rockylinux.org/stg/rocky/{{major}}/BaseOS/{{architecture}}/{{installdir}}</url>
</install> </install>
<icicle> <icicle>
<extra_command>rpm -qa --qf '%{NAME},%{VERSION},%{RELEASE},%{ARCH},%{EPOCH},%{SIZE},%{SIGMD5},%{BUILDTIME} <extra_command>rpm -qa --qf '%{NAME},%{VERSION},%{RELEASE},%{ARCH},%{EPOCH},%{SIZE},%{SIGMD5},%{BUILDTIME}
'</extra_command> '</extra_command>
</icicle> </icicle>
<kernelparam>console=tty0 inst.usefbx</kernelparam>
</os> </os>
<description>Rocky-{{major}}-{{type}}-{{version_variant}}.{{iso8601date}}.{{release}}.{{architecture}} Generated on {{utcnow}}</description> <description>Rocky-{{major}}-{{type}}-{{version_variant}}.{{iso8601date}}.{{release}}.{{architecture}} Generated on {{utcnow}}</description>
<disk> <disk>

View File

@ -0,0 +1,16 @@
diff --git a/imagefactory_plugins/TinMan/TinMan.info b/imagefactory_plugins/TinMan/TinMan.info
index bd61a02..00a8112 100644
--- a/imagefactory_plugins/TinMan/TinMan.info
+++ b/imagefactory_plugins/TinMan/TinMan.info
@@ -3,7 +3,10 @@
"targets": [ ["Fedora", null, null], ["RHEL-6", null, null], ["RHEL-5", null, null],
["Ubuntu", null, null], ["CentOS-6", null, null], ["CentOS-5", null, null],
["ScientificLinux-6", null, null], ["ScientificLinux-5", null, null], ["OpenSUSE", null, null],
- [ "RHEL-7", null, null ], [ "CentOS-7", null, null ], [ "ScientificLinux-7", null, null ] ],
+ [ "RHEL-7", null, null ], [ "CentOS-7", null, null ], [ "ScientificLinux-7", null, null ],
+ [ "RHEL-8", null, null ], [ "CentOS-8", null, null ], [ "Rocky-8", null, null ],
+ [ "RHEL-9", null, null ], [ "CentOS-9", null, null ], [ "Rocky-9", null, null ]
+ ],
"description": "Plugin to support most Oz customize capable guest types",
"maintainer": {
"name": "Red Hat, Inc.",

BIN
iso/empanadas/oz.rpm Normal file

Binary file not shown.