[libvirt] [jenkins-ci PATCH 7/8] lcitool: Implement the 'update' action

Andrea Bolognani abologna at redhat.com
Wed Jul 11 15:54:35 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 cefce65..c17c174 100755
--- a/guests/lcitool
+++ b/guests/lcitool
@@ -240,6 +240,7 @@ class Application:
                 supported actions:
                   list     list all known hosts
                   install  perform unattended host installation
+                  update   prepare hosts and keep them updated
                 """),
         )
         self._parser.add_argument(
@@ -316,6 +317,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