diff mbox series

[v6,2/4] Jobs based on custom runners: build environment docs and playbook

Message ID 20210608031425.833536-3-crosa@redhat.com
State New
Headers show
Series GitLab Custom Runners and Jobs (was: QEMU Gating CI) | expand

Commit Message

Cleber Rosa June 8, 2021, 3:14 a.m. UTC
To run basic jobs on custom runners, the environment needs to be
properly set up.  The most common requirement is having the right
packages installed.

The playbook introduced here covers the QEMU's project s390x and
aarch64 machines.  At the time this is being proposed, those machines
have already had this playbook applied to them.

Signed-off-by: Cleber Rosa <crosa@redhat.com>
---
 docs/devel/ci.rst                      | 30 ++++++++
 scripts/ci/setup/build-environment.yml | 98 ++++++++++++++++++++++++++
 scripts/ci/setup/inventory.template    |  1 +
 3 files changed, 129 insertions(+)
 create mode 100644 scripts/ci/setup/build-environment.yml
 create mode 100644 scripts/ci/setup/inventory.template

Comments

Wainer dos Santos Moschetta June 8, 2021, 6:48 p.m. UTC | #1
Hi,

On 6/8/21 12:14 AM, Cleber Rosa wrote:
> To run basic jobs on custom runners, the environment needs to be
> properly set up.  The most common requirement is having the right
> packages installed.
>
> The playbook introduced here covers the QEMU's project s390x and
> aarch64 machines.  At the time this is being proposed, those machines
> have already had this playbook applied to them.
>
> Signed-off-by: Cleber Rosa <crosa@redhat.com>
> ---
>   docs/devel/ci.rst                      | 30 ++++++++
>   scripts/ci/setup/build-environment.yml | 98 ++++++++++++++++++++++++++
>   scripts/ci/setup/inventory.template    |  1 +
>   3 files changed, 129 insertions(+)
>   create mode 100644 scripts/ci/setup/build-environment.yml
>   create mode 100644 scripts/ci/setup/inventory.template
>
> diff --git a/docs/devel/ci.rst b/docs/devel/ci.rst
> index 585b7bf4b8..35c6b5e269 100644
> --- a/docs/devel/ci.rst
> +++ b/docs/devel/ci.rst
> @@ -26,3 +26,33 @@ gitlab-runner, is called a "custom runner".
>   The GitLab CI jobs definition for the custom runners are located under::
>   
>     .gitlab-ci.d/custom-runners.yml
> +
> +Machine Setup Howto
> +-------------------
> +
> +For all Linux based systems, the setup can be mostly automated by the
> +execution of two Ansible playbooks.  Create an ``inventory`` file
> +under ``scripts/ci/setup``, such as this::
Missing to mention the template file.
> +
> +  fully.qualified.domain
> +  other.machine.hostname
> +
> +You may need to set some variables in the inventory file itself.  One
> +very common need is to tell Ansible to use a Python 3 interpreter on
> +those hosts.  This would look like::
> +
> +  fully.qualified.domain ansible_python_interpreter=/usr/bin/python3
> +  other.machine.hostname ansible_python_interpreter=/usr/bin/python3
> +
> +Build environment
> +~~~~~~~~~~~~~~~~~
> +
> +The ``scripts/ci/setup/build-environment.yml`` Ansible playbook will
> +set up machines with the environment needed to perform builds and run
> +QEMU tests.  It covers a number of different Linux distributions and
> +FreeBSD.
> +
> +To run the playbook, execute::
> +
> +  cd scripts/ci/setup
> +  ansible-playbook -i inventory build-environment.yml
> diff --git a/scripts/ci/setup/build-environment.yml b/scripts/ci/setup/build-environment.yml
> new file mode 100644
> index 0000000000..664f2f0519
> --- /dev/null
> +++ b/scripts/ci/setup/build-environment.yml
> @@ -0,0 +1,98 @@
> +---
> +- name: Installation of basic packages to build QEMU
> +  hosts: all

You will need to "become: yes" if the login user is not privileged, right?

Or mention on the documentation how the user should configure the 
connection for privileged login.

About privilege escalation with Ansible: 
https://docs.ansible.com/ansible/latest/user_guide/become.html

> +  tasks:

