[libvirt] [jenkins-ci PATCH 3/5] guests: Make PERL5LIB dynamic

Andrea Bolognani posted 5 patches 6 years, 11 months ago
[libvirt] [jenkins-ci PATCH 3/5] guests: Make PERL5LIB dynamic
Posted by Andrea Bolognani 6 years, 11 months ago
Instead of having to specify this separately for every
guest due to minor differences in the environment, figure
it out at login time by asking Perl itself for the
information we need.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
---
 guests/group_vars/all/main.yml                    | 1 -
 guests/host_vars/libvirt-centos-6/main.yml        | 1 -
 guests/host_vars/libvirt-centos-7/main.yml        | 1 -
 guests/host_vars/libvirt-debian-8/main.yml        | 1 -
 guests/host_vars/libvirt-debian-9/main.yml        | 1 -
 guests/host_vars/libvirt-debian-sid/main.yml      | 1 -
 guests/host_vars/libvirt-fedora-27/main.yml       | 1 -
 guests/host_vars/libvirt-fedora-28/main.yml       | 1 -
 guests/host_vars/libvirt-fedora-rawhide/main.yml  | 1 -
 guests/host_vars/libvirt-freebsd-10/main.yml      | 1 -
 guests/host_vars/libvirt-freebsd-11/main.yml      | 1 -
 guests/host_vars/libvirt-freebsd-current/main.yml | 1 -
 guests/host_vars/libvirt-ubuntu-14/main.yml       | 1 -
 guests/host_vars/libvirt-ubuntu-16/main.yml       | 1 -
 guests/host_vars/libvirt-ubuntu-18/main.yml       | 1 -
 guests/templates/bashrc.j2                        | 6 +++++-
 16 files changed, 5 insertions(+), 16 deletions(-)

diff --git a/guests/group_vars/all/main.yml b/guests/group_vars/all/main.yml
index cd8ef25..840c80b 100644
--- a/guests/group_vars/all/main.yml
+++ b/guests/group_vars/all/main.yml
@@ -16,5 +16,4 @@ PKG_CONFIG_PATH: $VIRT_PREFIX/lib/pkgconfig
 XDG_DATA_DIRS: $VIRT_PREFIX/share:/usr/share:/usr/local/share
 GI_TYPELIB_PATH: $VIRT_PREFIX/lib/girepository-1.0
 OSINFO_SYSTEM_DIR: $VIRT_PREFIX/share/osinfo
-PERL5LIB:
 PYTHONPATH:
diff --git a/guests/host_vars/libvirt-centos-6/main.yml b/guests/host_vars/libvirt-centos-6/main.yml
index 8b18c19..c27c1ad 100644
--- a/guests/host_vars/libvirt-centos-6/main.yml
+++ b/guests/host_vars/libvirt-centos-6/main.yml
@@ -1,5 +1,4 @@
 ---
-PERL5LIB: $VIRT_PREFIX/lib/perl5/x86_64-linux-thread-multi
 PYTHONPATH: $VIRT_PREFIX/lib64/python2.6/site-packages
 
 projects:
diff --git a/guests/host_vars/libvirt-centos-7/main.yml b/guests/host_vars/libvirt-centos-7/main.yml
index 8f88615..6cb8995 100644
--- a/guests/host_vars/libvirt-centos-7/main.yml
+++ b/guests/host_vars/libvirt-centos-7/main.yml
@@ -1,5 +1,4 @@
 ---
-PERL5LIB: $VIRT_PREFIX/lib/perl5/x86_64-linux-thread-multi
 PYTHONPATH: $VIRT_PREFIX/lib64/python2.7/site-packages
 
 projects:
diff --git a/guests/host_vars/libvirt-debian-8/main.yml b/guests/host_vars/libvirt-debian-8/main.yml
index d0b3601..64f3255 100644
--- a/guests/host_vars/libvirt-debian-8/main.yml
+++ b/guests/host_vars/libvirt-debian-8/main.yml
@@ -1,5 +1,4 @@
 ---
-PERL5LIB: $VIRT_PREFIX/lib/perl5/x86_64-linux-gnu-thread-multi
 PYTHONPATH: $VIRT_PREFIX/lib/python3.4/site-packages
 
 projects:
diff --git a/guests/host_vars/libvirt-debian-9/main.yml b/guests/host_vars/libvirt-debian-9/main.yml
index caf513e..04d5132 100644
--- a/guests/host_vars/libvirt-debian-9/main.yml
+++ b/guests/host_vars/libvirt-debian-9/main.yml
@@ -1,5 +1,4 @@
 ---
