[libvirt-ci PATCH 11/12] config: Move the virt-install settings from install.yml to the config

Erik Skultety eskultet at redhat.com
Wed May 6 12:06:01 UTC 2020


Looking into the future where we're able to generate cloudinit images,
we'll need to configure some of the install options which is currently
not possible without editing the install.yml group vars file within the
repository. That is suboptimal, so let's move the install options to
the global config under the 'install' section so that further tweaking
is possible (but explicitly discouraged at the same time).

Signed-off-by: Erik Skultety <eskultet at redhat.com>
---
 guests/config.yaml | 17 +++++++++++++++++
 guests/lcitool     | 28 +++++++++++-----------------
 2 files changed, 28 insertions(+), 17 deletions(-)

diff --git a/guests/config.yaml b/guests/config.yaml
index 291fd57..5f750e7 100644
--- a/guests/config.yaml
+++ b/guests/config.yaml
@@ -15,6 +15,23 @@ install:
   # instead. (Mandatory)
   #root_password:
 
+  # Settings mapping to the virt-install options - see virt-install(1).
+  # It is strongly recommended that you keep the following at their default
+  # values to produce machines which conform to the upstream libvirt standard,
+  # unless you have a reason to do otherwise.
+  #
+  # Sizes are expressed in GiB.
+  #
+  virt_type: kvm
+  arch: x86_64
+  machine: pc
+  cpu_model: host-passthrough
+  vcpus: 2
+  memory_size: 2
+  disk_size: 15
+  storage_pool: default
+  network: default
+
 gitlab:
   # GitLab runner agent registration options, applies only if flavor == 'gitlab'.
   url: https://gitlab.com
diff --git a/guests/lcitool b/guests/lcitool
index 6bbe314..91582cb 100755
--- a/guests/lcitool
+++ b/guests/lcitool
@@ -534,23 +534,17 @@ class Application:
 
     def _action_install(self, args):
         base = Util.get_base()
+        config = self._config
 
         for host in self._inventory.expand_pattern(args.hosts):
             facts = self._inventory.get_facts(host)
 
-            # Both memory size and disk size are stored as GiB in the
-            # inventory, but virt-install expects the disk size in GiB
-            # and the memory size in *MiB*, so perform conversion here
-            memory_arg = str(int(facts["install_memory_size"]) * 1024)
-
-            vcpus_arg = str(facts["install_vcpus"])
-
             disk_arg = "size={},pool={},bus=virtio".format(
-                facts["install_disk_size"],
-                facts["install_storage_pool"],
+                config.values["install"]["disk_size"],
+                config.values["install"]["storage_pool"],
             )
             network_arg = "network={},model=virtio".format(
-                facts["install_network"],
+                config.values["install"]["network"],
             )
 
             # Different operating systems require different configuration
@@ -610,12 +604,12 @@ class Application:
                 virt_install,
                 "--name", host,
                 "--location", facts["install_url"],
-                "--virt-type", facts["install_virt_type"],
-                "--arch", facts["install_arch"],
-                "--machine", facts["install_machine"],
-                "--cpu", facts["install_cpu_model"],
-                "--vcpus", vcpus_arg,
-                "--memory", memory_arg,
+                "--virt-type", config.values["install"]["virt_type"],
+                "--arch", config.values["install"]["arch"],
+                "--machine", config.values["install"]["machine"],
+                "--cpu", config.values["install"]["cpu_model"],
+                "--vcpus", str(config.values["install"]["vcpus"]),
+                "--memory", str(config.values["install"]["memory_size"] * 1024),
                 "--disk", disk_arg,
                 "--network", network_arg,
                 "--graphics", "none",
@@ -630,7 +624,7 @@ class Application:
                 cmd.append("--noautoconsole")
 
             # Only configure autostart for the guest for the jenkins flavor
-            if self._config.values["install"]["flavor"] == "jenkins":
+            if config.values["install"]["flavor"] == "jenkins":
                 cmd += ["--autostart"]
 
             try:
-- 
2.25.3




More information about the libvir-list mailing list