Just a tip: you can put all those task under a block 
(https://docs.ansible.com/ansible/latest/user_guide/playbooks_blocks.html) 
so check if "ansible_facts['distribution'] == 'Ubuntu'" only once.

I reviewed the remain of the playbook; it looks good to me.

> +    - name: Update apt cache
> +      apt:
> +        update_cache: yes
> +      when:
> +        - ansible_facts['distribution'] == 'Ubuntu'
> +
> +    - name: Install basic packages to build QEMU on Ubuntu 18.04/20.04
> +      package:
> +        name:
> +        # Originally from tests/docker/dockerfiles/ubuntu1804.docker
> +          - ccache
> +          - gcc
> +          - gettext
> +          - git
> +          - glusterfs-common
> +          - libaio-dev
> +          - libattr1-dev
> +          - libbrlapi-dev
> +          - libbz2-dev
> +          - libcacard-dev
> +          - libcap-ng-dev
> +          - libcurl4-gnutls-dev
> +          - libdrm-dev
> +          - libepoxy-dev
> +          - libfdt-dev
> +          - libgbm-dev
> +          - libgtk-3-dev
> +          - libibverbs-dev
> +          - libiscsi-dev
> +          - libjemalloc-dev
> +          - libjpeg-turbo8-dev
> +          - liblzo2-dev
> +          - libncurses5-dev
> +          - libncursesw5-dev
> +          - libnfs-dev
> +          - libnss3-dev
> +          - libnuma-dev
> +          - libpixman-1-dev
> +          - librados-dev
> +          - librbd-dev
> +          - librdmacm-dev
> +          - libsasl2-dev
> +          - libsdl2-dev
> +          - libseccomp-dev
> +          - libsnappy-dev
> +          - libspice-protocol-dev
> +          - libssh-dev
> +          - libusb-1.0-0-dev
> +          - libusbredirhost-dev
> +          - libvdeplug-dev
> +          - libvte-2.91-dev
> +          - libzstd-dev
> +          - make
> +          - python3-yaml
> +          - python3-sphinx
> +          - python3-sphinx-rtd-theme
> +          - ninja-build
> +          - sparse
> +          - xfslibs-dev
> +        state: present
> +      when:
> +        - ansible_facts['distribution'] == 'Ubuntu'
> +
> +    - name: Install packages to build QEMU on Ubuntu 18.04/20.04 on non-s390x
> +      package:
> +        name:
> +          - libspice-server-dev
> +          - libxen-dev
> +        state: present
> +      when:
> +        - ansible_facts['distribution'] == 'Ubuntu'
> +        - ansible_facts['architecture'] != 's390x'
> +
> +    - name: Install basic packages to build QEMU on Ubuntu 18.04
> +      package:
> +        name:
> +        # Originally from tests/docker/dockerfiles/ubuntu1804.docker
> +          - clang
> +      when:
> +        - ansible_facts['distribution'] == 'Ubuntu'
> +        - ansible_facts['distribution_version'] == '18.04'
> +
> +    - name: Install basic packages to build QEMU on Ubuntu 20.04
> +      package:
> +        name:
> +        # Originally from tests/docker/dockerfiles/ubuntu2004.docker
> +          - clang-10
> +          - genisoimage
> +          - liblttng-ust-dev
> +          - libslirp-dev
> +          - netcat-openbsd
> +      when:
> +        - ansible_facts['distribution'] == 'Ubuntu'
> +        - ansible_facts['distribution_version'] == '20.04'
> diff --git a/scripts/ci/setup/inventory.template b/scripts/ci/setup/inventory.template
> new file mode 100644
> index 0000000000..2fbb50c4a8
> --- /dev/null
> +++ b/scripts/ci/setup/inventory.template
> @@ -0,0 +1 @@
> +localhost
Alex Bennée June 9, 2021, 1:31 p.m. UTC | #2
Cleber Rosa <crosa@redhat.com> writes:

> To run basic jobs on custom runners, the environment needs to be
> properly set up.  The most common requirement is having the right
> packages installed.
>
> The playbook introduced here covers the QEMU's project s390x and
> aarch64 machines.  At the time this is being proposed, those machines
> have already had this playbook applied to them.
>
> Signed-off-by: Cleber Rosa <crosa@redhat.com>
> ---
>  docs/devel/ci.rst                      | 30 ++++++++
>  scripts/ci/setup/build-environment.yml | 98 ++++++++++++++++++++++++++
>  scripts/ci/setup/inventory.template    |  1 +
>  3 files changed, 129 insertions(+)
>  create mode 100644 scripts/ci/setup/build-environment.yml
>  create mode 100644 scripts/ci/setup/inventory.template
>
> diff --git a/docs/devel/ci.rst b/docs/devel/ci.rst
> index 585b7bf4b8..35c6b5e269 100644
> --- a/docs/devel/ci.rst
> +++ b/docs/devel/ci.rst
> @@ -26,3 +26,33 @@ gitlab-runner, is called a "custom runner".
>  The GitLab CI jobs definition for the custom runners are located under::
>  
>    .gitlab-ci.d/custom-runners.yml
> +
> +Machine Setup Howto
> +-------------------
> +
> +For all Linux based systems, the setup can be mostly automated by the
> +execution of two Ansible playbooks.  Create an ``inventory`` file
> +under ``scripts/ci/setup``, such as this::
> +
> +  fully.qualified.domain
> +  other.machine.hostname
> +
> +You may need to set some variables in the inventory file itself.  One
> +very common need is to tell Ansible to use a Python 3 interpreter on
> +those hosts.  This would look like::
> +
> +  fully.qualified.domain ansible_python_interpreter=/usr/bin/python3
> +  other.machine.hostname ansible_python_interpreter=/usr/bin/python3
> +
> +Build environment
> +~~~~~~~~~~~~~~~~~
> +
> +The ``scripts/ci/setup/build-environment.yml`` Ansible playbook will
> +set up machines with the environment needed to perform builds and run
> +QEMU tests.  It covers a number of different Linux distributions and
> +FreeBSD.
> +
> +To run the playbook, execute::
> +
> +  cd scripts/ci/setup
> +  ansible-playbook -i inventory build-environment.yml

I tried this to re-update aarch64.ci.qemu.org and another ubuntu box I
have up and running as a VM and I got a failure when checking facts:

  14:26:26 [alex@zen:~/l/q/s/c/setup] review/custom-runners-v6|✚1…(+1/-1) + ansible-playbook -i inventory build-environment.yml

  PLAY [Installation of basic packages to build QEMU] *************************************************************************************************************************

  TASK [Gathering Facts] ******************************************************************************************************************************************************
  ok: [aarch64.ci.qemu.org]
  ok: [hackbox-ubuntu-2004]

  TASK [Update apt cache] *****************************************************************************************************************************************************
  fatal: [aarch64.ci.qemu.org]: FAILED! => {"msg": "The conditional check 'ansible_facts['distribution'] == 'Ubuntu'' failed. The error was: error while evaluating conditional (ansible_facts['distribution'] == 'Ubuntu'): 'dict object' has no attribute 'distribution'\n\nThe error appears to have been in '/home/alex/lsrc/qemu.git/scripts/ci/setup/build-environment.yml': line 5, column 7, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n  tasks:\n    - name: Update apt cache\n      ^ here\n"}
  fatal: [hackbox-ubuntu-2004]: FAILED! => {"msg": "The conditional check 'ansible_facts['distribution'] == 'Ubuntu'' failed. The error was: error while evaluating conditional (ansible_facts['distribution'] == 'Ubuntu'): 'dict object' has no attribute 'distribution'\n\nThe error appears to have been in '/home/alex/lsrc/qemu.git/scripts/ci/setup/build-environment.yml': line 5, column 7, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n  tasks:\n    - name: Update apt cache\n      ^ here\n"}
          to retry, use: --limit @/home/alex/lsrc/qemu.git/scripts/ci/setup/build-environment.retry

  PLAY RECAP ******************************************************************************************************************************************************************
  aarch64.ci.qemu.org        : ok=1    changed=0    unreachable=0    failed=1
  hackbox-ubuntu-2004        : ok=1    changed=0    unreachable=0    failed=1
Cleber Rosa June 9, 2021, 2:21 p.m. UTC | #3
On Wed, Jun 9, 2021 at 9:36 AM Alex Bennée <alex.bennee@linaro.org> wrote:

>
> Cleber Rosa <crosa@redhat.com> writes:
>
> > To run basic jobs on custom runners, the environment needs to be
> > properly set up.  The most common requirement is having the right
> > packages installed.
> >
> > The playbook introduced here covers the QEMU's project s390x and
> > aarch64 machines.  At the time this is being proposed, those machines
> > have already had this playbook applied to them.
> >
> > Signed-off-by: Cleber Rosa <crosa@redhat.com>
> > ---
> >  docs/devel/ci.rst                      | 30 ++++++++
> >  scripts/ci/setup/build-environment.yml | 98 ++++++++++++++++++++++++++
> >  scripts/ci/setup/inventory.template    |  1 +
> >  3 files changed, 129 insertions(+)
> >  create mode 100644 scripts/ci/setup/build-environment.yml
> >  create mode 100644 scripts/ci/setup/inventory.template
> >
> > diff --git a/docs/devel/ci.rst b/docs/devel/ci.rst
> > index 585b7bf4b8..35c6b5e269 100644
> > --- a/docs/devel/ci.rst
> > +++ b/docs/devel/ci.rst
> > @@ -26,3 +26,33 @@ gitlab-runner, is called a "custom runner".
> >  The GitLab CI jobs definition for the custom runners are located under::
> >
> >    .gitlab-ci.d/custom-runners.yml
> > +
> > +Machine Setup Howto
> > +-------------------
> > +
> > +For all Linux based systems, the setup can be mostly automated by the
> > +execution of two Ansible playbooks.  Create an ``inventory`` file
> > +under ``scripts/ci/setup``, such as this::
> > +
> > +  fully.qualified.domain
> > +  other.machine.hostname
> > +
> > +You may need to set some variables in the inventory file itself.  One
> > +very common need is to tell Ansible to use a Python 3 interpreter on
> > +those hosts.  This would look like::
> > +
> > +  fully.qualified.domain ansible_python_interpreter=/usr/bin/python3
> > +  other.machine.hostname ansible_python_interpreter=/usr/bin/python3
> > +
> > +Build environment
> > +~~~~~~~~~~~~~~~~~
> > +
> > +The ``scripts/ci/setup/build-environment.yml`` Ansible playbook will
> > +set up machines with the environment needed to perform builds and run
> > +QEMU tests.  It covers a number of different Linux distributions and
> > +FreeBSD.
> > +
> > +To run the playbook, execute::
> > +
> > +  cd scripts/ci/setup
> > +  ansible-playbook -i inventory build-environment.yml
>
> I tried this to re-update aarch64.ci.qemu.org and another ubuntu box I
> have up and running as a VM and I got a failure when checking facts:
>
>   14:26:26 [alex@zen:~/l/q/s/c/setup] review/custom-runners-v6|✚1…(+1/-1)
> + ansible-playbook -i inventory build-environment.yml
>
>   PLAY [Installation of basic packages to build QEMU]
> *************************************************************************************************************************
>
>   TASK [Gathering Facts]
> ******************************************************************************************************************************************************
>   ok: [aarch64.ci.qemu.org]
>   ok: [hackbox-ubuntu-2004]
>
>   TASK [Update apt cache]
> *****************************************************************************************************************************************************
>   fatal: [aarch64.ci.qemu.org]: FAILED! => {"msg": "The conditional check
> 'ansible_facts['distribution'] == 'Ubuntu'' failed. The error was: error
> while evaluating conditional (ansible_facts['distribution'] == 'Ubuntu'):
> 'dict object' has no attribute 'distribution'\n\nThe error appears to have
> been in '/home/alex/lsrc/qemu.git/scripts/ci/setup/build-environment.yml':
> line 5, column 7, but may\nbe elsewhere in the file depending on the exact
> syntax problem.\n\nThe offending line appears to be:\n\n  tasks:\n    -
> name: Update apt cache\n      ^ here\n"}
>   fatal: [hackbox-ubuntu-2004]: FAILED! => {"msg": "The conditional check
> 'ansible_facts['distribution'] == 'Ubuntu'' failed. The error was: error
> while evaluating conditional (ansible_facts['distribution'] == 'Ubuntu'):
> 'dict object' has no attribute 'distribution'\n\nThe error appears to have
> been in '/home/alex/lsrc/qemu.git/scripts/ci/setup/build-environment.yml':
> line 5, column 7, but may\nbe elsewhere in the file depending on the exact
> syntax problem.\n\nThe offending line appears to be:\n\n  tasks:\n    -
> name: Update apt cache\n      ^ here\n"}
>           to retry, use: --limit
> @/home/alex/lsrc/qemu.git/scripts/ci/setup/build-environment.retry
>
>   PLAY RECAP
> ******************************************************************************************************************************************************************
>   aarch64.ci.qemu.org        : ok=1    changed=0    unreachable=0
> failed=1
>   hackbox-ubuntu-2004        : ok=1    changed=0    unreachable=0
> failed=1
>
>
>
Hi Alex,

Thanks for checking this version out.  It looks like this is similar to
what happened to you during v5 and hackmox-ubuntu-2004.  Because I had no
issues running the playbook against aarch64.ci.qemu.org, I am now betting
that this is an issue with the ansible installation on the "controller"
machine, that is, the one that drives the playbook execution (the "zen"
host, according to your output).

About the error, the syntax itself is correct[1], but I bet there may be
differences between ansible versions.  Could you please share the output of
"ansible --version" on that machine?

Thanks again,
- Cleber.

[1] -
https://docs.ansible.com/ansible/latest/user_guide/playbooks_conditionals.html#ansible-facts-distribution


> --
> Alex Bennée
>
>
Alex Bennée June 9, 2021, 3:26 p.m. UTC | #4
Cleber Rosa Junior <crosa@redhat.com> writes:

> On Wed, Jun 9, 2021 at 9:36 AM Alex Bennée <alex.bennee@linaro.org> wrote:
>
>  Cleber Rosa <crosa@redhat.com> writes:
>
>  > To run basic jobs on custom runners, the environment needs to be
>  > properly set up.  The most common requirement is having the right
>  > packages installed.
>  >
>  > The playbook introduced here covers the QEMU's project s390x and
>  > aarch64 machines.  At the time this is being proposed, those machines
>  > have already had this playbook applied to them.
>  >
>  > Signed-off-by: Cleber Rosa <crosa@redhat.com>
>  > ---
>  >  docs/devel/ci.rst                      | 30 ++++++++
>  >  scripts/ci/setup/build-environment.yml | 98 ++++++++++++++++++++++++++
>  >  scripts/ci/setup/inventory.template    |  1 +
>  >  3 files changed, 129 insertions(+)
>  >  create mode 100644 scripts/ci/setup/build-environment.yml
>  >  create mode 100644 scripts/ci/setup/inventory.template
>  >
>  > diff --git a/docs/devel/ci.rst b/docs/devel/ci.rst
>  > index 585b7bf4b8..35c6b5e269 100644
>  > --- a/docs/devel/ci.rst
>  > +++ b/docs/devel/ci.rst
>  > @@ -26,3 +26,33 @@ gitlab-runner, is called a "custom runner".
>  >  The GitLab CI jobs definition for the custom runners are located under::
>  >  
>  >    .gitlab-ci.d/custom-runners.yml
>  > +
>  > +Machine Setup Howto
>  > +-------------------
>  > +
>  > +For all Linux based systems, the setup can be mostly automated by the
>  > +execution of two Ansible playbooks.  Create an ``inventory`` file
>  > +under ``scripts/ci/setup``, such as this::
>  > +
>  > +  fully.qualified.domain
>  > +  other.machine.hostname
>  > +
>  > +You may need to set some variables in the inventory file itself.  One
>  > +very common need is to tell Ansible to use a Python 3 interpreter on
>  > +those hosts.  This would look like::
>  > +
>  > +  fully.qualified.domain ansible_python_interpreter=/usr/bin/python3
>  > +  other.machine.hostname ansible_python_interpreter=/usr/bin/python3
>  > +
>  > +Build environment
>  > +~~~~~~~~~~~~~~~~~
>  > +
>  > +The ``scripts/ci/setup/build-environment.yml`` Ansible playbook will
>  > +set up machines with the environment needed to perform builds and run
>  > +QEMU tests.  It covers a number of different Linux distributions and
>  > +FreeBSD.
>  > +
>  > +To run the playbook, execute::
>  > +
>  > +  cd scripts/ci/setup
>  > +  ansible-playbook -i inventory build-environment.yml
>
>  I tried this to re-update aarch64.ci.qemu.org and another ubuntu box I
>  have up and running as a VM and I got a failure when checking facts:
>
>    14:26:26 [alex@zen:~/l/q/s/c/setup] review/custom-runners-v6|✚1…(+1/-1) + ansible-playbook -i inventory build-environment.yml
>
>    PLAY [Installation of basic packages to build QEMU]
>  *************************************************************************************************************************
>
>    TASK [Gathering Facts]
>  ******************************************************************************************************************************************************
>  
>    ok: [aarch64.ci.qemu.org]
>    ok: [hackbox-ubuntu-2004]
>
>    TASK [Update apt cache]
>  *****************************************************************************************************************************************************
>  
>    fatal: [aarch64.ci.qemu.org]: FAILED! => {"msg": "The conditional check 'ansible_facts['distribution'] == 'Ubuntu'' failed. The error
>  was: error while evaluating conditional (ansible_facts['distribution'] == 'Ubuntu'): 'dict object' has no attribute 'distribution'\n\nThe
>  error appears to have been in '/home/alex/lsrc/qemu.git/scripts/ci/setup/build-environment.yml': line 5, column 7, but may\nbe
>  elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n  tasks:\n    - name: Update apt
>  cache\n      ^ here\n"}
>    fatal: [hackbox-ubuntu-2004]: FAILED! => {"msg": "The conditional check 'ansible_facts['distribution'] == 'Ubuntu'' failed. The error
>  was: error while evaluating conditional (ansible_facts['distribution'] == 'Ubuntu'): 'dict object' has no attribute 'distribution'\n\nThe
>  error appears to have been in '/home/alex/lsrc/qemu.git/scripts/ci/setup/build-environment.yml': line 5, column 7, but may\nbe
>  elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n  tasks:\n    - name: Update apt
>  cache\n      ^ here\n"}
>            to retry, use: --limit @/home/alex/lsrc/qemu.git/scripts/ci/setup/build-environment.retry
>
>    PLAY RECAP
>  ******************************************************************************************************************************************************************
>  
>    aarch64.ci.qemu.org        : ok=1    changed=0    unreachable=0    failed=1
>    hackbox-ubuntu-2004        : ok=1    changed=0    unreachable=0    failed=1
>
> Hi Alex,
>
> Thanks for checking this version out.  It looks like this is similar to what happened to you during v5 and hackmox-ubuntu-2004.  Because I
> had no issues running the playbook against aarch64.ci.qemu.org, I am now betting that this is an issue with the ansible installation on the
> "controller" machine, that is, the one that drives the playbook execution (the "zen" host, according to your output).
>
> About the error, the syntax itself is correct[1], but I bet there may be differences between ansible versions.  Could you please share the
> output of "ansible --version" on that machine?

15:41:21 [alex@zen:~/l/q/s/c/setup] review/custom-runners-v6|✚1…(+1/-1) 4 + ansible --version
ansible 2.7.7
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/alex/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3/dist-packages/ansible
  executable location = /usr/bin/ansible
  python version = 3.7.3 (default, Jan 22 2021, 20:04:44) [GCC 8.3.0]

My machine is Debian stable (aka Buster)

>
> Thanks again,
> - Cleber.
>
> [1] - https://docs.ansible.com/ansible/latest/user_guide/playbooks_conditionals.html#ansible-facts-distribution
>  
>  -- 
>  Alex Bennée
Willian Rampazzo June 9, 2021, 4:13 p.m. UTC | #5
On Tue, Jun 8, 2021 at 3:48 PM Wainer dos Santos Moschetta
<wainersm@redhat.com> wrote:
>
> Hi,
>
> On 6/8/21 12:14 AM, Cleber Rosa wrote:
> > To run basic jobs on custom runners, the environment needs to be
> > properly set up.  The most common requirement is having the right
> > packages installed.
> >
> > The playbook introduced here covers the QEMU's project s390x and
> > aarch64 machines.  At the time this is being proposed, those machines
> > have already had this playbook applied to them.
> >
> > Signed-off-by: Cleber Rosa <crosa@redhat.com>
> > ---
> >   docs/devel/ci.rst                      | 30 ++++++++
> >   scripts/ci/setup/build-environment.yml | 98 ++++++++++++++++++++++++++
> >   scripts/ci/setup/inventory.template    |  1 +
> >   3 files changed, 129 insertions(+)
> >   create mode 100644 scripts/ci/setup/build-environment.yml
> >   create mode 100644 scripts/ci/setup/inventory.template
> >
> > diff --git a/docs/devel/ci.rst b/docs/devel/ci.rst
> > index 585b7bf4b8..35c6b5e269 100644
> > --- a/docs/devel/ci.rst
> > +++ b/docs/devel/ci.rst
> > @@ -26,3 +26,33 @@ gitlab-runner, is called a "custom runner".
> >   The GitLab CI jobs definition for the custom runners are located under::
> >
> >     .gitlab-ci.d/custom-runners.yml
> > +
> > +Machine Setup Howto
> > +-------------------
> > +
> > +For all Linux based systems, the setup can be mostly automated by the
> > +execution of two Ansible playbooks.  Create an ``inventory`` file
> > +under ``scripts/ci/setup``, such as this::
> Missing to mention the template file.
> > +
> > +  fully.qualified.domain
> > +  other.machine.hostname
> > +
> > +You may need to set some variables in the inventory file itself.  One
> > +very common need is to tell Ansible to use a Python 3 interpreter on
> > +those hosts.  This would look like::
> > +
> > +  fully.qualified.domain ansible_python_interpreter=/usr/bin/python3
> > +  other.machine.hostname ansible_python_interpreter=/usr/bin/python3
> > +
> > +Build environment
> > +~~~~~~~~~~~~~~~~~
> > +
> > +The ``scripts/ci/setup/build-environment.yml`` Ansible playbook will
> > +set up machines with the environment needed to perform builds and run
> > +QEMU tests.  It covers a number of different Linux distributions and
> > +FreeBSD.
> > +
> > +To run the playbook, execute::
> > +
> > +  cd scripts/ci/setup
> > +  ansible-playbook -i inventory build-environment.yml
> > diff --git a/scripts/ci/setup/build-environment.yml b/scripts/ci/setup/build-environment.yml
> > new file mode 100644
> > index 0000000000..664f2f0519
> > --- /dev/null
> > +++ b/scripts/ci/setup/build-environment.yml
> > @@ -0,0 +1,98 @@
> > +---
> > +- name: Installation of basic packages to build QEMU
> > +  hosts: all
>
> You will need to "become: yes" if the login user is not privileged, right?
>
> Or mention on the documentation how the user should configure the
> connection for privileged login.

As this will vary from system to system, I think it is worth
mentioning in the documentation it can be configured in the inventory
file, adding the variable ansible_become=yes and
ansible_become_password= if password is needed to sudo.
Cleber Rosa June 9, 2021, 5:09 p.m. UTC | #6
On Wed, Jun 9, 2021 at 11:26 AM Alex Bennée <alex.bennee@linaro.org> wrote:

>
> Cleber Rosa Junior <crosa@redhat.com> writes:
>
> > On Wed, Jun 9, 2021 at 9:36 AM Alex Bennée <alex.bennee@linaro.org>
> wrote:
> >
> >  Cleber Rosa <crosa@redhat.com> writes:
> >
> >  > To run basic jobs on custom runners, the environment needs to be
> >  > properly set up.  The most common requirement is having the right
> >  > packages installed.
> >  >
> >  > The playbook introduced here covers the QEMU's project s390x and
> >  > aarch64 machines.  At the time this is being proposed, those machines
> >  > have already had this playbook applied to them.
> >  >
> >  > Signed-off-by: Cleber Rosa <crosa@redhat.com>
> >  > ---
> >  >  docs/devel/ci.rst                      | 30 ++++++++
> >  >  scripts/ci/setup/build-environment.yml | 98
> ++++++++++++++++++++++++++
> >  >  scripts/ci/setup/inventory.template    |  1 +
> >  >  3 files changed, 129 insertions(+)
> >  >  create mode 100644 scripts/ci/setup/build-environment.yml
> >  >  create mode 100644 scripts/ci/setup/inventory.template
> >  >
> >  > diff --git a/docs/devel/ci.rst b/docs/devel/ci.rst
> >  > index 585b7bf4b8..35c6b5e269 100644
> >  > --- a/docs/devel/ci.rst
> >  > +++ b/docs/devel/ci.rst
> >  > @@ -26,3 +26,33 @@ gitlab-runner, is called a "custom runner".
> >  >  The GitLab CI jobs definition for the custom runners are located
> under::
> >  >
> >  >    .gitlab-ci.d/custom-runners.yml
> >  > +
> >  > +Machine Setup Howto
> >  > +-------------------
> >  > +
> >  > +For all Linux based systems, the setup can be mostly automated by the
> >  > +execution of two Ansible playbooks.  Create an ``inventory`` file
> >  > +under ``scripts/ci/setup``, such as this::
> >  > +
> >  > +  fully.qualified.domain
> >  > +  other.machine.hostname
> >  > +
> >  > +You may need to set some variables in the inventory file itself.  One
> >  > +very common need is to tell Ansible to use a Python 3 interpreter on
> >  > +those hosts.  This would look like::
> >  > +
> >  > +  fully.qualified.domain ansible_python_interpreter=/usr/bin/python3
> >  > +  other.machine.hostname ansible_python_interpreter=/usr/bin/python3
> >  > +
> >  > +Build environment
> >  > +~~~~~~~~~~~~~~~~~
> >  > +
> >  > +The ``scripts/ci/setup/build-environment.yml`` Ansible playbook will
> >  > +set up machines with the environment needed to perform builds and run
> >  > +QEMU tests.  It covers a number of different Linux distributions and
> >  > +FreeBSD.
> >  > +
> >  > +To run the playbook, execute::
> >  > +
> >  > +  cd scripts/ci/setup
> >  > +  ansible-playbook -i inventory build-environment.yml
> >
> >  I tried this to re-update aarch64.ci.qemu.org and another ubuntu box I
> >  have up and running as a VM and I got a failure when checking facts:
> >
> >    14:26:26 [alex@zen:~/l/q/s/c/setup]
> review/custom-runners-v6|✚1…(+1/-1) + ansible-playbook -i inventory
> build-environment.yml
> >
> >    PLAY [Installation of basic packages to build QEMU]
> >
> *************************************************************************************************************************
> >
> >    TASK [Gathering Facts]
> >
> ******************************************************************************************************************************************************
> >
> >    ok: [aarch64.ci.qemu.org]
> >    ok: [hackbox-ubuntu-2004]
> >
> >    TASK [Update apt cache]
> >
> *****************************************************************************************************************************************************
> >
> >    fatal: [aarch64.ci.qemu.org]: FAILED! => {"msg": "The conditional
> check 'ansible_facts['distribution'] == 'Ubuntu'' failed. The error
> >  was: error while evaluating conditional (ansible_facts['distribution']
> == 'Ubuntu'): 'dict object' has no attribute 'distribution'\n\nThe
> >  error appears to have been in
> '/home/alex/lsrc/qemu.git/scripts/ci/setup/build-environment.yml': line 5,
> column 7, but may\nbe
> >  elsewhere in the file depending on the exact syntax problem.\n\nThe
> offending line appears to be:\n\n  tasks:\n    - name: Update apt
> >  cache\n      ^ here\n"}
> >    fatal: [hackbox-ubuntu-2004]: FAILED! => {"msg": "The conditional
> check 'ansible_facts['distribution'] == 'Ubuntu'' failed. The error
> >  was: error while evaluating conditional (ansible_facts['distribution']
> == 'Ubuntu'): 'dict object' has no attribute 'distribution'\n\nThe
> >  error appears to have been in
> '/home/alex/lsrc/qemu.git/scripts/ci/setup/build-environment.yml': line 5,
> column 7, but may\nbe
> >  elsewhere in the file depending on the exact syntax problem.\n\nThe
> offending line appears to be:\n\n  tasks:\n    - name: Update apt
> >  cache\n      ^ here\n"}
> >            to retry, use: --limit
> @/home/alex/lsrc/qemu.git/scripts/ci/setup/build-environment.retry
> >
> >    PLAY RECAP
> >
> ******************************************************************************************************************************************************************
> >
> >    aarch64.ci.qemu.org        : ok=1    changed=0    unreachable=0
> failed=1
> >    hackbox-ubuntu-2004        : ok=1    changed=0    unreachable=0
> failed=1
> >
> > Hi Alex,
> >
> > Thanks for checking this version out.  It looks like this is similar to
> what happened to you during v5 and hackmox-ubuntu-2004.  Because I
> > had no issues running the playbook against aarch64.ci.qemu.org, I am
> now betting that this is an issue with the ansible installation on the
> > "controller" machine, that is, the one that drives the playbook
> execution (the "zen" host, according to your output).
> >
> > About the error, the syntax itself is correct[1], but I bet there may be
> differences between ansible versions.  Could you please share the
> > output of "ansible --version" on that machine?
>
> 15:41:21 [alex@zen:~/l/q/s/c/setup] review/custom-runners-v6|✚1…(+1/-1) 4
> + ansible --version
> ansible 2.7.7
>   config file = /etc/ansible/ansible.cfg
>   configured module search path = ['/home/alex/.ansible/plugins/modules',
> '/usr/share/ansible/plugins/modules']
>   ansible python module location = /usr/lib/python3/dist-packages/ansible
>   executable location = /usr/bin/ansible
>   python version = 3.7.3 (default, Jan 22 2021, 20:04:44) [GCC 8.3.0]
>
> My machine is Debian stable (aka Buster)
>
>
Hi Alex,

I found out, the hard way, that one will need ansible 2.8.x.  I'll make a
note about that in the documentation. Long version:

I was able to replicate this on Debian stable, using the exact same
versions as you did.  Then I tried the latest ansible 2.7.18 (the latest in
the 2.7.x series), installed with "pip install ansible==2.7.18 --user".
Still, the exact same issue.

Then, still on Debian stable, I tried 2.8.20 (installed with "pip install
ansible==2.8.20 --user"), and the playbook execution completed successfully.

I went through the 2.7x. and 2.8.x changelogs, and I could not spot one
clear entry about the change in behavior though.

Thanks,
- Cleber.


> >
> > Thanks again,
> > - Cleber.
> >
> > [1] -
> https://docs.ansible.com/ansible/latest/user_guide/playbooks_conditionals.html#ansible-facts-distribution
> >
> >  --
> >  Alex Bennée
>
>
> --
> Alex Bennée
>
>
Willian Rampazzo June 9, 2021, 5:16 p.m. UTC | #7
On Tue, Jun 8, 2021 at 12:14 AM Cleber Rosa <crosa@redhat.com> wrote:
>
> To run basic jobs on custom runners, the environment needs to be
> properly set up.  The most common requirement is having the right
> packages installed.
>
> The playbook introduced here covers the QEMU's project s390x and
> aarch64 machines.  At the time this is being proposed, those machines
> have already had this playbook applied to them.
>
> Signed-off-by: Cleber Rosa <crosa@redhat.com>
> ---
>  docs/devel/ci.rst                      | 30 ++++++++
>  scripts/ci/setup/build-environment.yml | 98 ++++++++++++++++++++++++++
>  scripts/ci/setup/inventory.template    |  1 +
>  3 files changed, 129 insertions(+)
>  create mode 100644 scripts/ci/setup/build-environment.yml
>  create mode 100644 scripts/ci/setup/inventory.template
>
> diff --git a/docs/devel/ci.rst b/docs/devel/ci.rst
> index 585b7bf4b8..35c6b5e269 100644
> --- a/docs/devel/ci.rst
> +++ b/docs/devel/ci.rst
> @@ -26,3 +26,33 @@ gitlab-runner, is called a "custom runner".
>  The GitLab CI jobs definition for the custom runners are located under::
>
>    .gitlab-ci.d/custom-runners.yml
> +
> +Machine Setup Howto
> +-------------------
> +
> +For all Linux based systems, the setup can be mostly automated by the
> +execution of two Ansible playbooks.  Create an ``inventory`` file
> +under ``scripts/ci/setup``, such as this::
> +
> +  fully.qualified.domain
> +  other.machine.hostname
> +
> +You may need to set some variables in the inventory file itself.  One
> +very common need is to tell Ansible to use a Python 3 interpreter on
> +those hosts.  This would look like::
> +
> +  fully.qualified.domain ansible_python_interpreter=/usr/bin/python3
> +  other.machine.hostname ansible_python_interpreter=/usr/bin/python3
> +

As I mentioned to Wainer, my suggestion is to include a comment about
ansible_become=yes and
ansible_become_password= variables as some systems may need it.

> +Build environment
> +~~~~~~~~~~~~~~~~~
> +
> +The ``scripts/ci/setup/build-environment.yml`` Ansible playbook will
> +set up machines with the environment needed to perform builds and run
> +QEMU tests.  It covers a number of different Linux distributions and
> +FreeBSD.
> +
> +To run the playbook, execute::
> +
> +  cd scripts/ci/setup
> +  ansible-playbook -i inventory build-environment.yml
> diff --git a/scripts/ci/setup/build-environment.yml b/scripts/ci/setup/build-environment.yml
> new file mode 100644
> index 0000000000..664f2f0519
> --- /dev/null
> +++ b/scripts/ci/setup/build-environment.yml
> @@ -0,0 +1,98 @@
> +---
> +- name: Installation of basic packages to build QEMU
> +  hosts: all
> +  tasks:
> +    - name: Update apt cache
> +      apt:
> +        update_cache: yes

On a freshly installed Ubuntu 20.04, the script failed for me with
dependency messages on the apt side. After I updated the packages on
the system, the playbook worked without problems.

So, my suggestion is to add the "update = yes" here, or add a note in
the documentation asking the user to update the system before running
the playbook.

Except for the above comment and Wainer's comments, it looks good to
me. With these changes:

Reviewed-by: Willian Rampazzo <willianr@redhat.com>
Tested-by: Willian Rampazzo <willianr@redhat.com>
Erik Skultety June 10, 2021, 8:13 a.m. UTC | #8
...
> On a freshly installed Ubuntu 20.04, the script failed for me with
> dependency messages on the apt side. After I updated the packages on
> the system, the playbook worked without problems.
> 
> So, my suggestion is to add the "update = yes" here, or add a note in
> the documentation asking the user to update the system before running
> the playbook.

I'd advocate for always updating the system automatically rather than putting
it into the documentation and relying on users actually doing it.

Erik
Alex Bennée June 11, 2021, 10:40 a.m. UTC | #9
Cleber Rosa Junior <crosa@redhat.com> writes:

> On Wed, Jun 9, 2021 at 11:26 AM Alex Bennée <alex.bennee@linaro.org> wrote:
>
>  Cleber Rosa Junior <crosa@redhat.com> writes:
>
>  > On Wed, Jun 9, 2021 at 9:36 AM Alex Bennée <alex.bennee@linaro.org> wrote:
>  >
>  >  Cleber Rosa <crosa@redhat.com> writes:
>  >
>  >  > To run basic jobs on custom runners, the environment needs to be
>  >  > properly set up.  The most common requirement is having the right
>  >  > packages installed.
>  >  >
>  >  > The playbook introduced here covers the QEMU's project s390x and
>  >  > aarch64 machines.  At the time this is being proposed, those machines
>  >  > have already had this playbook applied to them.
>  >  >
>  >  > Signed-off-by: Cleber Rosa <crosa@redhat.com>
>  >  > ---
>  >  >  docs/devel/ci.rst                      | 30 ++++++++
>  >  >  scripts/ci/setup/build-environment.yml | 98 ++++++++++++++++++++++++++
>  >  >  scripts/ci/setup/inventory.template    |  1 +
>  >  >  3 files changed, 129 insertions(+)
>  >  >  create mode 100644 scripts/ci/setup/build-environment.yml
>  >  >  create mode 100644 scripts/ci/setup/inventory.template
>  >  >
>  >  > diff --git a/docs/devel/ci.rst b/docs/devel/ci.rst
>  >  > index 585b7bf4b8..35c6b5e269 100644
>  >  > --- a/docs/devel/ci.rst
>  >  > +++ b/docs/devel/ci.rst
>  >  > @@ -26,3 +26,33 @@ gitlab-runner, is called a "custom runner".
>  >  >  The GitLab CI jobs definition for the custom runners are located under::
>  >  >  
>  >  >    .gitlab-ci.d/custom-runners.yml
>  >  > +
>  >  > +Machine Setup Howto
>  >  > +-------------------
>  >  > +
>  >  > +For all Linux based systems, the setup can be mostly automated by the
>  >  > +execution of two Ansible playbooks.  Create an ``inventory`` file
>  >  > +under ``scripts/ci/setup``, such as this::
>  >  > +
>  >  > +  fully.qualified.domain
>  >  > +  other.machine.hostname
>  >  > +
>  >  > +You may need to set some variables in the inventory file itself.  One
>  >  > +very common need is to tell Ansible to use a Python 3 interpreter on
>  >  > +those hosts.  This would look like::
>  >  > +
>  >  > +  fully.qualified.domain ansible_python_interpreter=/usr/bin/python3
>  >  > +  other.machine.hostname ansible_python_interpreter=/usr/bin/python3
>  >  > +
>  >  > +Build environment
>  >  > +~~~~~~~~~~~~~~~~~
>  >  > +
>  >  > +The ``scripts/ci/setup/build-environment.yml`` Ansible playbook will
>  >  > +set up machines with the environment needed to perform builds and run
>  >  > +QEMU tests.  It covers a number of different Linux distributions and
>  >  > +FreeBSD.
>  >  > +
>  >  > +To run the playbook, execute::
>  >  > +
>  >  > +  cd scripts/ci/setup
>  >  > +  ansible-playbook -i inventory build-environment.yml
>  >
>  >  I tried this to re-update aarch64.ci.qemu.org and another ubuntu box I
>  >  have up and running as a VM and I got a failure when checking facts:
>  >
>  >    14:26:26 [alex@zen:~/l/q/s/c/setup] review/custom-runners-v6|✚1…(+1/-1) + ansible-playbook -i inventory
>  build-environment.yml
>  >
>  >    PLAY [Installation of basic packages to build QEMU]
>  >  *************************************************************************************************************************
>  >
>  >    TASK [Gathering Facts]
>  > 
>  ******************************************************************************************************************************************************
>  
>  >  
>  >    ok: [aarch64.ci.qemu.org]
>  >    ok: [hackbox-ubuntu-2004]
>  >
>  >    TASK [Update apt cache]
>  > 
>  *****************************************************************************************************************************************************
>  
>  >  
>  >    fatal: [aarch64.ci.qemu.org]: FAILED! => {"msg": "The conditional check 'ansible_facts['distribution'] == 'Ubuntu'' failed. The
>  error
>  >  was: error while evaluating conditional (ansible_facts['distribution'] == 'Ubuntu'): 'dict object' has no attribute 'distribution'\n\nThe
>  >  error appears to have been in '/home/alex/lsrc/qemu.git/scripts/ci/setup/build-environment.yml': line 5, column 7, but may\nbe
>  >  elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n  tasks:\n    - name: Update
>  apt
>  >  cache\n      ^ here\n"}
>  >    fatal: [hackbox-ubuntu-2004]: FAILED! => {"msg": "The conditional check 'ansible_facts['distribution'] == 'Ubuntu'' failed. The
>  error
>  >  was: error while evaluating conditional (ansible_facts['distribution'] == 'Ubuntu'): 'dict object' has no attribute 'distribution'\n\nThe
>  >  error appears to have been in '/home/alex/lsrc/qemu.git/scripts/ci/setup/build-environment.yml': line 5, column 7, but may\nbe
>  >  elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n  tasks:\n    - name: Update
>  apt
>  >  cache\n      ^ here\n"}
>  >            to retry, use: --limit @/home/alex/lsrc/qemu.git/scripts/ci/setup/build-environment.retry
>  >
>  >    PLAY RECAP
>  > 
>  ******************************************************************************************************************************************************************
>  
>  >  
>  >    aarch64.ci.qemu.org        : ok=1    changed=0    unreachable=0    failed=1
>  >    hackbox-ubuntu-2004        : ok=1    changed=0    unreachable=0    failed=1
>  >
>  > Hi Alex,
>  >
>  > Thanks for checking this version out.  It looks like this is similar to what happened to you during v5 and hackmox-ubuntu-2004. 
>  Because I
>  > had no issues running the playbook against aarch64.ci.qemu.org, I am now betting that this is an issue with the ansible installation
>  on the
>  > "controller" machine, that is, the one that drives the playbook execution (the "zen" host, according to your output).
>  >
>  > About the error, the syntax itself is correct[1], but I bet there may be differences between ansible versions.  Could you please share
>  the
>  > output of "ansible --version" on that machine?
>
>  15:41:21 [alex@zen:~/l/q/s/c/setup] review/custom-runners-v6|✚1…(+1/-1) 4 + ansible --version
>  ansible 2.7.7
>    config file = /etc/ansible/ansible.cfg
>    configured module search path = ['/home/alex/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
>    ansible python module location = /usr/lib/python3/dist-packages/ansible
>    executable location = /usr/bin/ansible
>    python version = 3.7.3 (default, Jan 22 2021, 20:04:44) [GCC 8.3.0]
>
>  My machine is Debian stable (aka Buster)
>
> Hi Alex,
>
> I found out, the hard way, that one will need ansible 2.8.x.  I'll
> make a note about that in the documentation. Long version:

OK - yes please and I'll test with a local installed version. Is it
possible for the playbook to error out with a useful warning if the
version of ansible isn't new enough?

>
> I was able to replicate this on Debian stable, using the exact same versions as you did.  Then I tried the latest ansible 2.7.18 (the latest in
> the 2.7.x series), installed with "pip install ansible==2.7.18 --user".  Still, the exact same issue.
>
> Then, still on Debian stable, I tried 2.8.20 (installed with "pip install ansible==2.8.20 --user"), and the playbook execution completed
> successfully.
>
> I went through the 2.7x. and 2.8.x changelogs, and I could not spot one clear entry about the change in behavior though.
>
> Thanks,
> - Cleber.
>  
>  >
>  > Thanks again,
>  > - Cleber.
>  >
>  > [1] - https://docs.ansible.com/ansible/latest/user_guide/playbooks_conditionals.html#ansible-facts-distribution
>  >  
>  >  -- 
>  >  Alex Bennée
>
>  -- 
>  Alex Bennée
Cleber Rosa June 28, 2021, 11:07 p.m. UTC | #10
On 6/11/21 6:40 AM, Alex Bennée wrote:

> Cleber Rosa Junior <crosa@redhat.com> writes:
>
>> On Wed, Jun 9, 2021 at 11:26 AM Alex Bennée <alex.bennee@linaro.org> wrote:
>>
>>   Cleber Rosa Junior <crosa@redhat.com> writes:
>>
>>   > On Wed, Jun 9, 2021 at 9:36 AM Alex Bennée <alex.bennee@linaro.org> wrote:
>>   >
>>   >  Cleber Rosa <crosa@redhat.com> writes:
>>   >
>>   >  > To run basic jobs on custom runners, the environment needs to be
>>   >  > properly set up.  The most common requirement is having the right
>>   >  > packages installed.
>>   >  >
>>   >  > The playbook introduced here covers the QEMU's project s390x and
>>   >  > aarch64 machines.  At the time this is being proposed, those machines
>>   >  > have already had this playbook applied to them.
>>   >  >
>>   >  > Signed-off-by: Cleber Rosa <crosa@redhat.com>
>>   >  > ---
>>   >  >  docs/devel/ci.rst                      | 30 ++++++++
>>   >  >  scripts/ci/setup/build-environment.yml | 98 ++++++++++++++++++++++++++
>>   >  >  scripts/ci/setup/inventory.template    |  1 +
>>   >  >  3 files changed, 129 insertions(+)
>>   >  >  create mode 100644 scripts/ci/setup/build-environment.yml
>>   >  >  create mode 100644 scripts/ci/setup/inventory.template
>>   >  >
>>   >  > diff --git a/docs/devel/ci.rst b/docs/devel/ci.rst
>>   >  > index 585b7bf4b8..35c6b5e269 100644
>>   >  > --- a/docs/devel/ci.rst
>>   >  > +++ b/docs/devel/ci.rst
>>   >  > @@ -26,3 +26,33 @@ gitlab-runner, is called a "custom runner".
>>   >  >  The GitLab CI jobs definition for the custom runners are located under::
>>   >  >
>>   >  >    .gitlab-ci.d/custom-runners.yml
>>   >  > +
>>   >  > +Machine Setup Howto
>>   >  > +-------------------
>>   >  > +
>>   >  > +For all Linux based systems, the setup can be mostly automated by the
>>   >  > +execution of two Ansible playbooks.  Create an ``inventory`` file
>>   >  > +under ``scripts/ci/setup``, such as this::
>>   >  > +
>>   >  > +  fully.qualified.domain
>>   >  > +  other.machine.hostname
>>   >  > +
>>   >  > +You may need to set some variables in the inventory file itself.  One
>>   >  > +very common need is to tell Ansible to use a Python 3 interpreter on
>>   >  > +those hosts.  This would look like::
>>   >  > +
>>   >  > +  fully.qualified.domain ansible_python_interpreter=/usr/bin/python3
>>   >  > +  other.machine.hostname ansible_python_interpreter=/usr/bin/python3
>>   >  > +
>>   >  > +Build environment
>>   >  > +~~~~~~~~~~~~~~~~~
>>   >  > +
>>   >  > +The ``scripts/ci/setup/build-environment.yml`` Ansible playbook will
>>   >  > +set up machines with the environment needed to perform builds and run
>>   >  > +QEMU tests.  It covers a number of different Linux distributions and
>>   >  > +FreeBSD.
>>   >  > +
>>   >  > +To run the playbook, execute::
>>   >  > +
>>   >  > +  cd scripts/ci/setup
>>   >  > +  ansible-playbook -i inventory build-environment.yml
>>   >
>>   >  I tried this to re-update aarch64.ci.qemu.org and another ubuntu box I
>>   >  have up and running as a VM and I got a failure when checking facts:
>>   >
>>   >    14:26:26 [alex@zen:~/l/q/s/c/setup] review/custom-runners-v6|✚1…(+1/-1) + ansible-playbook -i inventory
>>   build-environment.yml
>>   >
>>   >    PLAY [Installation of basic packages to build QEMU]
>>   >  *************************************************************************************************************************
>>   >
>>   >    TASK [Gathering Facts]
>>   >
>>   ******************************************************************************************************************************************************
>>   
>>   >
>>   >    ok: [aarch64.ci.qemu.org]
>>   >    ok: [hackbox-ubuntu-2004]
>>   >
>>   >    TASK [Update apt cache]
>>   >
>>   *****************************************************************************************************************************************************
>>   
>>   >
>>   >    fatal: [aarch64.ci.qemu.org]: FAILED! => {"msg": "The conditional check 'ansible_facts['distribution'] == 'Ubuntu'' failed. The
>>   error
>>   >  was: error while evaluating conditional (ansible_facts['distribution'] == 'Ubuntu'): 'dict object' has no attribute 'distribution'\n\nThe
>>   >  error appears to have been in '/home/alex/lsrc/qemu.git/scripts/ci/setup/build-environment.yml': line 5, column 7, but may\nbe
>>   >  elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n  tasks:\n    - name: Update
>>   apt
>>   >  cache\n      ^ here\n"}
>>   >    fatal: [hackbox-ubuntu-2004]: FAILED! => {"msg": "The conditional check 'ansible_facts['distribution'] == 'Ubuntu'' failed. The
>>   error
>>   >  was: error while evaluating conditional (ansible_facts['distribution'] == 'Ubuntu'): 'dict object' has no attribute 'distribution'\n\nThe
>>   >  error appears to have been in '/home/alex/lsrc/qemu.git/scripts/ci/setup/build-environment.yml': line 5, column 7, but may\nbe
>>   >  elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n  tasks:\n    - name: Update
>>   apt
>>   >  cache\n      ^ here\n"}
>>   >            to retry, use: --limit @/home/alex/lsrc/qemu.git/scripts/ci/setup/build-environment.retry
>>   >
>>   >    PLAY RECAP
>>   >
>>   ******************************************************************************************************************************************************************
>>   
>>   >
>>   >    aarch64.ci.qemu.org        : ok=1    changed=0    unreachable=0    failed=1
>>   >    hackbox-ubuntu-2004        : ok=1    changed=0    unreachable=0    failed=1
>>   >
>>   > Hi Alex,
>>   >
>>   > Thanks for checking this version out.  It looks like this is similar to what happened to you during v5 and hackmox-ubuntu-2004.
>>   Because I
>>   > had no issues running the playbook against aarch64.ci.qemu.org, I am now betting that this is an issue with the ansible installation
>>   on the
>>   > "controller" machine, that is, the one that drives the playbook execution (the "zen" host, according to your output).
>>   >
>>   > About the error, the syntax itself is correct[1], but I bet there may be differences between ansible versions.  Could you please share
>>   the
>>   > output of "ansible --version" on that machine?
>>
>>   15:41:21 [alex@zen:~/l/q/s/c/setup] review/custom-runners-v6|✚1…(+1/-1) 4 + ansible --version
>>   ansible 2.7.7
>>     config file = /etc/ansible/ansible.cfg
>>     configured module search path = ['/home/alex/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
>>     ansible python module location = /usr/lib/python3/dist-packages/ansible
>>     executable location = /usr/bin/ansible
>>     python version = 3.7.3 (default, Jan 22 2021, 20:04:44) [GCC 8.3.0]
>>
>>   My machine is Debian stable (aka Buster)
>>
>> Hi Alex,
>>
>> I found out, the hard way, that one will need ansible 2.8.x.  I'll
>> make a note about that in the documentation. Long version:
> OK - yes please and I'll test with a local installed version. Is it
> possible for the playbook to error out with a useful warning if the
> version of ansible isn't new enough?


Hi Alex,


Yes, I'll add the version check on v7.  The planned error message will be:


"Unsuitable ansible version, please use version 2.8.0 or later"


- Cleber.
Cleber Rosa June 29, 2021, 3:06 p.m. UTC | #11
On Tue, Jun 8, 2021 at 2:48 PM Wainer dos Santos Moschetta
<wainersm@redhat.com> wrote:
>
> Hi,
>
> On 6/8/21 12:14 AM, Cleber Rosa wrote:
> > To run basic jobs on custom runners, the environment needs to be
> > properly set up.  The most common requirement is having the right
> > packages installed.
> >
> > The playbook introduced here covers the QEMU's project s390x and
> > aarch64 machines.  At the time this is being proposed, those machines
> > have already had this playbook applied to them.
> >
> > Signed-off-by: Cleber Rosa <crosa@redhat.com>
> > ---
> >   docs/devel/ci.rst                      | 30 ++++++++
> >   scripts/ci/setup/build-environment.yml | 98 ++++++++++++++++++++++++++
> >   scripts/ci/setup/inventory.template    |  1 +
> >   3 files changed, 129 insertions(+)
> >   create mode 100644 scripts/ci/setup/build-environment.yml
> >   create mode 100644 scripts/ci/setup/inventory.template
> >
> > diff --git a/docs/devel/ci.rst b/docs/devel/ci.rst
> > index 585b7bf4b8..35c6b5e269 100644
> > --- a/docs/devel/ci.rst
> > +++ b/docs/devel/ci.rst
> > @@ -26,3 +26,33 @@ gitlab-runner, is called a "custom runner".
> >   The GitLab CI jobs definition for the custom runners are located under::
> >
> >     .gitlab-ci.d/custom-runners.yml
> > +
> > +Machine Setup Howto
> > +-------------------
> > +
> > +For all Linux based systems, the setup can be mostly automated by the
> > +execution of two Ansible playbooks.  Create an ``inventory`` file
> > +under ``scripts/ci/setup``, such as this::
> Missing to mention the template file.
> > +
> > +  fully.qualified.domain
> > +  other.machine.hostname
> > +
> > +You may need to set some variables in the inventory file itself.  One
> > +very common need is to tell Ansible to use a Python 3 interpreter on
> > +those hosts.  This would look like::
> > +
> > +  fully.qualified.domain ansible_python_interpreter=/usr/bin/python3
> > +  other.machine.hostname ansible_python_interpreter=/usr/bin/python3
> > +
> > +Build environment
> > +~~~~~~~~~~~~~~~~~
> > +
> > +The ``scripts/ci/setup/build-environment.yml`` Ansible playbook will
> > +set up machines with the environment needed to perform builds and run
> > +QEMU tests.  It covers a number of different Linux distributions and
> > +FreeBSD.
> > +
> > +To run the playbook, execute::
> > +
> > +  cd scripts/ci/setup
> > +  ansible-playbook -i inventory build-environment.yml
> > diff --git a/scripts/ci/setup/build-environment.yml b/scripts/ci/setup/build-environment.yml
> > new file mode 100644
> > index 0000000000..664f2f0519
> > --- /dev/null
> > +++ b/scripts/ci/setup/build-environment.yml
> > @@ -0,0 +1,98 @@
> > +---
> > +- name: Installation of basic packages to build QEMU
> > +  hosts: all
>
> You will need to "become: yes" if the login user is not privileged, right?
>

Hi Wainer,

Yes, pretty much all of the actions here need a privileged user.  I'm
not sure how much of Ansible basics we should be replicating here.  In
my experience, users running "ansible-playbook" will resort to a
combination of --become, --become-method, --ask-become-pass, etc, if
needed.

> Or mention on the documentation how the user should configure the
> connection for privileged login.
>

Yes, I think it's better to just put a note/reference, instead of
inundating the user and the playbook with possibly unnecessary
configurations and details.  I've added the following to the
documentation:

Please note that most of the tasks in the playbook require superuser
privileges, such as those from the ``root`` account or those obtained
by ``sudo``.  If necessary, please refer to ``ansible-playbook`` options
such as ``--become``, ``--become-method``, ``--become-user`` and
``--ask-become-pass``.

Let me know if that sounds good to you.

> About privilege escalation with Ansible:
> https://docs.ansible.com/ansible/latest/user_guide/become.html
>
> > +  tasks:
>
> Just a tip: you can put all those task under a block
> (https://docs.ansible.com/ansible/latest/user_guide/playbooks_blocks.html)
> so check if "ansible_facts['distribution'] == 'Ubuntu'" only once.
>

There will be other non-Ubuntu tasks added later (such as in the
CentOS Stream 8 series), so I think it's better to keep those
separate.  Also, the Ansible version check which Alex suggested is not
limited to Ubuntu.

> I reviewed the remain of the playbook; it looks good to me.
>

Thanks!
- Cleber.
Cleber Rosa June 29, 2021, 3:23 p.m. UTC | #12
On 6/9/21 12:13 PM, Willian Rampazzo wrote:
> On Tue, Jun 8, 2021 at 3:48 PM Wainer dos Santos Moschetta
> <wainersm@redhat.com> wrote:
>> Hi,
>>
>> On 6/8/21 12:14 AM, Cleber Rosa wrote:
>>> To run basic jobs on custom runners, the environment needs to be
>>> properly set up.  The most common requirement is having the right
>>> packages installed.
>>>
>>> The playbook introduced here covers the QEMU's project s390x and
>>> aarch64 machines.  At the time this is being proposed, those machines
>>> have already had this playbook applied to them.
>>>
>>> Signed-off-by: Cleber Rosa <crosa@redhat.com>
>>> ---
>>>    docs/devel/ci.rst                      | 30 ++++++++
>>>    scripts/ci/setup/build-environment.yml | 98 ++++++++++++++++++++++++++
>>>    scripts/ci/setup/inventory.template    |  1 +
>>>    3 files changed, 129 insertions(+)
>>>    create mode 100644 scripts/ci/setup/build-environment.yml
>>>    create mode 100644 scripts/ci/setup/inventory.template
>>>
>>> diff --git a/docs/devel/ci.rst b/docs/devel/ci.rst
>>> index 585b7bf4b8..35c6b5e269 100644
>>> --- a/docs/devel/ci.rst
>>> +++ b/docs/devel/ci.rst
>>> @@ -26,3 +26,33 @@ gitlab-runner, is called a "custom runner".
>>>    The GitLab CI jobs definition for the custom runners are located under::
>>>
>>>      .gitlab-ci.d/custom-runners.yml
>>> +
>>> +Machine Setup Howto
>>> +-------------------
>>> +
>>> +For all Linux based systems, the setup can be mostly automated by the
>>> +execution of two Ansible playbooks.  Create an ``inventory`` file
>>> +under ``scripts/ci/setup``, such as this::
>> Missing to mention the template file.
>>> +
>>> +  fully.qualified.domain
>>> +  other.machine.hostname
>>> +
>>> +You may need to set some variables in the inventory file itself.  One
>>> +very common need is to tell Ansible to use a Python 3 interpreter on
>>> +those hosts.  This would look like::
>>> +
>>> +  fully.qualified.domain ansible_python_interpreter=/usr/bin/python3
>>> +  other.machine.hostname ansible_python_interpreter=/usr/bin/python3
>>> +
>>> +Build environment
>>> +~~~~~~~~~~~~~~~~~
>>> +
>>> +The ``scripts/ci/setup/build-environment.yml`` Ansible playbook will
>>> +set up machines with the environment needed to perform builds and run
>>> +QEMU tests.  It covers a number of different Linux distributions and
>>> +FreeBSD.
>>> +
>>> +To run the playbook, execute::
>>> +
>>> +  cd scripts/ci/setup
>>> +  ansible-playbook -i inventory build-environment.yml
>>> diff --git a/scripts/ci/setup/build-environment.yml b/scripts/ci/setup/build-environment.yml
>>> new file mode 100644
>>> index 0000000000..664f2f0519
>>> --- /dev/null
>>> +++ b/scripts/ci/setup/build-environment.yml
>>> @@ -0,0 +1,98 @@
>>> +---
>>> +- name: Installation of basic packages to build QEMU
>>> +  hosts: all
>> You will need to "become: yes" if the login user is not privileged, right?
>>
>> Or mention on the documentation how the user should configure the
>> connection for privileged login.
> As this will vary from system to system, I think it is worth
> mentioning in the documentation it can be configured in the inventory
> file, adding the variable ansible_become=yes and
> ansible_become_password= if password is needed to sudo.
>
Agreed.  But I'll put a mention to the ansible-playbook command line 
options instead. I believe our savvy users will be able to decide 
whether to use the command line options, the inventory options, or even 
temporary changes to the playbook.


Thanks!

- Cleber.
Cleber Rosa June 29, 2021, 11:30 p.m. UTC | #13
On 6/9/21 1:16 PM, Willian Rampazzo wrote:
> On Tue, Jun 8, 2021 at 12:14 AM Cleber Rosa <crosa@redhat.com> wrote:
>> To run basic jobs on custom runners, the environment needs to be
>> properly set up.  The most common requirement is having the right
>> packages installed.
>>
>> The playbook introduced here covers the QEMU's project s390x and
>> aarch64 machines.  At the time this is being proposed, those machines
>> have already had this playbook applied to them.
>>
>> Signed-off-by: Cleber Rosa <crosa@redhat.com>
>> ---
>>   docs/devel/ci.rst                      | 30 ++++++++
>>   scripts/ci/setup/build-environment.yml | 98 ++++++++++++++++++++++++++
>>   scripts/ci/setup/inventory.template    |  1 +
>>   3 files changed, 129 insertions(+)
>>   create mode 100644 scripts/ci/setup/build-environment.yml
>>   create mode 100644 scripts/ci/setup/inventory.template
>>
>> diff --git a/docs/devel/ci.rst b/docs/devel/ci.rst
>> index 585b7bf4b8..35c6b5e269 100644
>> --- a/docs/devel/ci.rst
>> +++ b/docs/devel/ci.rst
>> @@ -26,3 +26,33 @@ gitlab-runner, is called a "custom runner".
>>   The GitLab CI jobs definition for the custom runners are located under::
>>
>>     .gitlab-ci.d/custom-runners.yml
>> +
>> +Machine Setup Howto
>> +-------------------
>> +
>> +For all Linux based systems, the setup can be mostly automated by the
>> +execution of two Ansible playbooks.  Create an ``inventory`` file
>> +under ``scripts/ci/setup``, such as this::
>> +
>> +  fully.qualified.domain
>> +  other.machine.hostname
>> +
>> +You may need to set some variables in the inventory file itself.  One
>> +very common need is to tell Ansible to use a Python 3 interpreter on
>> +those hosts.  This would look like::
>> +
>> +  fully.qualified.domain ansible_python_interpreter=/usr/bin/python3
>> +  other.machine.hostname ansible_python_interpreter=/usr/bin/python3
>> +
> As I mentioned to Wainer, my suggestion is to include a comment about
> ansible_become=yes and
> ansible_become_password= variables as some systems may need it.


OK.  I mentioned in a previous reply that I'll plan to do this slightly 
different, that is, to mention the ansible-playbook command line 
options.  Let me know if that works for you.


>> +Build environment
>> +~~~~~~~~~~~~~~~~~
>> +
>> +The ``scripts/ci/setup/build-environment.yml`` Ansible playbook will
>> +set up machines with the environment needed to perform builds and run
>> +QEMU tests.  It covers a number of different Linux distributions and
>> +FreeBSD.
>> +
>> +To run the playbook, execute::
>> +
>> +  cd scripts/ci/setup
>> +  ansible-playbook -i inventory build-environment.yml
>> diff --git a/scripts/ci/setup/build-environment.yml b/scripts/ci/setup/build-environment.yml
>> new file mode 100644
>> index 0000000000..664f2f0519
>> --- /dev/null
>> +++ b/scripts/ci/setup/build-environment.yml
>> @@ -0,0 +1,98 @@
>> +---
>> +- name: Installation of basic packages to build QEMU
>> +  hosts: all
>> +  tasks:
>> +    - name: Update apt cache
>> +      apt:
>> +        update_cache: yes
> On a freshly installed Ubuntu 20.04, the script failed for me with
> dependency messages on the apt side. After I updated the packages on
> the system, the playbook worked without problems.


I know it's too late now, but it would have been helpful to document the 
exact error, at the very least here in this thread. I tried to replicate 
with an also fresh install, but resulted in:


PLAY RECAP 
**************************************************************************************************************************************
192.168.122.19             : ok=6    changed=4    unreachable=0 
failed=0    skipped=1    rescued=0    ignored=0


A second run resulted in:

PLAY [Installation of basic packages to build QEMU] 
*********************************************************************************************

TASK [Gathering Facts] 
**************************************************************************************************************************
ok: [192.168.122.19]

TASK [Check for suitable ansible version] 
*******************************************************************************************************
ok: [192.168.122.19] => {
     "changed": false,
     "msg": "All assertions passed"
}

TASK [Update apt cache] 
*************************************************************************************************************************
ok: [192.168.122.19]

TASK [Install basic packages to build QEMU on Ubuntu 18.04/20.04] 
*******************************************************************************
ok: [192.168.122.19]

TASK [Install packages to build QEMU on Ubuntu 18.04/20.04 on non-s390x] 
************************************************************************
ok: [192.168.122.19]

TASK [Install basic packages to build QEMU on Ubuntu 18.04] 
*************************************************************************************
skipping: [192.168.122.19]

TASK [Install basic packages to build QEMU on Ubuntu 20.04] 
*************************************************************************************
ok: [192.168.122.19]

PLAY RECAP 
**************************************************************************************************************************************
192.168.122.19             : ok=6    changed=0    unreachable=0 
failed=0    skipped=1    rescued=0    ignored=0


> So, my suggestion is to add the "update = yes" here, or add a note in
> the documentation asking the user to update the system before running
> the playbook.


IIUC, you mean an "upgrade: yes" on the "Update apt cache" task, right?  
Something like:


-    - name: Update apt cache
+    - name: Update apt cache / upgrade packages via apt
        apt:
          update_cache: yes
+        upgrade: yes

I have mixed feelings about going beyond installing/updating the 
packages we care about.  On one hand, it's a good sysadmin practice, but 
on the other hand, development/test machines are sometimes peculiar.  
Since you and Erik are in favor of the updates, I'll change that and 
wait for feedback on v7.


So, besides the change to the playbook, I'm adding to the docs:


The ``scripts/ci/setup/build-environment.yml`` Ansible playbook will
set up machines with the environment needed to perform builds and run
QEMU tests.  This playbook consists on the installation of various
required packages (and a general package update while at it).  It
currently covers a number of different Linux distributions, but it can
be expanded to cover other systems.


> Except for the above comment and Wainer's comments, it looks good to
> me. With these changes:
>
> Reviewed-by: Willian Rampazzo <willianr@redhat.com>
> Tested-by: Willian Rampazzo <willianr@redhat.com>
>

Thanks for the review and test!  Given the amount of changes, I'll hold 
a bit to take you Rb/Tb until you see/test v7.

Thanks again!

- Cleber
Cleber Rosa June 29, 2021, 11:35 p.m. UTC | #14
On 6/10/21 4:13 AM, Erik Skultety wrote:
> ...
>> On a freshly installed Ubuntu 20.04, the script failed for me with
>> dependency messages on the apt side. After I updated the packages on
>> the system, the playbook worked without problems.
>>
>> So, my suggestion is to add the "update = yes" here, or add a note in
>> the documentation asking the user to update the system before running
>> the playbook.
> I'd advocate for always updating the system automatically rather than putting
> it into the documentation and relying on users actually doing it.
>
> Erik
>

ACK, I'm adding that to v7.


Thanks,

- Cleber.
diff mbox series

Patch

diff --git a/docs/devel/ci.rst b/docs/devel/ci.rst
index 585b7bf4b8..35c6b5e269 100644
--- a/docs/devel/ci.rst
+++ b/docs/devel/ci.rst
@@ -26,3 +26,33 @@  gitlab-runner, is called a "custom runner".
 The GitLab CI jobs definition for the custom runners are located under::
 
   .gitlab-ci.d/custom-runners.yml
+
+Machine Setup Howto
+-------------------
+
+For all Linux based systems, the setup can be mostly automated by the
+execution of two Ansible playbooks.  Create an ``inventory`` file
+under ``scripts/ci/setup``, such as this::
+
+  fully.qualified.domain
+  other.machine.hostname
+
+You may need to set some variables in the inventory file itself.  One
+very common need is to tell Ansible to use a Python 3 interpreter on
+those hosts.  This would look like::
+
+  fully.qualified.domain ansible_python_interpreter=/usr/bin/python3
+  other.machine.hostname ansible_python_interpreter=/usr/bin/python3
+
+Build environment
+~~~~~~~~~~~~~~~~~
+
+The ``scripts/ci/setup/build-environment.yml`` Ansible playbook will
+set up machines with the environment needed to perform builds and run
+QEMU tests.  It covers a number of different Linux distributions and
+FreeBSD.
+
+To run the playbook, execute::
+
+  cd scripts/ci/setup
+  ansible-playbook -i inventory build-environment.yml
diff --git a/scripts/ci/setup/build-environment.yml b/scripts/ci/setup/build-environment.yml
new file mode 100644
index 0000000000..664f2f0519
--- /dev/null
+++ b/scripts/ci/setup/build-environment.yml
@@ -0,0 +1,98 @@ 
+---
+- name: Installation of basic packages to build QEMU
+  hosts: all
+  tasks:
+    - name: Update apt cache
+      apt:
+        update_cache: yes
+      when:
+        - ansible_facts['distribution'] == 'Ubuntu'
+
+    - name: Install basic packages to build QEMU on Ubuntu 18.04/20.04
+      package:
+        name:
+        # Originally from tests/docker/dockerfiles/ubuntu1804.docker
+          - ccache
+          - gcc
+          - gettext
+          - git
+          - glusterfs-common
+          - libaio-dev
+          - libattr1-dev
+          - libbrlapi-dev
+          - libbz2-dev
+          - libcacard-dev
+          - libcap-ng-dev
+          - libcurl4-gnutls-dev
+          - libdrm-dev
+          - libepoxy-dev
+          - libfdt-dev
+          - libgbm-dev
+          - libgtk-3-dev
+          - libibverbs-dev
+          - libiscsi-dev
+          - libjemalloc-dev
+          - libjpeg-turbo8-dev
+          - liblzo2-dev
+          - libncurses5-dev
+          - libncursesw5-dev
+          - libnfs-dev
+          - libnss3-dev
+          - libnuma-dev
+          - libpixman-1-dev
+          - librados-dev
+          - librbd-dev
+          - librdmacm-dev
+          - libsasl2-dev
+          - libsdl2-dev
+          - libseccomp-dev
+          - libsnappy-dev
+          - libspice-protocol-dev
+          - libssh-dev
+          - libusb-1.0-0-dev
+          - libusbredirhost-dev
+          - libvdeplug-dev
+          - libvte-2.91-dev
+          - libzstd-dev
+          - make
+          - python3-yaml
+          - python3-sphinx
+          - python3-sphinx-rtd-theme
+          - ninja-build
+          - sparse
+          - xfslibs-dev
+        state: present
+      when:
+        - ansible_facts['distribution'] == 'Ubuntu'
+
+    - name: Install packages to build QEMU on Ubuntu 18.04/20.04 on non-s390x
+      package:
+        name:
+          - libspice-server-dev
+          - libxen-dev
+        state: present
+      when:
+        - ansible_facts['distribution'] == 'Ubuntu'
+        - ansible_facts['architecture'] != 's390x'
+
+    - name: Install basic packages to build QEMU on Ubuntu 18.04
+      package:
+        name:
+        # Originally from tests/docker/dockerfiles/ubuntu1804.docker
+          - clang
+      when:
+        - ansible_facts['distribution'] == 'Ubuntu'
+        - ansible_facts['distribution_version'] == '18.04'
+
+    - name: Install basic packages to build QEMU on Ubuntu 20.04
+      package:
+        name:
+        # Originally from tests/docker/dockerfiles/ubuntu2004.docker
+          - clang-10
+          - genisoimage
+          - liblttng-ust-dev
+          - libslirp-dev
+          - netcat-openbsd
+      when:
+        - ansible_facts['distribution'] == 'Ubuntu'
+        - ansible_facts['distribution_version'] == '20.04'
diff --git a/scripts/ci/setup/inventory.template b/scripts/ci/setup/inventory.template
new file mode 100644
index 0000000000..2fbb50c4a8
--- /dev/null
+++ b/scripts/ci/setup/inventory.template
@@ -0,0 +1 @@ 
+localhost