Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions kt/data/cloud_init.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,14 @@ ssh_pwauth: true
package_upgrade: False

mounts:
- ["mount_tag_mock_scratch", "SHARED_DIR_PLACEHOLDER", "virtiofs", "rw,relatime,context=unconfined_u:object_r:mock_var_lib_t:s0"]
- ["SHARED_DIR_PLACEHOLDER", "/var/lib/mock", "bind", "defaults,bind"]
- - mount_tag_mock_scratch
- SHARED_DIR_PLACEHOLDER
- virtiofs
- rw,relatime,context=unconfined_u:object_r:mock_var_lib_t:s0
- - SHARED_DIR_PLACEHOLDER
- /var/lib/mock
- bind
- defaults,bind

# Change working directory after boot
# Setting up homedir does not work without tricks, because
Expand All @@ -32,4 +38,10 @@ write_files:
# and then root is the owner
# workaround to change the owner to user
runcmd:
- [chown, USER_PLACEHOLDER:USER_PLACEHOLDER, HOMEDIR_PLACEHOLDER]
- - chown
- USER_PLACEHOLDER:USER_PLACEHOLDER
- HOMEDIR_PLACEHOLDER
- find /etc/yum.repos.d/ -iname "*.repo" -exec sed -i 's|^mirrorlist=|#mirrorlist=|g' {} \;
- find /etc/yum.repos.d/ -iname "*.repo" -exec sed -i 's|^#baseurl=http://dl.rockylinux.org/$contentdir|baseurl=https://dl.rockylinux.org/vault/rocky|g' {} \;
Comment thread
roxanan1996 marked this conversation as resolved.
- find /etc/yum.repos.d/ -iname "*.repo" -exec sed -i "s|\$releasever|$(. /etc/os-release && echo $VERSION_ID)|g" {} \;
Comment thread
roxanan1996 marked this conversation as resolved.
Comment on lines +44 to +46
- dnf clean all
11 changes: 8 additions & 3 deletions kt/ktlib/vm.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
import time
from dataclasses import dataclass

import oyaml as yaml
import wget
from git import Repo
from pathlib3x import Path
from ruamel.yaml import YAML

from kt.ktlib.config import Config
from kt.ktlib.kernel_workspace import KernelWorkspace
Expand Down Expand Up @@ -157,9 +157,15 @@ def _download_source_image(self, override_base: bool = False):
wget.download(self._get_vm_url(), out=str(self.qcow2_source_path))

def _setup_cloud_init(self, config: Config):
yaml = YAML()
yaml.preserve_quotes = True
yaml.width = 4096
yaml.default_flow_style = False
yaml.best_sequence_indent = 2

data = None
with open(CLOUD_INIT_BASE_PATH) as f:
data = yaml.safe_load(f)
data = yaml.load(f)

# replace placeholders with user data
data["users"][0]["name"] = config.user
Expand Down Expand Up @@ -189,7 +195,6 @@ def _setup_cloud_init(self, config: Config):
data["runcmd"].append([str(config.base_path / Path("kernel-src-tree-tools") / Path("kernel_install_dep.sh"))])
# Write this to image cloud_init
with open(self.cloud_init_path, "w") as f:
f.write("#cloud-config\n")
yaml.dump(data, f)

def _create_image(self, config: Config, vcpus: int = 12, memory: int = 32768):
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ dependencies = [
"click",
"pathlib3x",
"python3-wget",
"oyaml",
"ruamel.yaml",
Comment thread
roxanan1996 marked this conversation as resolved.
"pyyaml",
"pexpect",
"jira",
"requests",
Expand Down