-PERL5LIB: $VIRT_PREFIX/lib/perl5/x86_64-linux-gnu-thread-multi
 PYTHONPATH: $VIRT_PREFIX/lib/python3.5/site-packages
 
 projects:
diff --git a/guests/host_vars/libvirt-debian-sid/main.yml b/guests/host_vars/libvirt-debian-sid/main.yml
index 88b8b9b..cbf57aa 100644
--- a/guests/host_vars/libvirt-debian-sid/main.yml
+++ b/guests/host_vars/libvirt-debian-sid/main.yml
@@ -1,5 +1,4 @@
 ---
-PERL5LIB: $VIRT_PREFIX/lib/perl5/x86_64-linux-gnu-thread-multi
 PYTHONPATH: $VIRT_PREFIX/lib/python3.6/site-packages
 
 projects:
diff --git a/guests/host_vars/libvirt-fedora-27/main.yml b/guests/host_vars/libvirt-fedora-27/main.yml
index 20d90c5..9ed392b 100644
--- a/guests/host_vars/libvirt-fedora-27/main.yml
+++ b/guests/host_vars/libvirt-fedora-27/main.yml
@@ -1,5 +1,4 @@
 ---
-PERL5LIB: $VIRT_PREFIX/lib/perl5/x86_64-linux-thread-multi
 PYTHONPATH: $VIRT_PREFIX/lib64/python3.6/site-packages
 
 projects:
diff --git a/guests/host_vars/libvirt-fedora-28/main.yml b/guests/host_vars/libvirt-fedora-28/main.yml
index 20d90c5..9ed392b 100644
--- a/guests/host_vars/libvirt-fedora-28/main.yml
+++ b/guests/host_vars/libvirt-fedora-28/main.yml
@@ -1,5 +1,4 @@
 ---
-PERL5LIB: $VIRT_PREFIX/lib/perl5/x86_64-linux-thread-multi
 PYTHONPATH: $VIRT_PREFIX/lib64/python3.6/site-packages
 
 projects:
diff --git a/guests/host_vars/libvirt-fedora-rawhide/main.yml b/guests/host_vars/libvirt-fedora-rawhide/main.yml
index 202eccf..91b4158 100644
--- a/guests/host_vars/libvirt-fedora-rawhide/main.yml
+++ b/guests/host_vars/libvirt-fedora-rawhide/main.yml
@@ -1,5 +1,4 @@
 ---
-PERL5LIB: $VIRT_PREFIX/lib/perl5/x86_64-linux-thread-multi
 PYTHONPATH: $VIRT_PREFIX/lib64/python3.6/site-packages
 
 projects:
diff --git a/guests/host_vars/libvirt-freebsd-10/main.yml b/guests/host_vars/libvirt-freebsd-10/main.yml
index ac5f12b..e37c845 100644
--- a/guests/host_vars/libvirt-freebsd-10/main.yml
+++ b/guests/host_vars/libvirt-freebsd-10/main.yml
@@ -1,7 +1,6 @@
 ---
 ansible_python_interpreter: /usr/local/bin/python2
 
-PERL5LIB: $VIRT_PREFIX/lib/perl5/amd64-freebsd-thread-multi
 PYTHONPATH: $VIRT_PREFIX/lib/python3.6/site-packages
 
 projects:
diff --git a/guests/host_vars/libvirt-freebsd-11/main.yml b/guests/host_vars/libvirt-freebsd-11/main.yml
index ac5f12b..e37c845 100644
--- a/guests/host_vars/libvirt-freebsd-11/main.yml
+++ b/guests/host_vars/libvirt-freebsd-11/main.yml
@@ -1,7 +1,6 @@
 ---
 ansible_python_interpreter: /usr/local/bin/python2
 
-PERL5LIB: $VIRT_PREFIX/lib/perl5/amd64-freebsd-thread-multi
 PYTHONPATH: $VIRT_PREFIX/lib/python3.6/site-packages
 
 projects:
diff --git a/guests/host_vars/libvirt-freebsd-current/main.yml b/guests/host_vars/libvirt-freebsd-current/main.yml
index ac5f12b..e37c845 100644
--- a/guests/host_vars/libvirt-freebsd-current/main.yml
+++ b/guests/host_vars/libvirt-freebsd-current/main.yml
@@ -1,7 +1,6 @@
 ---
 ansible_python_interpreter: /usr/local/bin/python2
 
