From 8e6e399e5b372c977238fc90ac3b24efe2d21c4b Mon Sep 17 00:00:00 2001 From: jgoutin Date: Wed, 6 Nov 2019 10:49:18 +0100 Subject: [PATCH] Allow to download AWS SDK --- README.md | 1 + molecule/default/molecule.yml | 4 ++++ tasks/main.yml | 41 +++++++++++++++++++++++++---------- 3 files changed, 35 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index eb3e48f..feeed3a 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,7 @@ Role Variables No effect if *aws_fpga_allow_non_root* is `false`. * **aws_fpga_sdk_override_group**: If true, do not raise error if the group specified by *aws_fpga_sdk_group* already exists. Default to `false`. No effect if *aws_fpga_allow_non_root* is `false`. +* **aws_fpga_src_install**: If specified, install AWS FPGA sources in the specified directory. * **aws_fpga_xrt**: If `true`, also install Xilinx XRT. Default to `true`. diff --git a/molecule/default/molecule.yml b/molecule/default/molecule.yml index 3288329..5520693 100644 --- a/molecule/default/molecule.yml +++ b/molecule/default/molecule.yml @@ -25,6 +25,10 @@ provisioner: name: ansible lint: name: ansible-lint + inventory: + host_vars: + centos_7: + aws_fpga_src_install: /opt/aws_fpga verifier: name: testinfra diff --git a/tasks/main.yml b/tasks/main.yml index 38027cb..cd9a64b 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -17,14 +17,34 @@ tempfile: state: directory prefix: aws_fpga_ - register: aws_fpga_src - when: not libfpga_mgmt.stat.exists + register: aws_fpga_tmp_src + when: + - not libfpga_mgmt.stat.exists + - aws_fpga_src_install is not defined + +- name: Set AWS FPGA source directory + set_fact: + aws_fpga_src: "{{ aws_fpga_tmp_src.path }}" + when: aws_fpga_tmp_src.path is defined + +- name: Ensure AWS FPGA source directory exists + file: + state: directory + path: "{{ aws_fpga_src_install }}" + when: + - aws_fpga_src_install is defined + +- name: Set AWS FPGA source directory + set_fact: + aws_fpga_src: "{{ aws_fpga_src_install }}" + when: + - aws_fpga_src_install is defined - name: Download and extract AWS FPGA release tarbal unarchive: src: "https://api.github.com/repos/aws/aws-fpga/tarball/\ {{ aws_fpga_version | default('') }}" - dest: "{{ aws_fpga_src.path }}" + dest: "{{ aws_fpga_src }}" remote_src: true extra_opts: ['--strip-components=1'] register: aws_sdk @@ -55,7 +75,7 @@ when: ansible_os_family == 'RedHat' and not libfpga_mgmt.stat.exists - name: Build and install AWS FPGA libraries and utilities - shell: "source {{ aws_fpga_src.path }}/sdk_setup.sh;" + shell: "source {{ aws_fpga_src }}/sdk_setup.sh;" environment: AWS_FPGA_ALLOW_NON_ROOT: "{{ aws_fpga_allow_non_root or '' }}" AWS_FPGA_SDK_GROUP: "{{ aws_fpga_sdk_group }}" @@ -69,7 +89,7 @@ - name: Download xrt/xrt-aws packages from AWS FPGA developper AMI get_url: url: "{{ s3_dev_ami_url }}{{ xrt_package }}-{{ item }}.rpm" - dest: "{{ aws_fpga_src.path }}/{{ xrt_package | basename }}-{{ item }}.rpm" + dest: "{{ aws_fpga_src }}/{{ xrt_package | basename }}-{{ item }}.rpm" with_items: - xrt - aws @@ -87,7 +107,7 @@ - name: Ensure xrt/xrt-aws packages are installed yum: - name: "{{ aws_fpga_src.path }}/{{ xrt_package | basename }}-{{ item }}.rpm" + name: "{{ aws_fpga_src }}/{{ xrt_package | basename }}-{{ item }}.rpm" state: present with_items: - xrt @@ -115,11 +135,10 @@ - name: Build and install AWS FPGA driver command: "{{ item }}" args: - chdir: "{{ aws_fpga_src.path }}/sdk/linux_kernel_drivers/\ - {{ aws_fpga_driver }}" + chdir: "{{ aws_fpga_src }}/sdk/linux_kernel_drivers/{{ aws_fpga_driver }}" environment: # Required for XOCL - SDACCEL_DIR: "{{ aws_fpga_src.path }}/SDAccel" + SDACCEL_DIR: "{{ aws_fpga_src }}/SDAccel" with_items: - /usr/bin/make -j - /usr/bin/make install @@ -128,6 +147,6 @@ - name: Clean up AWS FPGA temporary directory file: - path: "{{ aws_fpga_src.path }}" + path: "{{ aws_fpga_tmp_src.path }}" state: absent - when: not libfpga_mgmt.stat.exists and aws_fpga_src.path is defined + when: not libfpga_mgmt.stat.exists and aws_fpga_tmp_src.path is defined