From nobody Thu May 15 12:19:59 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1508427413560970.3521815667763; Thu, 19 Oct 2017 08:36:53 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 79BC64DAFB; Thu, 19 Oct 2017 15:36:52 +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 5551FD63CA; Thu, 19 Oct 2017 15:36:52 +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 17A3B1800C9B; Thu, 19 Oct 2017 15:36:52 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v9JFakth013794 for ; Thu, 19 Oct 2017 11:36:46 -0400 Received: by smtp.corp.redhat.com (Postfix) id 772B9BA224; Thu, 19 Oct 2017 15:36:46 +0000 (UTC) Received: from inaba.usersys.redhat.com (ovpn-204-95.brq.redhat.com [10.40.204.95]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CD189BA21C for ; Thu, 19 Oct 2017 15:36:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 79BC64DAFB Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Andrea Bolognani To: libvir-list@redhat.com Date: Thu, 19 Oct 2017 17:36:29 +0200 Message-Id: <20171019153632.15016-4-abologna@redhat.com> In-Reply-To: <20171019153632.15016-1-abologna@redhat.com> References: <20171019153632.15016-1-abologna@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [libvirt-jenkins-ci PATCH 3/6] guests: Implement flavors 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 19 Oct 2017 15:36:53 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Our CI infrastructure and developers have different requirements, but really the overlap is almost complete and it's a shame that we require developers to perform manual steps before we can use our tools. Flavors are a very simple and effective way to deal with the issue: we'll be able to configure guests differently based on whether they will be used for CI or development. The default flavor is developer, which doesn't require the vault password and as such can be used by anyone out of the box: the Jenkins setup is skipped in this case. Signed-off-by: Andrea Bolognani --- guests/lcitool | 35 ++++++++++++++++++++++++++++++++--- guests/site.yml | 1 + 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/guests/lcitool b/guests/lcitool index 883e0eb..bf270f1 100755 --- a/guests/lcitool +++ b/guests/lcitool @@ -59,13 +59,39 @@ load_install_config() { load_config() { CONFIG_DIR=3D"$HOME/.config/$PROGRAM_NAME" =20 + mkdir -p "$CONFIG_DIR" >/dev/null 2>&1 || { + die "$PROGRAM_NAME: $CONFIG_DIR: Unable to create config directory" + } + + FLAVOR_FILE=3D"$CONFIG_DIR/flavor" VAULT_PASS_FILE=3D"$CONFIG_DIR/vault-password" ROOT_PASS_FILE=3D"$CONFIG_DIR/root-password" =20 - # Make sure required passwords exist and are not invalid (empty) - test -f "$VAULT_PASS_FILE" && test "$(cat "$VAULT_PASS_FILE")" || { - die "$PROGRAM_NAME: $VAULT_PASS_FILE: Missing or invalid password" + # Two flavors are supported: developer (default) and ci. Read the + # flavor from configuration, validate it and write it back in case + # it was not present + FLAVOR=3D"$(cat "$FLAVOR_FILE" 2>/dev/null)" + FLAVOR=3D${FLAVOR:-developer} + test "$FLAVOR" =3D developer || test "$FLAVOR" =3D ci || { + die "$PROGRAM_NAME: Invalid flavor '$FLAVOR'" } + echo "$FLAVOR" >"$FLAVOR_FILE" || { + die "$PROGRAM_NAME: $FLAVOR_FILE: Unable to save flavor" + } + + test "$FLAVOR" =3D ci && { + # The vault password is only needed for the ci flavor, so only + # validate it in that case + test -f "$VAULT_PASS_FILE" && test "$(cat "$VAULT_PASS_FILE")" || { + die "$PROGRAM_NAME: $VAULT_PASS_FILE: Missing or invalid passw= ord" + } + } || { + # For other flavors, undefine the variable so that Ansible + # will not try to read the file at all + VAULT_PASS_FILE=3D + } + + # Make sure the root password has been configured properly test -f "$ROOT_PASS_FILE" && test "$(cat "$ROOT_PASS_FILE")" || { die "$PROGRAM_NAME: $ROOT_PASS_FILE: Missing or invalid password" } @@ -164,8 +190,11 @@ do_prepare() { =20 load_config =20 + EXTRA_VARS=3D"flavor=3D$FLAVOR" + ansible-playbook \ --vault-password-file "$VAULT_PASS_FILE" \ + --extra-vars "$EXTRA_VARS" \ -l "$GUEST" \ site.yml } diff --git a/guests/site.yml b/guests/site.yml index 9c75dcb..35e3220 100644 --- a/guests/site.yml +++ b/guests/site.yml @@ -30,6 +30,7 @@ # Configure the Jenkins agent - include: tasks/jenkins.yml when: + - flavor =3D=3D 'ci' - projects is defined # jenkins is a pseudo-project - ( 'jenkins' in projects ) --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list