From 23fdade9964d91b7411ba15f53d854606023598a Mon Sep 17 00:00:00 2001 From: jgoutin Date: Wed, 27 Nov 2019 14:16:02 +0100 Subject: [PATCH] Ensure kernel headers are present and add source step to .bashrc --- README.md | 2 ++ defaults/main.yml | 3 +++ tasks/main.yml | 45 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 50 insertions(+) diff --git a/README.md b/README.md index 1c035db..db64ee3 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,8 @@ CentOS 7 is recommanded on AWS since AWS only provides packages for it. Default to the classical Xilinx XRT environment. * **xilinx_xrt_ensure_compatible_kernel**: If `true`, ensure the Linux kernel installed is compatible. Default to `true`. +* **xilinx_xrt_bashrc**: If `true`, add the source of the XRT setup script to the user `~/.bashrc`. + Default to `false`. ### AWS FPGA diff --git a/defaults/main.yml b/defaults/main.yml index 07a84fd..1960a57 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -2,6 +2,9 @@ # Install Xilinx XRT xilinx_xrt_install: true +# Add "source /opt/xilinx/xrt/setup.sh" to user "~/.bashrc" +xilinx_xrt_bashrc: false + # Xilinx XRT environement, default to Xilinx classical environement xilinx_xrt_env: '' diff --git a/tasks/main.yml b/tasks/main.yml index a3a422c..504793e 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -111,6 +111,23 @@ - not xbutil.stat.exists - ansible_os_family == 'RedHat' +- name: Ensure Kernel headers RPM are installed + yum: + name: + - "kernel-devel-{{ ansible_kernel }}" + - "kernel-headers-{{ ansible_kernel }}" + state: present + install_weak_deps: false + enablerepo: C7.* + retries: 10 + delay: 1 + when: + - xilinx_xrt_install | bool + - not xbutil.stat.exists + - ansible_os_family == 'RedHat' + tags: + - molecule-notest # Bad detected kernel version from container + - name: Ensure XRT RPM package is installed yum: name: "{{ xrt_tmp.path }}/{{ xrt_package }}" @@ -123,6 +140,25 @@ - ansible_os_family == 'RedHat' - not xbutil.stat.exists +- name: Ensure APT cache is up to date + apt: + update_cache: true + changed_when: false + when: + - xilinx_xrt_install | bool + - ansible_os_family == 'Debian' + - not xbutil.stat.exists + +- name: Ensure Kernel headers DEB are installed + apt: + name: "linux-headers-{{ ansible_kernel }}-generic" + when: + - xilinx_xrt_install | bool + - ansible_os_family == 'Debian' + - not xbutil.stat.exists + tags: + - molecule-notest # Bad detected kernel version from container + - name: Ensure XRT DEB package is installed package: deb: "{{ xrt_tmp.path }}/{{ xrt_package }}" @@ -135,5 +171,14 @@ - ansible_os_family == 'Debian' - not xbutil.stat.exists +- name: Ensure XRT is sourced in ~/.bashrc + lineinfile: + path: /home/{{ ansible_user }}/.bashrc + regexp: "^source /opt/xilinx/xrt/setup.sh" + line: source /opt/xilinx/xrt/setup.sh + when: + - xilinx_xrt_install | bool + - xilinx_xrt_bashrc | bool + - include_tasks: aws.yml when: xilinx_xrt_env == 'aws'