-PERL5LIB: $VIRT_PREFIX/lib/perl5/amd64-freebsd-thread-multi
 PYTHONPATH: $VIRT_PREFIX/lib/python3.6/site-packages
 
 projects:
diff --git a/guests/host_vars/libvirt-ubuntu-14/main.yml b/guests/host_vars/libvirt-ubuntu-14/main.yml
index fccd0ef..bfbdda6 100644
--- a/guests/host_vars/libvirt-ubuntu-14/main.yml
+++ b/guests/host_vars/libvirt-ubuntu-14/main.yml
@@ -1,5 +1,4 @@
 ---
-PERL5LIB: $VIRT_PREFIX/lib/perl5/x86_64-linux-gnu-thread-multi
 PYTHONPATH: $VIRT_PREFIX/lib/python3.4/site-packages
 
 projects:
diff --git a/guests/host_vars/libvirt-ubuntu-16/main.yml b/guests/host_vars/libvirt-ubuntu-16/main.yml
index caf513e..04d5132 100644
--- a/guests/host_vars/libvirt-ubuntu-16/main.yml
+++ b/guests/host_vars/libvirt-ubuntu-16/main.yml
@@ -1,5 +1,4 @@
 ---
-PERL5LIB: $VIRT_PREFIX/lib/perl5/x86_64-linux-gnu-thread-multi
 PYTHONPATH: $VIRT_PREFIX/lib/python3.5/site-packages
 
 projects:
diff --git a/guests/host_vars/libvirt-ubuntu-18/main.yml b/guests/host_vars/libvirt-ubuntu-18/main.yml
index 88b8b9b..cbf57aa 100644
--- a/guests/host_vars/libvirt-ubuntu-18/main.yml
+++ b/guests/host_vars/libvirt-ubuntu-18/main.yml
@@ -1,5 +1,4 @@
 ---
-PERL5LIB: $VIRT_PREFIX/lib/perl5/x86_64-linux-gnu-thread-multi
 PYTHONPATH: $VIRT_PREFIX/lib/python3.6/site-packages
 
 projects:
diff --git a/guests/templates/bashrc.j2 b/guests/templates/bashrc.j2
index 866087e..cf2679e 100644
--- a/guests/templates/bashrc.j2
+++ b/guests/templates/bashrc.j2
@@ -8,12 +8,16 @@ export PKG_CONFIG_PATH="{{ PKG_CONFIG_PATH }}"
 export XDG_DATA_DIRS="{{ XDG_DATA_DIRS }}"
 export GI_TYPELIB_PATH="{{ GI_TYPELIB_PATH }}"
 export OSINFO_SYSTEM_DIR="{{ OSINFO_SYSTEM_DIR }}"
-export PERL5LIB="{{ PERL5LIB }}"
 export PYTHONPATH="{{ PYTHONPATH }}"
 
 export MAKE="{{ make }}"
 export PYTHON="{{ python }}"
 
+# We need to ask Perl for this information, since it's used to
+# construct installation paths
+plarch=$(perl -e 'use Config; print $Config{archname}')
+export PERL5LIB="$VIRT_PREFIX/lib/perl5/$plarch"
+
 # Enable bash completion. Only needed on FreeBSD, the system-wide
 # shell profile will take care of it for us everywhere else
 bash_completion=/usr/local/share/bash-completion/bash_completion.sh
-- 
2.17.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [jenkins-ci PATCH 3/5] guests: Make PERL5LIB dynamic
Posted by Daniel P. Berrangé 6 years, 11 months ago
On Mon, May 21, 2018 at 06:53:25PM +0200, Andrea Bolognani wrote:
> Instead of having to specify this separately for every
> guest due to minor differences in the environment, figure
> it out at login time by asking Perl itself for the
> information we need.

We still have the problem that any time a package update is done it
might pull in a newer Perl, which will change the path, but our
Jenkins slave never picks it up until the VM is rebooted.

I wonder if we can solve this by instead of putting all these
env vars in the main bash profile, we create a

   'jenkins-ci.sh'

that contains all the env variables. We can then source that
from the bash profile, and also source it as the first thing
we do in every build job too. 


Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [jenkins-ci PATCH 3/5] guests: Make PERL5LIB dynamic
Posted by Andrea Bolognani 6 years, 11 months ago
On Tue, 2018-06-05 at 11:42 +0100, Daniel P. Berrangé wrote:
> On Mon, May 21, 2018 at 06:53:25PM +0200, Andrea Bolognani wrote:
> > Instead of having to specify this separately for every
> > guest due to minor differences in the environment, figure
> > it out at login time by asking Perl itself for the
> > information we need.
> 
> We still have the problem that any time a package update is done it
> might pull in a newer Perl, which will change the path, but our
> Jenkins slave never picks it up until the VM is rebooted.

