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 <eskul...@redhat.com> Reviewed-by: Andrea Bolognani <abolo...@redhat.com> --- guests/config.yaml | 17 +++++++++++++++++ guests/group_vars/all/install.yml | 11 ----------- guests/lcitool | 21 +++++++++++---------- 3 files changed, 28 insertions(+), 21 deletions(-) delete mode 100644 guests/group_vars/all/install.yml diff --git a/guests/config.yaml b/guests/config.yaml index 05f1e8a..0b0b79c 100644 --- a/guests/config.yaml +++ b/guests/config.yaml @@ -15,6 +15,23 @@ install: # cases, SSH key authentication will be used 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-related options (only apply to the 'gitlab' flavor) gitlab: diff --git a/guests/group_vars/all/install.yml b/guests/group_vars/all/install.yml deleted file mode 100644 index 94b752f..0000000 --- a/guests/group_vars/all/install.yml +++ /dev/null @@ -1,11 +0,0 @@ ---- -# Sizes are in GiB -install_virt_type: kvm -install_arch: x86_64 -install_machine: pc -install_cpu_model: host-passthrough -install_vcpus: 2 -install_memory_size: 2 -install_disk_size: 15 -install_storage_pool: default -install_network: default diff --git a/guests/lcitool b/guests/lcitool index a93b56e..378c937 100755 --- a/guests/lcitool +++ b/guests/lcitool @@ -562,6 +562,7 @@ 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) @@ -569,16 +570,16 @@ class Application: # 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) + memory_arg = str(config.values["install"]["memory_size"] * 1024) - vcpus_arg = str(facts["install_vcpus"]) + vcpus_arg = str(config.values["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 @@ -638,10 +639,10 @@ 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"], + "--virt-type", config.values["install"]["virt_type"], + "--arch", config.values["install"]["arch"], + "--machine", config.values["install"]["machine"], + "--cpu", config.values["install"]["cpu_model"], "--vcpus", vcpus_arg, "--memory", memory_arg, "--disk", disk_arg, @@ -658,7 +659,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