From nobody Tue Feb 10 13:34:41 2026 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; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1534515568604272.5165719379853; Fri, 17 Aug 2018 07:19:28 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C15C0C04BE00; Fri, 17 Aug 2018 14:19: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 86DE1101E597; Fri, 17 Aug 2018 14:19: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 40C8A181A721; Fri, 17 Aug 2018 14:19:26 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w7HEIf5V014032 for ; Fri, 17 Aug 2018 10:18:41 -0400 Received: by smtp.corp.redhat.com (Postfix) id B498417479; Fri, 17 Aug 2018 14:18:41 +0000 (UTC) Received: from inaba.usersys.redhat.com (unknown [10.43.2.44]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5337717471 for ; Fri, 17 Aug 2018 14:18:41 +0000 (UTC) From: Andrea Bolognani To: libvir-list@redhat.com Date: Fri, 17 Aug 2018 16:18:25 +0200 Message-Id: <20180817141829.25302-10-abologna@redhat.com> In-Reply-To: <20180817141829.25302-1-abologna@redhat.com> References: <20180817141829.25302-1-abologna@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Subject: [libvirt] [jenkins-ci PATCH v2 09/13] lcitool: Make playbook execution generic 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.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Fri, 17 Aug 2018 14:19:27 +0000 (UTC) X-ZohoMail: RDMRC_0 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Andrea Bolognani --- guests/lcitool | 87 ++++++++++++++++++++++++++------------------------ 1 file changed, 45 insertions(+), 42 deletions(-) diff --git a/guests/lcitool b/guests/lcitool index f28199d..e0410f3 100755 --- a/guests/lcitool +++ b/guests/lcitool @@ -351,6 +351,50 @@ class Application: help=3D"list of projects to consider", ) =20 + def _execute_playbook(self, playbook, hosts, projects): + base =3D Util.get_base() + + 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() + + ansible_hosts =3D ",".join(self._inventory.expand_pattern(hosts)) + selected_projects =3D self._projects.expand_pattern(projects) + + 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({ + "base": base, + "playbook_base": playbook_base, + "root_password_file": root_pass_file, + "flavor": flavor, + "selected_projects": selected_projects, + }) + + cmd =3D [ + "ansible-playbook", + "--limit", ansible_hosts, + "--extra-vars", extra_vars, + ] + + # Provide the vault password if available + if vault_pass_file is not None: + cmd +=3D ["--vault-password-file", vault_pass_file] + + cmd +=3D [playbook_path] + + # We need to point Ansible to the correct configuration file, + # and for some reason this has to be done using the environment + # rather than through the command line + os.environ["ANSIBLE_CONFIG"] =3D ansible_cfg_path + + try: + subprocess.check_call(cmd) + except Exception: + raise Error("Failed to run {} on '{}'".format(playbook, hosts)) + def _action_hosts(self, _hosts, _projects): for host in self._inventory.expand_pattern("all"): print(host) @@ -431,48 +475,7 @@ class Application: raise Error("Failed to install '{}'".format(host)) =20 def _action_update(self, hosts, projects): - base =3D Util.get_base() - - 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() - - ansible_hosts =3D ",".join(self._inventory.expand_pattern(hosts)) - selected_projects =3D self._projects.expand_pattern(projects) - - ansible_cfg_path =3D os.path.join(base, "ansible.cfg") - playbook_base =3D os.path.join(base, "playbooks", "update") - playbook_path =3D os.path.join(playbook_base, "main.yml") - - extra_vars =3D json.dumps({ - "base": base, - "playbook_base": playbook_base, - "root_password_file": root_pass_file, - "flavor": flavor, - "selected_projects": selected_projects, - }) - - cmd =3D [ - "ansible-playbook", - "--limit", ansible_hosts, - "--extra-vars", extra_vars, - ] - - # Provide the vault password if available - if vault_pass_file is not None: - cmd +=3D ["--vault-password-file", vault_pass_file] - - cmd +=3D [playbook_path] - - # We need to point Ansible to the correct configuration file, - # and for some reason this has to be done using the environment - # rather than through the command line - os.environ["ANSIBLE_CONFIG"] =3D ansible_cfg_path - - try: - subprocess.check_call(cmd) - except Exception: - raise Error("Failed to update '{}'".format(hosts)) + self._execute_playbook("update", hosts, projects) =20 def _action_dockerfile(self, hosts, projects): mappings =3D self._projects.get_mappings() --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list