From nobody Thu May 15 20:14:25 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 1508346748345670.0877013761857; Wed, 18 Oct 2017 10:12:28 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 3FE93C047B8B; Wed, 18 Oct 2017 17:12:27 +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 1D0245D96F; Wed, 18 Oct 2017 17:12:27 +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 DB80C410AE; Wed, 18 Oct 2017 17:12:26 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v9IHBx0a011765 for ; Wed, 18 Oct 2017 13:11:59 -0400 Received: by smtp.corp.redhat.com (Postfix) id D0FA66A50A; Wed, 18 Oct 2017 17:11:59 +0000 (UTC) Received: from inaba.usersys.redhat.com (unknown [10.40.205.73]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 36A7A6A517 for ; Wed, 18 Oct 2017 17:11:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 3FE93C047B8B Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Andrea Bolognani To: libvir-list@redhat.com Date: Wed, 18 Oct 2017 19:11:47 +0200 Message-Id: <20171018171151.12789-3-abologna@redhat.com> In-Reply-To: <20171018171151.12789-1-abologna@redhat.com> References: <20171018171151.12789-1-abologna@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [libvirt-jenkins-ci PATCH v2 2/6] guests: Introduce lcitool 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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Wed, 18 Oct 2017 17:12:27 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This script replaces the existing Makefile, and will be extended to provide more functionality in future commits. It also takes over ownership of the Ansible vault password, which is now expected to be stored in lcitool's own config directory along with more settings that will be introduced later. Signed-off-by: Andrea Bolognani --- guests/Makefile | 12 --------- guests/ansible.cfg | 1 - guests/lcitool | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++= ++++ 3 files changed, 76 insertions(+), 13 deletions(-) delete mode 100644 guests/Makefile create mode 100755 guests/lcitool diff --git a/guests/Makefile b/guests/Makefile deleted file mode 100644 index 39ebe52..0000000 --- a/guests/Makefile +++ /dev/null @@ -1,12 +0,0 @@ -all: - -site: - @ansible-playbook site.yml - -bootstrap: - @ansible-playbook --ask-pass bootstrap.yml - -clean: - @rm -f *.retry log - -.PHONY: all site bootstrap clean diff --git a/guests/ansible.cfg b/guests/ansible.cfg index 84fde77..6b18c57 100644 --- a/guests/ansible.cfg +++ b/guests/ansible.cfg @@ -5,7 +5,6 @@ inventory =3D ./inventory log_path =3D ./log nocows =3D 1 squash_actions =3D package -vault_password_file =3D ~/.ansible/libvirt-jenkins-ci.vault-password =20 [ssh_connection] pipelining =3D True diff --git a/guests/lcitool b/guests/lcitool new file mode 100755 index 0000000..aaee5f9 --- /dev/null +++ b/guests/lcitool @@ -0,0 +1,76 @@ +#!/bin/sh + +# ------------------- +# Utility functions +# ------------------- + +# die MESSAGE +# +# Abort the program after displaying $MESSAGE on standard error. +die() { + echo "$1" >&2 + exit 1 +} + +# ---------------------- +# User-visible actions +# ---------------------- + +do_help() { + echo "\ +Usage: $CALL_NAME ACTION [OPTIONS] + +Actions: + list List known guests + prepare GUEST|all Prepare or update GUEST. Can be run multiple times + update GUEST|all Alias for prepare + help Display this help" +} + +do_list() { + # List all guests present in the inventory. Skip group names, + # comments and empty lines + grep -vE '^#|^\[|^$' inventory | sort -u +} + +do_prepare() { + GUEST=3D"$1" + + test "$GUEST" || { + die "$(do_help)" + } + do_list | grep -q "$GUEST" || test "$GUEST" =3D all || { + die "$PROGRAM_NAME: $GUEST: Unknown guest" + } + + VAULT_PASS_FILE=3D"$CONFIG_DIR/vault-password" + + # 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" + } + + ansible-playbook \ + --vault-password-file "$VAULT_PASS_FILE" \ + -l "$GUEST" \ + site.yml +} + +# --------------------- +# Program entry point +# --------------------- + +CALL_NAME=3D"$0" +PROGRAM_NAME=3D"${0##*/}" +CONFIG_DIR=3D"$HOME/.config/$PROGRAM_NAME" + +test -f "$PROGRAM_NAME" || { + die "$PROGRAM_NAME: Must be run from the source directory" +} + +case "$1" in + list) do_list ;; + prepare|update) do_prepare "$2" ;; + *help) do_help ;; + *) die "$(do_help)" ;; +esac --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list