[libvirt] [jenkins-ci PATCH v2 07/12] lcitool: Implement the 'update' action

Andrea Bolognani abologna at redhat.com
Thu Jul 12 15:19:24 UTC 2018


The 'prepare' alias was kinda redundant and offered
dubious value, so it has been dropped.

Signed-off-by: Andrea Bolognani <abologna at redhat.com>
---
 guests/lcitool | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/guests/lcitool b/guests/lcitool
index 486f82f..d82c36f 100755
--- a/guests/lcitool
+++ b/guests/lcitool
@@ -246,6 +246,7 @@ class Application:
             epilog = textwrap.dedent("""
                 common actions:
                   install  perform unattended host installation
+                  update   prepare hosts and keep them updated
 
                 informational actions:
                   hosts  list all known hosts
@@ -327,6 +328,35 @@ class Application:
             except:
                 raise Error("Failed to install '{}'".format(host))
 
+    def _action_update(self, hosts):
+        flavor = self._config.get_flavor()
+        vault_pass_file = self._config.get_vault_password_file()
+        root_pass_file = self._config.get_root_password_file()
+
+        ansible_hosts = ",".join(self._inventory.expand_pattern(hosts))
+
+        extra_vars = "flavor={} root_password_file={}".format(
+            flavor,
+            root_pass_file,
+        )
+
+        cmd = [ "ansible-playbook" ]
+
+        # Provide the vault password if available
+        if vault_pass_file is not None:
+            cmd += [ "--vault-password-file", vault_pass_file ]
+
+        cmd += [
+            "--limit", ansible_hosts,
+            "--extra-vars", extra_vars,
+            "./site.yml",
+        ]
+
+        try:
+            subprocess.check_call(cmd)
+        except:
+            raise Error("Failed to update '{}'".format(hosts))
+
     def run(self):
         cmdline = self._parser.parse_args()
         action = cmdline.a
-- 
2.17.1




More information about the libvir-list mailing list