From nobody Mon Apr 29 07:37:33 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1588766923; cv=none; d=zohomail.com; s=zohoarc; b=hVaYIQVHz/5PiY5lYlKOMgKx+CQlGAxOnXjS1Sd1GsqfeoSasAh6hZ5hwQTiJEJkPHdmvgPX1kCQebtwe+IPckir5sVJUajDBargSF6TyaG6t0Uy4pLRSPyTYuqvaYUsd1+HPkit5cT1XTsg19ZFhnPL4YtiZ2LFHdZJJb5cpbg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588766923; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=uLrSE7a6YDwzjxWo4IDDAHDORHOmn85KRZ+kka07ioo=; b=KWfJt0ELHSTZaY2mjHCZlpqxGS8oJw5XKTaqGVT863ODe2Ij9wcy9By4ZdZ4hVT+ZZy3HrbMeM0Jh0nFiWoQ1ZkpkfNPqez0rMog0r1KxpCcWBkvfcAvgYdoM9EB9KkLZSsg+/fdYWwVpsYwkUGAW/TSkMywll89WtnbmKnmjKU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1588766923872930.384670113047; Wed, 6 May 2020 05:08:43 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-469-IHtdczt_OyiR-KVSFDIXDw-1; Wed, 06 May 2020 08:06:31 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 33CDB872FE1; Wed, 6 May 2020 12:06:26 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0B1315D9C5; Wed, 6 May 2020 12:06:26 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id B296C1809554; Wed, 6 May 2020 12:06:25 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 046C68GJ029200 for ; Wed, 6 May 2020 08:06:08 -0400 Received: by smtp.corp.redhat.com (Postfix) id 69C465D9DC; Wed, 6 May 2020 12:06:08 +0000 (UTC) Received: from sturgeon.redhat.com (unknown [10.40.193.49]) by smtp.corp.redhat.com (Postfix) with ESMTP id 840905D9C5; Wed, 6 May 2020 12:06:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588766922; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=uLrSE7a6YDwzjxWo4IDDAHDORHOmn85KRZ+kka07ioo=; b=eiY0RUC2C3ezsnRs0LNgLQz0Jsx2pB5RDI09eCMqA5Udzgi7Rk1D8PsfMFWYIxVtApeZqk wFZR40WgsgTAyiN6qPp2OsKFQewHd8QJQv0vftmTjG828/z9q+68ui3pvJsxtYm94l+99p HCLaZVY7teLG57MBJA8pPtuqMn4ebKQ= X-MC-Unique: IHtdczt_OyiR-KVSFDIXDw-1 From: Erik Skultety To: libvir-list@redhat.com Subject: [libvirt-ci PATCH 01/12] requirements: Introduce a requirements.txt file Date: Wed, 6 May 2020 14:05:51 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Cc: Andrea Bolognani , Erik Skultety X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Right now, lcitool's users have 2 options to satisfy the tool's dependencies: install them through the system package manager system-wide or install through pip manually. Since pip gives us the option to automate this process a tiny bit, let's ship a requirements file. This targets users who are used to work with Python virtual environments and install whatever it is necessary inside. Signed-off-by: Erik Skultety Reviewed-by: Andrea Bolognani --- guests/requirements.txt | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 guests/requirements.txt diff --git a/guests/requirements.txt b/guests/requirements.txt new file mode 100644 index 0000000..900cfd6 --- /dev/null +++ b/guests/requirements.txt @@ -0,0 +1,2 @@ +ansible +jenkins-job-builder --=20 2.25.3 From nobody Mon Apr 29 07:37:33 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1588766786; cv=none; d=zohomail.com; s=zohoarc; b=nwlpfXRgNHv4/WyJY1IzMbNlolfLJepesSQm1x4HjNUOmzGtEeD/wbqVJ4xoDLFE4cvFxw6TLB4ZcBRE6VOePnjvtHzETwLl/bs4uV2gN+VpMQfHnMnFSRpbslPsHIMGD/NzrgXIWRGU6ewDIulIBdJ/oTS+UvPobXT6szfeOzM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588766786; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Jq5yzHRru/KvFBgPL0vqysCc1pb4NYvlOsRSi43PLb0=; b=IeRwZnWToiGRvTN1vdZ3DjQO2ZrW4l0Dt85SzHAjKOhJmsKCmzMWTSPAji2dMj3GBw/fWFpP91g4GbbqowaSThUlLOUOU/YxZHABLBFGzSzYtMxiwNsehIfHZZHeQLYpK+2lesAr/o6g2O0AUcQeqjjWjEg3N7QDZ/j7tZMOJpU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1588766786124160.65298911376283; Wed, 6 May 2020 05:06:26 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-211-7OPmwiRyNjK7B7tJjQJOZg-1; Wed, 06 May 2020 08:06:19 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B7FB5460; Wed, 6 May 2020 12:06:13 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1DB7C6443D; Wed, 6 May 2020 12:06:13 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 45CE954D01; Wed, 6 May 2020 12:06:11 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 046C69Ww029212 for ; Wed, 6 May 2020 08:06:09 -0400 Received: by smtp.corp.redhat.com (Postfix) id A67795D9DC; Wed, 6 May 2020 12:06:09 +0000 (UTC) Received: from sturgeon.redhat.com (unknown [10.40.193.49]) by smtp.corp.redhat.com (Postfix) with ESMTP id BEE7E5D9C5; Wed, 6 May 2020 12:06:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588766784; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=Jq5yzHRru/KvFBgPL0vqysCc1pb4NYvlOsRSi43PLb0=; b=IAef25wiHRAUtE7/+BgfaMByg5dV8bRsCu2T8wQGnPG2vGv0gJINlbKBpxaCzArIisFAXW 5e2D9xBDz6uompV/8veswQC/FchFn5vG8QG+BJ3QEPLjeL6h5O5GkwB+jmzlMBNpX2p6p+ izMvowJ9gzmQSDcG6RXh5eKd3Lp4tNo= X-MC-Unique: 7OPmwiRyNjK7B7tJjQJOZg-1 From: Erik Skultety To: libvir-list@redhat.com Subject: [libvirt-ci PATCH 02/12] lcitool: Decrease the indent when creating a tempdir for initrd injection Date: Wed, 6 May 2020 14:05:52 +0200 Message-Id: <3333c6accdf7b9b8a97e9c5bad0b8c2cea16a976.1588766736.git.eskultet@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Cc: Andrea Bolognani , Erik Skultety X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The 'with' statement doesn't define a new code block [1], thus no local namespace is created. Therefore, we can still access the @content variable outside of the 'with' block. So, there's really no need to hold the @initrd_template file open longer than necessary (not that it would be a big deal anyway). [1] https://docs.python.org/3.7/reference/executionmodel.html Signed-off-by: Erik Skultety Reviewed-by: Andrea Bolognani --- guests/lcitool | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/guests/lcitool b/guests/lcitool index ab3b95f..c8d0d9a 100755 --- a/guests/lcitool +++ b/guests/lcitool @@ -608,11 +608,11 @@ class Application: facts[option] ) =20 - tempdir =3D tempfile.mkdtemp() - initrd_inject =3D os.path.join(tempdir, install_config) + tempdir =3D tempfile.mkdtemp() + initrd_inject =3D os.path.join(tempdir, install_config) =20 - with open(initrd_inject, "w") as inject: - inject.write(content) + with open(initrd_inject, "w") as inject: + inject.write(content) =20 # preseed files must use a well-known name to be picked up by # d-i; for kickstart files, we can use whatever name we please --=20 2.25.3 From nobody Mon Apr 29 07:37:33 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1588766795; cv=none; d=zohomail.com; s=zohoarc; b=dDflqWMk7okzWI7P0NYJD6AYjXgXxw6L5QoaPoHhGnC4u1i8GIJ7+eaGxPf9jBctww67+Wzo6axf3OOUYisao4GCchOTfKp/hBnyW5+hWOLLfnsbf7meHbDZleoHtWV4abMVElhUipOeFV+gqnbR0F0NknZy7C/+UHMsXwpDwps= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588766795; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=xTsib2OIRqtAXEmmrLyGM7QCljyYZtnF4iG7WSF8rb4=; b=H7QAjT2UrPMiySfhg/opeZOWWl0ZkJn1eLDPgkwD9wRGE/X7cKCfpHzFGSQZLqxWCooHKfehXxoF60mDG8LfkeN3PScJVIN0W/Pz+a1RCMWlhbS/cU9gCs2H9JHlTMwyMx7GovctyqlGY1xnB/Hwl3DYikgefvgzZMoZbf6CoWY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1588766795162381.6975602074232; Wed, 6 May 2020 05:06:35 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-115-grRyj33YMT6t08Bezkedtw-1; Wed, 06 May 2020 08:06:31 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 07ECA460; Wed, 6 May 2020 12:06:26 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D3D895D9DA; Wed, 6 May 2020 12:06:25 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 8F61A1809542; Wed, 6 May 2020 12:06:25 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 046C6AFL029219 for ; Wed, 6 May 2020 08:06:10 -0400 Received: by smtp.corp.redhat.com (Postfix) id DEDF35D9DC; Wed, 6 May 2020 12:06:10 +0000 (UTC) Received: from sturgeon.redhat.com (unknown [10.40.193.49]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0581C5D9C5; Wed, 6 May 2020 12:06:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588766793; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=xTsib2OIRqtAXEmmrLyGM7QCljyYZtnF4iG7WSF8rb4=; b=KEY1yGVS6WOFdDuRsiPJs/S8vGbZ9mqYS8b6Swd4phnMTkYYTMQpNNc0p1FjdC1FLkoSca Z3EUjqdqzZH6nChXsSpvTXOcxmit2oOC+jl+W/h5HPrk59wXkNdG5/9m25trF4ADmcR4Rz Mi3sZqq19Y64YRv2aX65HelFC8jYVV4= X-MC-Unique: grRyj33YMT6t08Bezkedtw-1 From: Erik Skultety To: libvir-list@redhat.com Subject: [libvirt-ci PATCH 03/12] lcitool: Prefer tempfile's native wrappers over low level primitives Date: Wed, 6 May 2020 14:05:53 +0200 Message-Id: <2575a09c362fbc75f78b02696035603eaf7f6a8b.1588766736.git.eskultet@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Cc: Andrea Bolognani , Erik Skultety X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Rather than requiring shutil module to get rid of the temporary directory we're creating for virt-install, let's use the TemporaryDirectory method instead which returns a file-like object which can be used to clean up the standard Python way. Although the internal exit handlers will take care of closing the temporary directories (and thus removing their contents) automatically, let's be explicit anyway and use the 'finally' clause to clean these up on both success and failure. Signed-off-by: Erik Skultety Reviewed-by: Andrea Bolognani --- guests/lcitool | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/guests/lcitool b/guests/lcitool index c8d0d9a..759e604 100755 --- a/guests/lcitool +++ b/guests/lcitool @@ -23,7 +23,6 @@ import json import os import platform import random -import shutil import string import subprocess import sys @@ -608,8 +607,8 @@ class Application: facts[option] ) =20 - tempdir =3D tempfile.mkdtemp() - initrd_inject =3D os.path.join(tempdir, install_config) + tempdir =3D tempfile.TemporaryDirectory(prefix=3D"lcitool") + initrd_inject =3D os.path.join(tempdir.name, install_config) =20 with open(initrd_inject, "w") as inject: inject.write(content) @@ -663,8 +662,8 @@ class Application: subprocess.check_call(cmd) except Exception as ex: raise Exception("Failed to install '{}': {}".format(host, = ex)) - - shutil.rmtree(tempdir, ignore_errors=3DTrue) + finally: + tempdir.cleanup() =20 def _action_update(self, args): self._execute_playbook("update", args.hosts, args.projects, --=20 2.25.3 From nobody Mon Apr 29 07:37:33 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1588766800; cv=none; d=zohomail.com; s=zohoarc; b=Q3vZfN06G1eIYQ+V3SpTHpw6bL+u84IbsnltcsqirdRgjeaLkAYinQWx3B7ebbwOtW67fcTDCAcXTuLlV/kC9dMDMnJntj70wbE9CTBzdRDK/IG/sKf4ICdWokAn50ZPX4Y6UQmiXxDNRcEyRmR8ipCLp/8ELNUxVarQa+TtPSU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588766800; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=46cW6OXwR65T3EBGijssQQZGd6X0l1Jiq17kFk7uaYo=; b=UAGmrfqcoD8gSVmxZ9fBkbfrcvQrUFUjnddIomBjtuXl0SsshF+OJQSy7deDqbsuL2hGHR+2NLgKahDo6Iuw35QfGtc0lmHQ396dtkoH0TVj90i9hl9RNpFZspbV5UFasbmTl4nRiEybcKsqOhMi5gFBad18ywd47T0gM/qoDww= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1588766800114903.3621599610486; Wed, 6 May 2020 05:06:40 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-299-ENbyzYxfNXu9jzTDuXpfkw-1; Wed, 06 May 2020 08:06:36 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 174B3EC1A2; Wed, 6 May 2020 12:06:31 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D94C7398; Wed, 6 May 2020 12:06:30 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 9329554D07; Wed, 6 May 2020 12:06:30 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 046C6BSs029230 for ; Wed, 6 May 2020 08:06:11 -0400 Received: by smtp.corp.redhat.com (Postfix) id ECCF75D9DA; Wed, 6 May 2020 12:06:11 +0000 (UTC) Received: from sturgeon.redhat.com (unknown [10.40.193.49]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3F1D35D9C5; Wed, 6 May 2020 12:06:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588766798; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=46cW6OXwR65T3EBGijssQQZGd6X0l1Jiq17kFk7uaYo=; b=JxqSWj0/bWCLJywb6vKrzHDndYGjMX8r3f330YPHBE+t9CG/PGUdCUJP3V6lnxbw8/LNkw Xagm1TN2l8FZZDIIXAF+Kb9o8oLQs5gP9PUdW5C2qx9HcJ4kmksLD6ksjriROxsM9eF8Kj VlYoDTdUNVKOhXAKHzslziYZV333iM8= X-MC-Unique: ENbyzYxfNXu9jzTDuXpfkw-1 From: Erik Skultety To: libvir-list@redhat.com Subject: [libvirt-ci PATCH 04/12] lcitool: Use a temporary JSON file to pass extra variables Date: Wed, 6 May 2020 14:05:54 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Cc: Erik Skultety X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" This patch is a pre-requisite config file consolidation. Currently we've got a number of files which serve as a configuration either to the lcitool itself or to the ansible playbooks (majority). Once we replace these with a single global lcitool config, we'd end up passing tokens (potentially some passwords) as ansible extra variables bare naked on the cmdline. In order to prevent this security flaw use temporary JSON file holding all these extra variables and pass it as follows: $ ansible-playbook --extra-vars @extra_vars.json playbook.yml Signed-off-by: Erik Skultety --- guests/lcitool | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/guests/lcitool b/guests/lcitool index 759e604..2dca8b5 100755 --- a/guests/lcitool +++ b/guests/lcitool @@ -504,11 +504,13 @@ class Application: git_remote =3D "default" git_branch =3D "master" =20 + tempdir =3D tempfile.TemporaryDirectory(prefix=3D"lcitool") + ansible_cfg_path =3D os.path.join(base, "ansible.cfg") playbook_base =3D os.path.join(base, "playbooks", playbook) playbook_path =3D os.path.join(playbook_base, "main.yml") - - extra_vars =3D json.dumps({ + extra_vars_path =3D os.path.join(tempdir.name, "extra_vars.json") + extra_vars =3D { "base": base, "playbook_base": playbook_base, "root_password_file": root_pass_file, @@ -518,7 +520,10 @@ class Application: "git_branch": git_branch, "gitlab_url_file": gitlab_url_file, "gitlab_runner_token_file": gitlab_runner_token_file, - }) + } + + with open(extra_vars_path, "w") as fp: + json.dump(extra_vars, fp) =20 ansible_playbook =3D distutils.spawn.find_executable("ansible-play= book") if ansible_playbook is None: @@ -527,7 +532,7 @@ class Application: cmd =3D [ ansible_playbook, "--limit", ansible_hosts, - "--extra-vars", extra_vars, + "--extra-vars", "@" + extra_vars_path, ] =20 # Provide the vault password if available @@ -546,6 +551,8 @@ class Application: except Exception as ex: raise Exception( "Failed to run {} on '{}': {}".format(playbook, hosts, ex)) + finally: + tempdir.cleanup() =20 def _action_hosts(self, args): for host in self._inventory.expand_pattern("all"): --=20 2.25.3 From nobody Mon Apr 29 07:37:33 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1588766788; cv=none; d=zohomail.com; s=zohoarc; b=Mot/wRc8rsRWTWS/He8SjnXY9eF8ldhgZrjrkYGfv5XEMHyxcmkHm3bRVmkhftN/F07RYZfHG0pMU91XtmBlncrPztAgOjq4CkJgIn9QQE4wORe+5PmdUsJtkBhDHbFoHetx+WKBlPopqisjFVSdBJk43uv8VoNfEZow4QgoTwM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588766788; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=CTNljyvAflfcibRhyf03+jktwaOSBQi+V/x3qTZY3EQ=; b=Lmrti7Mq3aXTegS+hNl2TobyzIj5GeVB3etYk5hyRAZpBlY0/y28BvyE6cNB3esCv1VTjkd9c4Xm44BDxyQScnFpJoVt1Y/kE7Ctdn/9HB8BNlFgbPCs2s8V9i9DTattZ4eyJ11azGNzAY9GRkP54Ay6EH6F/64Q/4upGxFHkeg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1588766788411880.5022310750838; Wed, 6 May 2020 05:06:28 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-49--us7Ph7xNZ6zBuRC81XPAg-1; Wed, 06 May 2020 08:06:22 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id AFF75108BD16; Wed, 6 May 2020 12:06:16 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 897C95C1D4; Wed, 6 May 2020 12:06:16 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 49ED154D05; Wed, 6 May 2020 12:06:16 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 046C6DTq029242 for ; Wed, 6 May 2020 08:06:13 -0400 Received: by smtp.corp.redhat.com (Postfix) id 06AEA5D9DC; Wed, 6 May 2020 12:06:13 +0000 (UTC) Received: from sturgeon.redhat.com (unknown [10.40.193.49]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4CB565D9C5; Wed, 6 May 2020 12:06:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588766784; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=CTNljyvAflfcibRhyf03+jktwaOSBQi+V/x3qTZY3EQ=; b=brfcco79NeeZYdbspqcLaH1ovvIM5JOVoX9uV8aNV5vM08FTGuZAV4Nh9TGhjWhPoAB8Be mDVlqSrF42iRiwvz4/Ym42FQPECl+GxTR0nV+GtOI3pKBDeMVdqMZ8G7lmNSjI5w09Nn8V kWUzQfQCbxEUBju8l5QaaB1Vj3J2KjQ= X-MC-Unique: -us7Ph7xNZ6zBuRC81XPAg-1 From: Erik Skultety To: libvir-list@redhat.com Subject: [libvirt-ci PATCH 05/12] config: Introduce a new global config.yaml configuration file Date: Wed, 6 May 2020 14:05:55 +0200 Message-Id: <211b5cea5ae13e0a9b2b10deb76fb6d244ac11ac.1588766736.git.eskultet@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Cc: Erik Skultety X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" 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 YAML format has been chosen simply because it's the native data format in Ansible and thus plays very nicely when accessing variables within Ansible playbooks. Signed-off-by: Erik Skultety --- guests/config.yaml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 guests/config.yaml diff --git a/guests/config.yaml b/guests/config.yaml new file mode 100644 index 0000000..291fd57 --- /dev/null +++ b/guests/config.yaml @@ -0,0 +1,23 @@ +--- +# Configuration file for lcitool + +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 pass= word + # will only be necessary for serial console access in case something goes + # horribly wrong, for all other use cases, SSH key authentication will b= e used + # instead. (Mandatory) + #root_password: + +gitlab: + # GitLab runner agent registration options, applies only if flavor =3D= =3D 'gitlab'. + url: https://gitlab.com + + # GitLab runner registration token. (Mandatory) + #runner_secret: --=20 2.25.3 From nobody Mon Apr 29 07:37:33 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1588766804; cv=none; d=zohomail.com; s=zohoarc; b=AIR7owIbfEI6adn0JtGuH2pBdlXdfOwPQX2F/QmxV1jefQUXmgmiDLgCZOZfp1LOyfT8Z/O1HvHOtUnO7TRvbR8NpynJKP6czd2uA5oIpDLrhvLv8pR5oUk0Rsu80VRR9ODJSQR/Pj5YHG2vEuLla23qIgtg9ySlq4r8ssnxw9I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588766804; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=kxTLc6RbBO1kXbelRYuHqGYrvPmz6TVVlU1r8CWYbLY=; b=FeFbRuFvWP0yQqN4mBjoW+wy21DeZgD2UxeAGP+zKQG8UD51quwT5ODY+uf7ExGhgvyiFaLhrUkrPPHz8FGai87WmhrrIsaxxNIHmASdVtjBTzwdiIAQi5hueIjMcFAkVEe0qx89YrTtEKp126eVjmVEIqOOAJPReg7SjlwobUY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1588766804690672.221925282224; Wed, 6 May 2020 05:06:44 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-474-z6S1cURnMv-zLeHc4pzfcw-1; Wed, 06 May 2020 08:06:41 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 77B44108BD0E; Wed, 6 May 2020 12:06:35 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4C82A398; Wed, 6 May 2020 12:06:35 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 00487180042C; Wed, 6 May 2020 12:06:34 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 046C6EKb029250 for ; Wed, 6 May 2020 08:06:14 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1641F5D9DC; Wed, 6 May 2020 12:06:14 +0000 (UTC) Received: from sturgeon.redhat.com (unknown [10.40.193.49]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5B8E35D9C5; Wed, 6 May 2020 12:06:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588766803; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=kxTLc6RbBO1kXbelRYuHqGYrvPmz6TVVlU1r8CWYbLY=; b=Sgo3uEYHZDkBVKtcgl8HzuQYSQWK6f8ADDwVNHYbPI+xVn8MCqMgnPRcdTJePjVCU5zvf2 gRtbE7R9TkjUsueSfmGf5T0VGeRh54/7IPOv4FAvKQXOG2cCp/8GWVK/aan6qR1oUXKV8j 82CUIVQnE3WqriA0TpEPJ/Ou63mdabY= X-MC-Unique: z6S1cURnMv-zLeHc4pzfcw-1 From: Erik Skultety To: libvir-list@redhat.com Subject: [libvirt-ci PATCH 06/12] lcitool: Introduce methods to load and validate the YAML config Date: Wed, 6 May 2020 14:05:56 +0200 Message-Id: <2726822156fa117dbefb422a22ddd0d67b2b0d78.1588766736.git.eskultet@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Cc: Erik Skultety X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" This patch introduce a set of class Config helper methods in order to parse and validate the new global YAML config. Currently, only 'install' and 'gitlab' sections are recognized with the flavor setting defaulting to "test" (backwards compatibility) and gitlab runner registration url defaulting to "https://gitlab.com"; the rest of the options are currently mandatory. Signed-off-by: Erik Skultety --- guests/lcitool | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/guests/lcitool b/guests/lcitool index 2dca8b5..07d0b3c 100755 --- a/guests/lcitool +++ b/guests/lcitool @@ -133,6 +133,29 @@ class Util: =20 class Config: =20 + def __init__(self): + + # Load the template config containing the defaults first, this must + # always succeed. + # NOTE: we should load this from /usr/share once we start packaging + # lcitool + base =3D Util.get_base() + with open(os.path.join(base, "config.yaml"), "r") as fp: + self.values =3D yaml.load(fp, Loader=3Dyaml.Loader) + + try: + with open(self._get_config_file("config.yaml"), "r") as fp: + user_config =3D yaml.load(fp, Loader=3Dyaml.Loader) + except Exception as e: + print("Missing or invalid config.yaml file: {}".format(e), + file=3Dsys.stderr) + sys.exit(1) + + # Validate the user provided config and use it to override the def= ault + # settings + self._validate(user_config) + self._update(user_config) + @staticmethod def _get_config_file(name): try: @@ -154,6 +177,40 @@ class Config: =20 return os.path.join(config_dir, name) =20 + @staticmethod + def _validate_section(config, section, keys): + + if config.get(section, None) is None: + raise KeyError("Section '{}' not found".format(section)) + + for key in keys: + if config.get(section).get(key, None) is None: + raise KeyError("Missing mandatory key '{}.{}'".format(sect= ion, + key)) + + @staticmethod + def _validate(config): + + # verify the [install] section and its mandatory options + Config._validate_section(config, "install", ["root_password"]) + + # we need to check flavor here, because later validations depend o= n it + flavor =3D config.get("install").get("flavor", "test") + if flavor not in ["test", "jenkins", "gitlab"]: + raise ValueError( + "Invalid value '{}' for 'install.flavor'".format(flavor) + ) + + # verify the optional [gitlab] section and its mandatory options + if flavor =3D=3D "gitlab": + Config._validate_section(config, "gitlab", ["runner_secret"]) + + def _update(self, values): + self.values["install"].update(values["install"]) + + if values.get("gitlab", None): + self.values["gitlab"].update(values["gitlab"]) + def get_flavor(self): flavor_file =3D self._get_config_file("flavor") =20 --=20 2.25.3 From nobody Mon Apr 29 07:37:33 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1588766797; cv=none; d=zohomail.com; s=zohoarc; b=Z1rHnTZBwKwP+kS8DDBPHohZREDz7Eidogm3u5hLZnPjPYKXdR3udrWE4CdCqF9EOyA7rzWKFmgKBeqEbgeEXqvbffHjmRCZCoCUPabWL1cZAyiUUUoBGt8Y+romXkJkAJsu3yCtU6iqg6WsflNTnNpBEfB4fmqasQ+E10/1OvY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588766797; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=+Q+3hYYFy6ExUuyMYkg7OYJQWpJEmhgJtzg1+WRc7pQ=; b=iBWaK929FM4yaTmoqjAWmNRhK9ciwGeSg+46dQFdb3zwYPVmodWkQGU5HlYf4Jxpn9R4treuRajnNVMjReAn8Q4BsQInBRehyahCYA3cSa2Xv9MDPit5VMAA1B/Gm16BLeDntfTH1odAT4PQBfnbeKsRlQq2uvDqUqDefmA8CEo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1588766797393315.66137396747195; Wed, 6 May 2020 05:06:37 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-455-SBIf0JExOoSDttnYbKscCQ-1; Wed, 06 May 2020 08:06:33 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0033F8015CF; Wed, 6 May 2020 12:06:26 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C5F2A60E3E; Wed, 6 May 2020 12:06:25 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 7E4D71809543; Wed, 6 May 2020 12:06:25 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 046C6FpH029262 for ; Wed, 6 May 2020 08:06:15 -0400 Received: by smtp.corp.redhat.com (Postfix) id 256425D9DC; Wed, 6 May 2020 12:06:15 +0000 (UTC) Received: from sturgeon.redhat.com (unknown [10.40.193.49]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6AB605D9C5; Wed, 6 May 2020 12:06:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588766796; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=+Q+3hYYFy6ExUuyMYkg7OYJQWpJEmhgJtzg1+WRc7pQ=; b=LkvbeQAdkXNafMGkZTwAuHBA4m050VdlOF5g0jNhub1eWFS0YrmB5zrdTMb+c11/3zAB/D eiDrd5/LU29e3lq+fddF4qQHauO0+qnn/6BgVjenONOxqAQTyRMFKfnT4VH/5HR26mMCd9 ozuP+n8Mf0bAAjkgzeNCtw0UPerr8Sc= X-MC-Unique: SBIf0JExOoSDttnYbKscCQ-1 From: Erik Skultety To: libvir-list@redhat.com Subject: [libvirt-ci PATCH 07/12] lcitool: Update the config values with internal playbook settings Date: Wed, 6 May 2020 14:05:57 +0200 Message-Id: <588f70e7c891b681575a177cd9cc68364df6e30f.1588766736.git.eskultet@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Cc: Erik Skultety X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" So, the idea is to pass our YAML config to the Ansible playbooks as extra vars. However, not all variables we need to pass on to Ansible are exposed in the config (and they shouldn't be). Update the config values dictionary with these variables before passing on to Ansible. Signed-off-by: Erik Skultety --- guests/lcitool | 10 ++---- guests/playbooks/build/main.yml | 2 +- guests/playbooks/update/main.yml | 6 ++-- guests/playbooks/update/tasks/gitlab.yml | 4 +-- guests/playbooks/update/tasks/kludges.yml | 2 +- guests/playbooks/update/tasks/users.yml | 42 +++++++++++------------ 6 files changed, 30 insertions(+), 36 deletions(-) diff --git a/guests/lcitool b/guests/lcitool index 07d0b3c..818ae82 100755 --- a/guests/lcitool +++ b/guests/lcitool @@ -567,20 +567,16 @@ class Application: playbook_base =3D os.path.join(base, "playbooks", playbook) playbook_path =3D os.path.join(playbook_base, "main.yml") extra_vars_path =3D os.path.join(tempdir.name, "extra_vars.json") - extra_vars =3D { + self._config.values.update({ "base": base, "playbook_base": playbook_base, - "root_password_file": root_pass_file, - "flavor": flavor, "selected_projects": selected_projects, "git_remote": git_remote, "git_branch": git_branch, - "gitlab_url_file": gitlab_url_file, - "gitlab_runner_token_file": gitlab_runner_token_file, - } + }) =20 with open(extra_vars_path, "w") as fp: - json.dump(extra_vars, fp) + json.dump(self._config.values, fp) =20 ansible_playbook =3D distutils.spawn.find_executable("ansible-play= book") if ansible_playbook is None: diff --git a/guests/playbooks/build/main.yml b/guests/playbooks/build/main.= yml index 8abda67..462764b 100644 --- a/guests/playbooks/build/main.yml +++ b/guests/playbooks/build/main.yml @@ -1,6 +1,6 @@ --- - hosts: all - remote_user: '{{ flavor }}' + remote_user: '{{ install.flavor }}' =20 vars_files: - '{{ playbook_base }}/jobs/defaults.yml' diff --git a/guests/playbooks/update/main.yml b/guests/playbooks/update/mai= n.yml index 371e53d..1b97027 100644 --- a/guests/playbooks/update/main.yml +++ b/guests/playbooks/update/main.yml @@ -45,7 +45,7 @@ vars: project: jenkins when: - - flavor =3D=3D "jenkins" + - install.flavor =3D=3D "jenkins" =20 # Configure environment. Needs to happen after installing packages - include: '{{ playbook_base }}/tasks/kludges.yml' @@ -57,9 +57,9 @@ # Configure the Jenkins agent - include: '{{ playbook_base }}/tasks/jenkins.yml' when: - - flavor =3D=3D 'jenkins' + - install.flavor =3D=3D 'jenkins' =20 # Install the Gitlab runner agent - include: '{{ playbook_base }}/tasks/gitlab.yml' when: - - flavor =3D=3D 'gitlab' + - install.flavor =3D=3D 'gitlab' diff --git a/guests/playbooks/update/tasks/gitlab.yml b/guests/playbooks/up= date/tasks/gitlab.yml index f07279c..07a376c 100644 --- a/guests/playbooks/update/tasks/gitlab.yml +++ b/guests/playbooks/update/tasks/gitlab.yml @@ -1,8 +1,6 @@ --- - name: Define gitlab-related facts set_fact: - gitlab_url: '{{ lookup("file", gitlab_url_file) }}' - gitlab_runner_secret: '{{ lookup("file", gitlab_runner_token_file) }}' gitlab_runner_download_url: https://gitlab-runner-downloads.s3.amazona= ws.com/latest/binaries/gitlab-runner-{{ ansible_system|lower }}-amd64 gitlab_runner_config_dir: '/etc/gitlab-runner' =20 @@ -14,7 +12,7 @@ force: yes =20 - name: Register the gitlab-runner agent - shell: 'gitlab-runner register --non-interactive --config "{{ gitlab_run= ner_config_dir }}/config.toml" --registration-token "{{ gitlab_runner_secre= t }}" --url "{{ gitlab_url }}" --executor shell --tag-list "{{ os.name|lowe= r }}-{{ os.version }}"' + shell: 'gitlab-runner register --non-interactive --config "{{ gitlab_run= ner_config_dir }}/config.toml" --registration-token "{{ gitlab.runner_secre= t }}" --url "{{ gitlab.url }}" --executor shell --tag-list "{{ os.name|lowe= r }}-{{ os.version }}"' args: creates: '{{ gitlab_runner_config_dir }}/config.toml' =20 diff --git a/guests/playbooks/update/tasks/kludges.yml b/guests/playbooks/u= pdate/tasks/kludges.yml index 96fe1a5..33c6532 100644 --- a/guests/playbooks/update/tasks/kludges.yml +++ b/guests/playbooks/update/tasks/kludges.yml @@ -12,7 +12,7 @@ group: wheel when: - os.name =3D=3D 'FreeBSD' - - flavor =3D=3D "jenkins" + - install.flavor =3D=3D "jenkins" =20 # FreeBSD compiles bash without defining SSH_SOURCE_BASHRC, which means # it won't try to detect when it's spawned by ssh and source ~/.bashrc diff --git a/guests/playbooks/update/tasks/users.yml b/guests/playbooks/upd= ate/tasks/users.yml index 5c6ce8f..bc3cc11 100644 --- a/guests/playbooks/update/tasks/users.yml +++ b/guests/playbooks/update/tasks/users.yml @@ -2,7 +2,7 @@ - name: 'root: Set password' user: name: root - password: '{{ lookup("file", root_password_file)|password_hash("sha512= ") }}' + password: '{{ install.root_password|password_hash("sha512") }}' =20 - name: 'root: Configure ssh access' authorized_key: @@ -17,54 +17,54 @@ line: 'PermitRootLogin without-password' state: present =20 -- name: '{{ flavor }}: Create group' +- name: '{{ install.flavor }}: Create group' group: - name: '{{ flavor }}' + name: '{{ install.flavor }}' state: present =20 -- name: '{{ flavor }}: Create user account' +- name: '{{ install.flavor }}: Create user account' user: - name: '{{ flavor }}' - group: '{{ flavor }}' - comment: '{{ flavor }}' + name: '{{ install.flavor }}' + group: '{{ install.flavor }}' + comment: '{{ install.flavor }}' password: '*' shell: '{{ paths.bash }}' =20 -- name: '{{ flavor }}: Set password' +- name: '{{ install.flavor }}: Set password' user: - name: '{{ flavor }}' + name: '{{ install.flavor }}' password: '{{ "test"|password_hash("sha512") }}' when: - - flavor =3D=3D 'test' + - install.flavor =3D=3D 'test' =20 -- name: '{{ flavor }}: Configure ssh access' +- name: '{{ install.flavor }}: Configure ssh access' authorized_key: - user: '{{ flavor }}' + user: '{{ install.flavor }}' key: '{{ lookup("file", lookup("env", "HOME") + "/.ssh/id_rsa.pub") }}' state: present =20 -- name: '{{ flavor }}: Grant passwordless sudo access' +- name: '{{ install.flavor }}: Grant passwordless sudo access' lineinfile: path: '{{ paths.sudoers }}' - line: '{{ flavor }} ALL=3D(ALL) NOPASSWD: ALL' + line: '{{ install.flavor }} ALL=3D(ALL) NOPASSWD: ALL' state: present validate: 'visudo -cf %s' when: - - flavor =3D=3D 'test' + - install.flavor =3D=3D 'test' =20 -- name: '{{ flavor }}: Create shell profile' +- name: '{{ install.flavor }}: Create shell profile' template: src: '{{ playbook_base }}/templates/{{ item }}.j2' - dest: /home/{{ flavor }}/.{{ item }} - owner: '{{ flavor }}' - group: '{{ flavor }}' + dest: /home/{{ install.flavor }}/.{{ item }} + owner: '{{ install.flavor }}' + group: '{{ install.flavor }}' with_items: - bash_profile - bashrc =20 -- name: '{{ flavor }}: Remove unnecessary home skeleton files' +- name: '{{ install.flavor }}: Remove unnecessary home skeleton files' file: - path: /home/{{ flavor }}/.{{ item }} + path: /home/{{ install.flavor }}/.{{ item }} state: absent with_items: - profile --=20 2.25.3 From nobody Mon Apr 29 07:37:33 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1588766883; cv=none; d=zohomail.com; s=zohoarc; b=ie0uzSJoBX66f4wTQwE63ZqrPnjlQ8Hs/iiwhxU2CNociclsRyQQ54D9AfRb8CrUC2zVUh1VA6yToQHJB/QrqNIHLJTvB7pwVnzpNG+/gHIJzp6WZfAybROnudsQwlzXrtfVICRZLbTuJVsMjFceLzK5cIw4NA1TuK5tEtZqOhY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588766883; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=lb6Onvi/VlVQ1I+iskay5uehceUExaT8zi7IiHvbzHg=; b=hahpWhSPrzOn1oPx65jP2KxbBjJwq8V54hs6XJemth47NkVLLzS/AvQ2Wty4N0LwqTYjt50PDEj82rV09cupTB3lDEyvCJiRE2BfdMaR3s/oFSJlAU7dKQbL4EounJsQrR62fPj4TiiyGs3yVkCCfeAW7yp6fP8pFaJoqbHxR9c= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1588766883547962.1308176554805; Wed, 6 May 2020 05:08:03 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-469-YIg8x_laPriTPQHa1rO08Q-1; Wed, 06 May 2020 08:06:45 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 44C831899527; Wed, 6 May 2020 12:06:39 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 16C8D5C241; Wed, 6 May 2020 12:06:39 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 9B1D554D0E; Wed, 6 May 2020 12:06:38 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 046C6ILS029280 for ; Wed, 6 May 2020 08:06:18 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1BD255D9DD; Wed, 6 May 2020 12:06:18 +0000 (UTC) Received: from sturgeon.redhat.com (unknown [10.40.193.49]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6232C5D9DA; Wed, 6 May 2020 12:06:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588766882; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=lb6Onvi/VlVQ1I+iskay5uehceUExaT8zi7IiHvbzHg=; b=CkaLUDqOmXyX+11kcxwb2Na/1DakT+qmqIyu219mf50miwIJP4Lw5Hr5gla1IgxPPdVMmR wwH3A8kQAc/1edzhBBPoeBtl34O4NAqc/rrED29VxFbycJBZyYbms8sLMZHK8qOcAVPVry aMISE+gda49vrdZHBqNz3WUooDBSojw= X-MC-Unique: YIg8x_laPriTPQHa1rO08Q-1 From: Erik Skultety To: libvir-list@redhat.com Subject: [libvirt-ci PATCH 08/12] lcitool: Drop the get_flavor() method Date: Wed, 6 May 2020 14:05:58 +0200 Message-Id: <03001c8b43df68fd11665ad88e76ca9b3041f5e1.1588766736.git.eskultet@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Cc: Erik Skultety X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" We can now access this value directly in the config dictionary. Signed-off-by: Erik Skultety Reviewed-by: Andrea Bolognani --- guests/lcitool | 36 ++++-------------------------------- 1 file changed, 4 insertions(+), 32 deletions(-) diff --git a/guests/lcitool b/guests/lcitool index 818ae82..9c1a722 100755 --- a/guests/lcitool +++ b/guests/lcitool @@ -211,37 +211,12 @@ class Config: if values.get("gitlab", None): self.values["gitlab"].update(values["gitlab"]) =20 - def get_flavor(self): - flavor_file =3D self._get_config_file("flavor") - - try: - with open(flavor_file, "r") as infile: - flavor =3D infile.readline().strip() - except Exception: - # If the flavor has not been configured, we choose the default - # and store it on disk to ensure consistent behavior from now = on - flavor =3D "test" - try: - with open(flavor_file, "w") as infile: - infile.write("{}\n".format(flavor)) - except Exception as ex: - raise Exception( - "Can't write flavor file ({}): {}".format( - flavor_file, ex - ) - ) - - if flavor not in ["test", "jenkins", "gitlab"]: - raise Exception("Invalid flavor '{}'".format(flavor)) - - return flavor - def get_vault_password_file(self): vault_pass_file =3D None =20 # The vault password is only needed for the jenkins flavor, but in # that case we want to make sure there's *something* in there - if self.get_flavor() =3D=3D "jenkins": + if self.values["install"]["flavor"] =3D=3D "jenkins": vault_pass_file =3D self._get_config_file("vault-password") =20 try: @@ -274,7 +249,7 @@ class Config: return root_pass_file =20 def get_gitlab_runner_token_file(self): - if self.get_flavor() !=3D "gitlab": + if self.values["install"]["flavor"] !=3D "gitlab": return None =20 gitlab_runner_token_file =3D self._get_config_file("gitlab-runner-= token") @@ -293,7 +268,7 @@ class Config: return gitlab_runner_token_file =20 def get_gitlab_url_file(self): - if self.get_flavor() !=3D "gitlab": + if self.values["install"]["flavor"] !=3D "gitlab": return None =20 gitlab_url_file =3D self._get_config_file("gitlab-url") @@ -540,7 +515,6 @@ class Application: def _execute_playbook(self, playbook, hosts, projects, git_revision): base =3D Util.get_base() =20 - flavor =3D self._config.get_flavor() vault_pass_file =3D self._config.get_vault_password_file() root_pass_file =3D self._config.get_root_password_file() gitlab_url_file =3D self._config.get_gitlab_url_file() @@ -618,8 +592,6 @@ class Application: def _action_install(self, args): base =3D Util.get_base() =20 - flavor =3D self._config.get_flavor() - for host in self._inventory.expand_pattern(args.hosts): facts =3D self._inventory.get_facts(host) =20 @@ -715,7 +687,7 @@ class Application: cmd.append("--noautoconsole") =20 # Only configure autostart for the guest for the jenkins flavor - if flavor =3D=3D "jenkins": + if self._config.values["install"]["flavor"] =3D=3D "jenkins": cmd +=3D ["--autostart"] =20 try: --=20 2.25.3 From nobody Mon Apr 29 07:37:33 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1588766812; cv=none; d=zohomail.com; s=zohoarc; b=OeMlzRHBipdsJ3y7VWAuqfWAGA7KtaSTZxaGqHbOyt9x2DgxQtJ8O02GiVoO312/zNYpgwVgdCvOeSqO0d5LDTujtRdN/PSqJ9PRJUCGWL1WVTflG9Hm/3aIyN+R/C9TpN4rW7v4ynDUatUMKjzIFfaHQF20skjZgxekoBcOVGw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588766812; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=OlMBX20DfnS+h8DgwTATLJgNEplzudnaVxNai/ArucE=; b=evdLVEtSgyEgqmwJKj1UtxErK0m0xi/irwIdrx1iqPU1prUPK1gjqnMa85dTbdwwUgLB5ggErSzVd5TpR4DRtdqygJGuB8rsXLv4fiLSJrmJ0IZ0Npa/Yq8zDadcI5V6OlmXokFIxZCmLbDc5tNhtplvazW0l3L1waWY7n9ZI9I= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1588766812401900.9723224494114; Wed, 6 May 2020 05:06:52 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-441-cTlRqsh5Nf2gQj0cA1GE2g-1; Wed, 06 May 2020 08:06:49 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9F5481899521; Wed, 6 May 2020 12:06:43 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 73D68398; Wed, 6 May 2020 12:06:43 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 30D2D54D12; Wed, 6 May 2020 12:06:43 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 046C6Jla029287 for ; Wed, 6 May 2020 08:06:19 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2B6B65D9DA; Wed, 6 May 2020 12:06:19 +0000 (UTC) Received: from sturgeon.redhat.com (unknown [10.40.193.49]) by smtp.corp.redhat.com (Postfix) with ESMTP id 71F275D9DC; Wed, 6 May 2020 12:06:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588766811; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=OlMBX20DfnS+h8DgwTATLJgNEplzudnaVxNai/ArucE=; b=NxkFBv3RWoHjM9r6UGM85BuYWZgFGRv9VDh6BYtfUwARBlD42uLJwWaVCo4EwUt2/15Cid quX6qkg2jx+1ywTuUHSCp1x6zZNvD+3G1qKIKLlKAlgaN2c773LTByeo3pX13fhV95iwA6 anXrEIV4x+JhQD2zFkJHW6GMYn36i4o= X-MC-Unique: cTlRqsh5Nf2gQj0cA1GE2g-1 From: Erik Skultety To: libvir-list@redhat.com Subject: [libvirt-ci PATCH 09/12] lcitool: Drop the get_root_password_file() method Date: Wed, 6 May 2020 14:05:59 +0200 Message-Id: <363e78165e66b8149356d16ffe20a8bfdd957df3.1588766736.git.eskultet@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Cc: Erik Skultety X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" We can now access this value directly in the config dictionary. Signed-off-by: Erik Skultety Reviewed-by: Andrea Bolognani --- guests/lcitool | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/guests/lcitool b/guests/lcitool index 9c1a722..0725be9 100755 --- a/guests/lcitool +++ b/guests/lcitool @@ -232,22 +232,6 @@ class Config: =20 return vault_pass_file =20 - def get_root_password_file(self): - root_pass_file =3D self._get_config_file("root-password") - - try: - with open(root_pass_file, "r") as infile: - if not infile.readline().strip(): - raise ValueError - except Exception as ex: - raise Exception( - "Missing or invalid root password file ({}): {}".format( - root_pass_file, ex - ) - ) - - return root_pass_file - def get_gitlab_runner_token_file(self): if self.values["install"]["flavor"] !=3D "gitlab": return None @@ -516,7 +500,6 @@ class Application: base =3D Util.get_base() =20 vault_pass_file =3D self._config.get_vault_password_file() - root_pass_file =3D self._config.get_root_password_file() gitlab_url_file =3D self._config.get_gitlab_url_file() gitlab_runner_token_file =3D self._config.get_gitlab_runner_token_= file() =20 --=20 2.25.3 From nobody Mon Apr 29 07:37:33 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1588766799; cv=none; d=zohomail.com; s=zohoarc; b=FgKAlVuPOt6Lo9UGZiwv5tJb8/lyHHBYMokb4Si+CpuZZO+CadrZIZQ6ZW+gtCCmzJopw+oS2ut94JHQqp1feMca5orX8UfT23edKcoByTgJ5ukWUODsTUMar7/XjMK+L5MfgX9VN3RAQ5nCvt427l97Vsd3n5wWNtmT3+D+YDE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588766799; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=nlRzwehJOv8akm/rehRtneJsmKpNrtFTrTU3iARZYjo=; b=KVuSY+jbbRLrD+nLCFyArCZmIpMJKT7kvLByjBDXB0yqc0nf67cBG+xmjM09FOhQvY1rTiM2VuvSx3OZeKGHNKGlLjk+xS0zm3iU3in8oF2vrcvi3esQGXw7ByFJEAWedOa5TgSUKSXsc19AbB1Hxh0r02YGqLlK3NK8wx3DC1M= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1588766799168455.09978932753484; Wed, 6 May 2020 05:06:39 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-402-vWFbPWyJNJ6fg6eBDhjN0A-1; Wed, 06 May 2020 08:06:35 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B97D6107ACF7; Wed, 6 May 2020 12:06:29 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8DF3699D2; Wed, 6 May 2020 12:06:29 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 4B70E54D02; Wed, 6 May 2020 12:06:29 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 046C6KPj029296 for ; Wed, 6 May 2020 08:06:20 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3B8565D9DC; Wed, 6 May 2020 12:06:20 +0000 (UTC) Received: from sturgeon.redhat.com (unknown [10.40.193.49]) by smtp.corp.redhat.com (Postfix) with ESMTP id 81AB95D9C5; Wed, 6 May 2020 12:06:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588766797; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=nlRzwehJOv8akm/rehRtneJsmKpNrtFTrTU3iARZYjo=; b=HUKliC5HCtAWgg15yINFjZCy7JoVjpUvCtCrybNSswWo1yvxCZfzve7g/ceIuj0hJRf0pH jovMFlSdYnN9a3nfyb8bZrebiY1chS/AcFv5GIHzJjAb/iQOwHpnaYPXAd+nrKfet3fa4u r4PnsFmu/AB/h6/RAWELQWxK/8dmOHI= X-MC-Unique: vWFbPWyJNJ6fg6eBDhjN0A-1 From: Erik Skultety To: libvir-list@redhat.com Subject: [libvirt-ci PATCH 10/12] lcitool: Drop the gitlab-related getter methods Date: Wed, 6 May 2020 14:06:00 +0200 Message-Id: <0e7ec0bb0559bbd757a5199554d0b7f61820a541.1588766736.git.eskultet@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Cc: Erik Skultety X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" We can now access the values directly in the config dictionary. Signed-off-by: Erik Skultety Reviewed-by: Andrea Bolognani --- guests/lcitool | 40 ---------------------------------------- 1 file changed, 40 deletions(-) diff --git a/guests/lcitool b/guests/lcitool index 0725be9..6bbe314 100755 --- a/guests/lcitool +++ b/guests/lcitool @@ -232,44 +232,6 @@ class Config: =20 return vault_pass_file =20 - def get_gitlab_runner_token_file(self): - if self.values["install"]["flavor"] !=3D "gitlab": - return None - - gitlab_runner_token_file =3D self._get_config_file("gitlab-runner-= token") - - try: - with open(gitlab_runner_token_file, "r") as infile: - if not infile.readline().strip(): - raise ValueError - except Exception as ex: - raise Exception( - "Missing or invalid GitLab runner token file ({}): {}".for= mat( - gitlab_runner_token_file, ex - ) - ) - - return gitlab_runner_token_file - - def get_gitlab_url_file(self): - if self.values["install"]["flavor"] !=3D "gitlab": - return None - - gitlab_url_file =3D self._get_config_file("gitlab-url") - - try: - with open(gitlab_url_file, "r") as infile: - if not infile.readline().strip(): - raise ValueError - except Exception as ex: - raise Exception( - "Missing or invalid GitLab url file ({}): {}".format( - gitlab_url_file, ex - ) - ) - - return gitlab_url_file - =20 class Inventory: =20 @@ -500,8 +462,6 @@ class Application: base =3D Util.get_base() =20 vault_pass_file =3D self._config.get_vault_password_file() - gitlab_url_file =3D self._config.get_gitlab_url_file() - gitlab_runner_token_file =3D self._config.get_gitlab_runner_token_= file() =20 ansible_hosts =3D ",".join(self._inventory.expand_pattern(hosts)) selected_projects =3D self._projects.expand_pattern(projects) --=20 2.25.3 From nobody Mon Apr 29 07:37:33 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1588766825; cv=none; d=zohomail.com; s=zohoarc; b=gM3F+jUGOZ/PAazRXax/IVL42SQGWMNFu2PnY0FcRlAuRm6x1DsOUcTPfmiBFUXMLQIKSmBtQpX9D5dWbj6V73kkrJ1TEdCM0Wr1M6Zazl4zPf7G2X3YO0vlDpD8yqRF1HVV+CejjvOKMs4Jbv4CE2FdQHUYLWZR9VgK1ZMxsSM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588766825; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=+u2gwa/tUcKWVjMIxPrNhCauhGcmLM98mfNEC/CPz7Y=; b=SHvJuhQChaQfU/ju0L12aDROjcvH7OXVM7W9L3+I+0ZcnzuKsvaT6YXa2094Qwz2vqPXvYp5VoqNrQ1Br/eY6QOEK2OqG5m3JQk/tG3ZbsfXyGQ2Hkrf/enilv7Mf8y1uCCYkxMQVfyklRBPXbjXOYOaRYIW+swKGPB/Qvf8LU4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1588766825090127.93175133049294; Wed, 6 May 2020 05:07:05 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-452-0Ghohy_ePzGobaZooIOB_Q-1; Wed, 06 May 2020 08:06:37 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6C024107ACF2; Wed, 6 May 2020 12:06:32 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 39EBB60BF4; Wed, 6 May 2020 12:06:32 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id DF1D91809543; Wed, 6 May 2020 12:06:31 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 046C6Lot029307 for ; Wed, 6 May 2020 08:06:21 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4D41F5D9DC; Wed, 6 May 2020 12:06:21 +0000 (UTC) Received: from sturgeon.redhat.com (unknown [10.40.193.49]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8F5855D9C5; Wed, 6 May 2020 12:06:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588766823; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=+u2gwa/tUcKWVjMIxPrNhCauhGcmLM98mfNEC/CPz7Y=; b=LeneFpAF8vM1pPClLBh6aN9ePi91V7/Z9IduQLsdiahGwwbTyxoQkYSb5lBM63MXtWozF9 +7nuTrOTOUCPCSRy2Hj4orapdDgHkL6OKsEDld0z0TJsWsCTxckC1QeEUzdYk1BqWbZN1s EM9XzeVATm1Uen1cnmupnEm6z0GFEaY= X-MC-Unique: 0Ghohy_ePzGobaZooIOB_Q-1 From: Erik Skultety To: libvir-list@redhat.com Subject: [libvirt-ci PATCH 11/12] config: Move the virt-install settings from install.yml to the config Date: Wed, 6 May 2020 14:06:01 +0200 Message-Id: <88dcd16c5b0b1a0f5d4eab1156868dadc52b42b2.1588766736.git.eskultet@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Cc: Erik Skultety X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" 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 --- 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: =20 + # 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 stand= ard, + # 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 =3D= =3D '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: =20 def _action_install(self, args): base =3D Util.get_base() + config =3D self._config =20 for host in self._inventory.expand_pattern(args.hosts): facts =3D self._inventory.get_facts(host) =20 - # 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 =3D str(int(facts["install_memory_size"]) * 1024) - - vcpus_arg =3D str(facts["install_vcpus"]) - disk_arg =3D "size=3D{},pool=3D{},bus=3Dvirtio".format( - facts["install_disk_size"], - facts["install_storage_pool"], + config.values["install"]["disk_size"], + config.values["install"]["storage_pool"], ) network_arg =3D "network=3D{},model=3Dvirtio".format( - facts["install_network"], + config.values["install"]["network"], ) =20 # 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") =20 # Only configure autostart for the guest for the jenkins flavor - if self._config.values["install"]["flavor"] =3D=3D "jenkins": + if config.values["install"]["flavor"] =3D=3D "jenkins": cmd +=3D ["--autostart"] =20 try: --=20 2.25.3 From nobody Mon Apr 29 07:37:33 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1588766805; cv=none; d=zohomail.com; s=zohoarc; b=XzjkpH/1ybes1/Je2zz6ZXAfUFo6ejFvxgyb1+T4sNpNIrgwKPUXY1rbLaANjavn6AJ88d0pgskmrslrI81dEV4mO/jBgjGl1vO0BvCfxSOsYDC94gozFI0VXjzrKgU7R44BQpbw5wTX+T1nWLUiIb8nqOPSeN2tAlQa9n+tzfw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588766805; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Qlf8GZKclpLYUni8jGKQU6lB4Ii2RDv6a1pKIXLkJ6o=; b=CObrb+EeDRa3nCTHvh65/u5ggjA1l3DFVP0cuTWh0IcnFsjXJx/cY70Jq85gfm2fjAGptd0sHT1KukjuhzobIHC+xYDa6l/kH0rePl2e5Ab38fOykCUClVujxziLib1Xf3r3AkUINjtfiAazOK+gYB2fBdVgkfxFUcRnr94ug8Q= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1588766805772733.381341097282; Wed, 6 May 2020 05:06:45 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-495-1ohoKkAwOkuiiXisH_2NvA-1; Wed, 06 May 2020 08:06:42 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DB4D8189952C; Wed, 6 May 2020 12:06:36 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A6E516248B; Wed, 6 May 2020 12:06:35 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 6A02B54D0A; Wed, 6 May 2020 12:06:35 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 046C6MjS029317 for ; Wed, 6 May 2020 08:06:22 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6013D5D9C5; Wed, 6 May 2020 12:06:22 +0000 (UTC) Received: from sturgeon.redhat.com (unknown [10.40.193.49]) by smtp.corp.redhat.com (Postfix) with ESMTP id A55265D9DA; Wed, 6 May 2020 12:06:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588766804; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=Qlf8GZKclpLYUni8jGKQU6lB4Ii2RDv6a1pKIXLkJ6o=; b=hH/Qdt3OLkR86fr5YOSJPvjzauOoVr6l6VJQ3RYEBWW7VUn4QGEIF2GjAgUFHW8GK+GBaz PcmYXNPVLP2Ud+TZq6at7MYd+dOBHN1Q+1PmHKdKN72+aDJmIyLknUQ7Vhe60gbjp8wgOk A1+KNg33TjlqaKN/0UFz99wqE4yWtsU= X-MC-Unique: 1ohoKkAwOkuiiXisH_2NvA-1 From: Erik Skultety To: libvir-list@redhat.com Subject: [libvirt-ci PATCH 12/12] guests: README: Document the existence and usage of config.toml Date: Wed, 6 May 2020 14:06:02 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Cc: Erik Skultety X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Erik Skultety --- guests/README.markdown | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/guests/README.markdown b/guests/README.markdown index 7dbefed..a58c5cb 100644 --- a/guests/README.markdown +++ b/guests/README.markdown @@ -64,13 +64,15 @@ branches out of those with Host setup ---------- =20 -Ansible and `virt-install` need to be available on the host. +`ansible` and `virt-install` need to be available on the host, the former = can +be either installed system-wide using your package manager or using by `pi= p` +(see the provided requirements.txt file). The latter can only be installed= with +your package manager as `virt-install` is not distributed via PyPI. =20 -Before you can start bringing up guests, you'll have to store your -site-specific root password in the `~/.config/lcitool/root-password` file. -This password will only be necessary for serial console access in case -something goes horribly wrong; for day to day operations, SSH key -authentication will be used instead. +Before you can start bringing up guests, you need to create (ideally by +copying the `config.yaml` template) ~/.config/lcitool/config.yaml and set = at +least the options marked as "(mandatory)" depending on the flavor (`test`, +`jenkins`, `gitlab`) you wish to use with your machines. =20 Ansible expects to be able to connect to the guests by name: installing and enabling the [libvirt NSS plugin](https://wiki.libvirt.org/page/NSS_module) @@ -123,8 +125,8 @@ Jenkins CI use -------------- =20 You'll need to configure `lcitool` to use the `jenkins` flavor for -guests: to do so, just write `jenkins` in the `~/.config/lcitool/flavor` -file. +guests. To do so, simply set the flavor to 'jenkins' in +`~/.config/lcitool/config.yaml`. =20 Once a guest has been prepared, you'll be able to log in as root either via SSH (your public key will have been authorized) or on the serial --=20 2.25.3