Merge "Remove duplicated Firewall Concurrency testcases"
[yardstick.git] / ansible / roles / enable_iommu_on_boot / tasks / main.yml
1 # Copyright (c) 2017-2018 Intel Corporation
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 #      http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14 ---
15 - name: Set iommu_boot_params for Intel
16   set_fact:
17     iommu_boot_params: ' intel_iommu=on iommu=pt'
18   when: hostvars[inventory_hostname]['ansible_system_vendor'] == "Intel Corporation"
19
20 - name: Set iommu_boot_params for AMD
21   set_fact:
22     iommu_boot_params: ' amd_iommu=on iommu=pt'
23   when: hostvars[inventory_hostname]['ansible_system_vendor'] == "AuthenticAMD"
24
25 - block:
26   - name: Define grub string for IOMMU
27     set_fact:
28       enable_iommu: 'GRUB_CMDLINE_LINUX="$GRUB_CMDLINE_LINUX{{ iommu_boot_params }}'
29
30   - name: check if iommu is set by this role in {{ grub_file}}
31     lineinfile:
32       path: "{{ grub_file}}"
33       regexp: '{{ iommu_help_string }}'
34       line: '{{ iommu_help_string }}'
35       state: absent
36     check_mode: yes
37     register: is_nsb_iommu_role
38     ignore_errors: True
39
40   - name: Check if IOMMU is set by someone else
41     lineinfile:
42       path: "{{ grub_file}}"
43       regexp: "_iommu="
44       line: '{{ iommu_help_string }}'
45       state: absent
46     check_mode: yes
47     register: is_iommu
48     ignore_errors: True
49
50   - name: Send info that IOMMU is configured by someone else
51     debug:
52       msg: "INFO: NOT modified, IOMMU is already configured by someone."
53     when:
54       - not is_nsb_iommu_role.changed
55       - is_iommu.changed
56
57   - name: Add IOMMU when it is not set
58     lineinfile:
59       path: "{{ grub_file }}"
60       regexp: "{{ iommu_help_string }}"
61       line: '{{ enable_iommu }}" {{ iommu_help_string }}'
62     when:
63       - not is_nsb_iommu_role.changed
64       - not is_iommu.changed
65
66   - name: find boot grub.cfg
67     find:
68       paths: /boot
69       file_type: file
70       patterns: 'grub*.cfg'
71       recurse: yes
72     register: grub_files
73
74   - include: manual_modify_grub.yml
75     # only tested on Ubuntu, kernel line is probably different on other distros
76     with_items: "{{ grub_files.files }}"
77     when: ansible_distribution == "Ubuntu"
78   when: iommu_boot_params is defined