add python compatibility module
[multicloud/k8s.git] / kud / deployment_infra / playbooks / preconfigure-sriov.yml
1 ---
2 # SPDX-license-identifier: Apache-2.0
3 ##############################################################################
4 # Copyright (c) 2018
5 # All rights reserved. This program and the accompanying materials
6 # are made available under the terms of the Apache License, Version 2.0
7 # which accompanies this distribution, and is available at
8 # http://www.apache.org/licenses/LICENSE-2.0
9 ##############################################################################
10
11 - hosts: localhost
12   become: yes
13   pre_tasks:
14     - name: Load kud variables
15       include_vars:
16         file: kud-vars.yml
17   tasks:
18     - name: Create SRIOV dest folder
19       file:
20         state: directory
21         path: "{{ sriov_dest }}"
22     - name: Fetching SRIOV driver
23       block:
24       - name: Download SRIOV driver tarball
25         get_url:
26           url: "{{ sriov_driver_url }}"
27           dest: "{{ sriov_dest }}/{{ sriov_package }}.tar.gz"
28
29 - hosts: kube-node
30   become: yes
31   pre_tasks:
32     - name: Load kud variables
33       include_vars:
34         file: kud-vars.yml
35   tasks:
36     - name: Create a destination for driver folder in the target's /tmp
37       file:
38         state: directory
39         path: "{{ item }}"
40       with_items:
41         - "{{ base_dest }}/sriov/{{ sriov_package }}"
42     - name: Create SRIOV dest folder
43       file:
44         state: directory
45         path: "sriov"
46     - name: Register SRIOV env variable
47       shell: "echo {{ SRIOV_ENABLED | default(False) }}"
48     - name: Copy SRIOV check script to target
49       copy:
50         src: "{{ playbook_dir }}/sriov_hardware_check.sh"
51         dest: sriov
52         mode: 0755
53     - name: Run the script and re-evaluate the variable
54       command: "sriov/sriov_hardware_check.sh"
55       register: output
56     - debug:
57         var: output.stdout_lines
58     - set_fact:
59         SRIOV_ENABLED: "{{ output.stdout }}"
60     - debug:
61         var: output
62     - name: Clean the script and folder
63       file:
64         path: sriov
65         state: absent
66     - name: Install SRIOV compilation packges
67       package:
68         name: "{{ item }}"
69         state: present
70       with_items: "{{ sriov_pkgs }}"
71       when: SRIOV_ENABLED
72     - name: Extract SRIOV source code
73       unarchive:
74          src: "{{ sriov_dest }}/{{ sriov_package }}.tar.gz"
75          dest: "{{ base_dest }}/sriov"
76       when: SRIOV_ENABLED
77     - name: Build the SRIOV target
78       make:
79         chdir: "{{ base_dest }}/sriov/{{ sriov_package }}/src"
80       when: SRIOV_ENABLED
81     - name: Create SRIOV driver folder in the target destination
82       file:
83         state: directory
84         path: "{{ item }}"
85       with_items:
86         - sriov_driver
87       when: SRIOV_ENABLED
88     - name: Copy SRIOV module to target destination
89       copy:
90         src: "{{ base_dest }}/sriov/{{ sriov_package }}/src/iavf.ko"
91         dest: sriov_driver
92         remote_src: yes
93       when: SRIOV_ENABLED
94     - name: Copy SRIOV install script to target
95       copy:
96         src: "{{ playbook_dir }}/install_iavf_drivers.sh"
97         dest: sriov_driver/install.sh
98         mode: 0755
99       when: SRIOV_ENABLED
100     - name: Run the install script with arguments
101       shell: ./install.sh
102       args:
103         chdir: "sriov_driver"
104       when: SRIOV_ENABLED
105     - name: Clean the SRIOV folder
106       file:
107         path: "{{ base_dest }}/sriov"
108         state: absent