summaryrefslogtreecommitdiffstats
path: root/kud/deployment_infra/playbooks/preconfigure-qat.yml
blob: ef8446f831946e5b7403b8b3d1ab0bb91e1794d8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
---
# SPDX-license-identifier: Apache-2.0
##############################################################################
# Copyright (c) 2018
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Apache License, Version 2.0
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################

- hosts: localhost
  become: yes
  pre_tasks:
    - name: Load kud variables
      include_vars:
        file: kud-vars.yml
  tasks:
    - name: Create QAT dest folder
      file:
        state: directory
        path: "{{ qat_dest }}"
    - name: Download QAT driver tarball
      get_url:
        url: "{{ qat_driver_url }}"
        dest: "{{ qat_dest }}/{{ qat_package }}.tar.gz"

- hosts: kube-node
  become: yes
  pre_tasks:
    - name: Load kud variables
      include_vars:
        file: kud-vars.yml
  tasks:
    - name: Create destination folder for QAT check script
      file:
        state: directory
        path: "{{ base_dest }}/qat"
    - name: Create QAT check script
      copy:
        dest: "{{ base_dest }}/qat/qat.sh"
        content: |
            #!/bin/bash
            qat_device=$( for i in 0434 0435 37c8 6f54 19e2; \
                    do lspci -d 8086:$i -m; done |\
                            grep -i "Quick*" | head -n 1 | cut -d " " -f 5 )
            if [ -z "$qat_device" ]; then
                echo "False"
                exit 0
            else
                echo "True"
            fi
        mode: 0755
    - name: Run QAT check script and re-evaluate the variable
      command: ./qat.sh
      args:
        chdir: "{{ base_dest }}/qat"
      register: output
    - debug:
        var: output.stdout_lines
    - set_fact:
        QAT_ENABLED: "{{ output.stdout }}"
    - debug:
        var: output
    - name: Clean QAT check script and folder
      file:
        path: "{{ base_dest }}/qat"
        state: absent
    - name: Install QAT driver
      block:
      - name: Install QAT compilation packages
        package:
          name: "{{ item }}"
          state: present
        with_items:
          - pciutils
          - build-essential
          - libudev-dev
          - pkg-config
      - name: Create destination folder for QAT source code
        file:
          state: directory
          path: "{{ qat_dest }}/{{ qat_package }}"
      - name: Extract QAT source code
        unarchive:
          src: "{{ qat_dest }}/{{ qat_package }}.tar.gz"
          dest: "{{ qat_dest }}/{{ qat_package }}"
      - name: Configure the target
        command: ./configure --enable-icp-sriov=host
        args:
          chdir: "{{ qat_dest }}/{{ qat_package }}"
      - name: Build QAT driver
        make:
          chdir: "{{ qat_dest }}/{{ qat_package }}"
          target: "{{ item }}"
        loop:
          - clean
          - uninstall
          - install
      - name: Copy QAT driver install script to target folder
        copy:
          src: "install_qat.sh"
          dest: "{{ qat_dest }}/{{ qat_package }}/build"
          mode: 0755
      - name: Copy /etc/default/qat to target folder
        copy:
          src: "/etc/default/qat"
          dest: "{{ qat_dest }}/{{ qat_package }}/build"
          remote_src: yes
      - name: Run a script with arguments
        command: ./install_qat.sh
        args:
          chdir: "{{ qat_dest }}/{{ qat_package }}/build"
      - name: Copy QAT substitue script to target folder
        copy:
          src: "substitute.sh"
          dest: "{{ qat_dest }}/{{ qat_package }}/build"
          mode: 0755
      - name: Update the QAT device SSL values to avoid duplication
        command: ./substitute.sh
        args:
          chdir: "{{ qat_dest }}/{{ qat_package }}/build"
      - name: Restart acceleration driver framework
        command: adf_ctl restart
      - name: Restart QAT service
        service:
          name: qat_service
          state: restarted
      when: QAT_ENABLED