Is that the case, though? I'm not entirely clear on the lifecycle,
but it might very well be the case that the Jenkins agent spawns
a separate session for each job, in which case changes to the shell
profile would be picked up immediately.

We can perhaps leave it as is for now, and see whether it breaks
at some point down the line.

> I wonder if we can solve this by instead of putting all these
> env vars in the main bash profile, we create a
> 
>    'jenkins-ci.sh'
> 
> that contains all the env variables. We can then source that
> from the bash profile, and also source it as the first thing
> we do in every build job too.

If we really need to do that, might as well source ~/.bashrc right
at the start of every build job instead of having a separate
script: the only unnecessary bits are setting up the prompt and
bash completion, but there's no harm in having them in there.

-- 
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 3/5] guests: Make PERL5LIB dynamic
Posted by Daniel P. Berrangé 6 years, 11 months ago
On Tue, Jun 05, 2018 at 01:10:45PM +0200, Andrea Bolognani wrote:
> On Tue, 2018-06-05 at 11:42 +0100, Daniel P. Berrangé wrote:
> > On Mon, May 21, 2018 at 06:53:25PM +0200, Andrea Bolognani wrote:
> > > Instead of having to specify this separately for every
> > > guest due to minor differences in the environment, figure
> > > it out at login time by asking Perl itself for the
> > > information we need.
> > 
> > We still have the problem that any time a package update is done it
> > might pull in a newer Perl, which will change the path, but our
> > Jenkins slave never picks it up until the VM is rebooted.
> 
> Is that the case, though? I'm not entirely clear on the lifecycle,
> but it might very well be the case that the Jenkins agent spawns
> a separate session for each job, in which case changes to the shell
> profile would be picked up immediately.

Since we move env variables out of jenkins host config and into
the ansible host config, any time we've made env variable changes
we've had to restart the agent or host to pick it up.

> > I wonder if we can solve this by instead of putting all these
> > env vars in the main bash profile, we create a
> > 
> >    'jenkins-ci.sh'
> > 
> > that contains all the env variables. We can then source that
> > from the bash profile, and also source it as the first thing
> > we do in every build job too.
> 
> If we really need to do that, might as well source ~/.bashrc right
> at the start of every build job instead of having a separate
> script: the only unnecessary bits are setting up the prompt and
> bash completion, but there's no harm in having them in there.

Oh true, yes, we can do that.

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [jenkins-ci PATCH 3/5] guests: Make PERL5LIB dynamic
Posted by Daniel P. Berrangé 6 years, 11 months ago
On Mon, May 21, 2018 at 06:53:25PM +0200, Andrea Bolognani wrote:
> Instead of having to specify this separately for every
> guest due to minor differences in the environment, figure
> it out at login time by asking Perl itself for the
> information we need.
> 
> Signed-off-by: Andrea Bolognani <abologna@redhat.com>
> ---
>  guests/group_vars/all/main.yml                    | 1 -
>  guests/host_vars/libvirt-centos-6/main.yml        | 1 -
>  guests/host_vars/libvirt-centos-7/main.yml        | 1 -
>  guests/host_vars/libvirt-debian-8/main.yml        | 1 -
>  guests/host_vars/libvirt-debian-9/main.yml        | 1 -
>  guests/host_vars/libvirt-debian-sid/main.yml      | 1 -
>  guests/host_vars/libvirt-fedora-27/main.yml       | 1 -
>  guests/host_vars/libvirt-fedora-28/main.yml       | 1 -
>  guests/host_vars/libvirt-fedora-rawhide/main.yml  | 1 -
>  guests/host_vars/libvirt-freebsd-10/main.yml      | 1 -
>  guests/host_vars/libvirt-freebsd-11/main.yml      | 1 -
>  guests/host_vars/libvirt-freebsd-current/main.yml | 1 -
>  guests/host_vars/libvirt-ubuntu-14/main.yml       | 1 -
>  guests/host_vars/libvirt-ubuntu-16/main.yml       | 1 -
>  guests/host_vars/libvirt-ubuntu-18/main.yml       | 1 -
>  guests/templates/bashrc.j2                        | 6 +++++-
>  16 files changed, 5 insertions(+), 16 deletions(-)

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>



Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

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