[libvirt-ci PATCH 05/13] config: Introduce a new global config.toml configuration file

Erik Skultety posted 13 patches 5 years, 9 months ago
[libvirt-ci PATCH 05/13] config: Introduce a new global config.toml configuration file
Posted by Erik Skultety 5 years, 9 months ago
Rather than having the configuration options split across multiple files
(root-password, flavor, gitlab-url, gitlab-runner-token, ...), let's
consolidate these settings into a global config file.

The TOML format has been chosen simply because its syntax is very similar
to the conventional INI format (thus easily human readable),
but unlike INI it has a formal specification, it's typed and it also
has some nice features over the plain INI should we find ourselves in
need of any of such extended features in the future, e.g. table nesting.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
---
 config.toml | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
 create mode 100644 config.toml

diff --git a/config.toml b/config.toml
new file mode 100644
index 0000000..5bb3725
--- /dev/null
+++ b/config.toml
@@ -0,0 +1,26 @@
+# Configuration file for the lcitool -- https://gitlab.com/libvirt/libvirt-ci/
+# ============================================================================
+
+[install]
+# Installation flavor determining the target environment for the VM:
+#
+# test - VMs suitable for local testing, 'test' has passwordless sudo
+# jenkins - VMs pluggable to a jenkins environment
+# gitlab - VMs ready to be plugged to a GitLab environment
+#
+#flavor = "test"
+
+# Initial root password to be set by ansible on the appliance. This password
+# will only be necessary for serial console access in case something goes
+# horribly wrong, for all other use cases, SSH key authentication will be used
+# instead. (mandatory)
+#root_password = ""
+
+[gitlab]
+# GitLab runner agent registration options, applies only if flavor == 'gitlab'.
+
+# GitLab server URL to register the runner.
+#gitlab_url = "https://gitlab.com"
+
+# GitLab runner registration token. (mandatory)
+#gitlab_runner_secret = ""
-- 
2.25.3

Re: [libvirt-ci PATCH 05/13] config: Introduce a new global config.toml configuration file
Posted by Andrea Bolognani 5 years, 9 months ago
On Wed, 2020-04-22 at 15:28 +0200, Erik Skultety wrote:
> and it also
> has some nice features over the plain INI should we find ourselves in
> need of any of such extended features in the future, e.g. table nesting.

Let's hope we never will! :)

> diff --git a/config.toml b/config.toml

This is specific to lcitool, so it should go in guests/ rather than
in the top-level directory.

> +# Configuration file for the lcitool -- https://gitlab.com/libvirt/libvirt-ci/
> +# ============================================================================

s/the //, and I would leave out the URL as well.

> +# Initial root password to be set by ansible on the appliance. This password
> +# will only be necessary for serial console access in case something goes
> +# horribly wrong, for all other use cases, SSH key authentication will be used
> +# instead. (mandatory)
> +#root_password = ""

s/ansible/Ansible/


With these nits addressed,

  Reviewed-by: Andrea Bolognani <abologna@redhat.com>

-- 
Andrea Bolognani / Red Hat / Virtualization

Re: [libvirt-ci PATCH 05/13] config: Introduce a new global config.toml configuration file
Posted by Andrea Bolognani 5 years, 9 months ago
On Wed, 2020-04-22 at 15:28 +0200, Erik Skultety wrote:
> +[gitlab]
> +# GitLab runner agent registration options, applies only if flavor == 'gitlab'.
> +
> +# GitLab server URL to register the runner.
> +#gitlab_url = "https://gitlab.com"
> +
> +# GitLab runner registration token. (mandatory)
> +#gitlab_runner_secret = ""

Additional nit: since TOML is organized in sections, it doesn't make
sense to include the section name in the key name, so this should
look like

  [gitlab]
  url = "https://gitlab.com"
  runner_secret = "..."

-- 
Andrea Bolognani / Red Hat / Virtualization

Re: [libvirt-ci PATCH 05/13] config: Introduce a new global config.toml configuration file
Posted by Erik Skultety 5 years, 9 months ago
On Tue, Apr 28, 2020 at 09:39:31AM +0200, Andrea Bolognani wrote:
> On Wed, 2020-04-22 at 15:28 +0200, Erik Skultety wrote:
> > +[gitlab]
> > +# GitLab runner agent registration options, applies only if flavor == 'gitlab'.
> > +
> > +# GitLab server URL to register the runner.
> > +#gitlab_url = "https://gitlab.com"
> > +
> > +# GitLab runner registration token. (mandatory)
> > +#gitlab_runner_secret = ""
> 
> Additional nit: since TOML is organized in sections, it doesn't make
> sense to include the section name in the key name, so this should
> look like
> 
>   [gitlab]
>   url = "https://gitlab.com"
>   runner_secret = "..."

Absolutely agreed. That was the initial approach, however it didn't pair
with the naming used within the Ansible playbooks, so I changed it. If I'm not
mistaken "url" will cause a collision with another variable, that's why I was
explicit with naming in the config, although I agree that from the config POV
it doesn't make sense to include the section prefix.

-- 
Erik Skultety