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

2018-07-17 Thread Katerina Koukiou
On Tue, Jul 17, 2018 at 04:45:39PM +0200, Andrea Bolognani wrote:
> On Tue, 2018-07-17 at 14:57 +0200, Katerina Koukiou wrote:
> > On Thu, Jul 12, 2018 at 05:19:24PM +0200, Andrea Bolognani wrote:
> > > +cmd = [ "ansible-playbook" ]
> > 
> > IMO this requirement should be as well in python requirements file.
> > In this way you can also specify which ansible version is expected for the
> > site.yaml playbook to run.
> 
> I had no idea you could require commands as well as Python modules.
> Clearly shows that I need to read up on the stuff :)

Ansible is available from pypi https://pypi.org/project/ansible/

Well I had in mind only pip requirements just put together in a
requirements file so that you can install them with `pip install -r
requirements.txt`.

Then you can easily test different ansible versions for example.

Anyway, of course this can be addressed in the future.

> 
> -- 
> Andrea Bolognani / Red Hat / Virtualization


signature.asc
Description: PGP signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

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

2018-07-17 Thread Andrea Bolognani
On Tue, 2018-07-17 at 14:57 +0200, Katerina Koukiou wrote:
> On Thu, Jul 12, 2018 at 05:19:24PM +0200, Andrea Bolognani wrote:
> > +cmd = [ "ansible-playbook" ]
> 
> IMO this requirement should be as well in python requirements file.
> In this way you can also specify which ansible version is expected for the
> site.yaml playbook to run.

I had no idea you could require commands as well as Python modules.
Clearly shows that I need to read up on the stuff :)

-- 
Andrea Bolognani / Red Hat / Virtualization

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


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

2018-07-17 Thread Katerina Koukiou
On Thu, Jul 12, 2018 at 05:19:24PM +0200, Andrea Bolognani wrote:
> The 'prepare' alias was kinda redundant and offered
> dubious value, so it has been dropped.
> 
> Signed-off-by: Andrea Bolognani 
> ---
>  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" ]

IMO this requirement should be as well in python requirements file.
In this way you can also specify which ansible version is expected for the
site.yaml playbook to run.

> +
> +# 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
> 
> --
> libvir-list mailing list
> libvir-list@redhat.com
> https://www.redhat.com/mailman/listinfo/libvir-list


signature.asc
Description: PGP signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list