1 # Copyright (c) 2017-2018 Intel Corporation
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
7 # http://www.apache.org/licenses/LICENSE-2.0
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.
15 - name: Set iommu_boot_params for Intel
17 iommu_boot_params: ' intel_iommu=on iommu=pt'
18 when: hostvars[inventory_hostname]['ansible_system_vendor'] == "Intel Corporation"
20 - name: Set iommu_boot_params for AMD
22 iommu_boot_params: ' amd_iommu=on iommu=pt'
23 when: hostvars[inventory_hostname]['ansible_system_vendor'] == "AuthenticAMD"
26 - name: Define grub string for IOMMU
28 enable_iommu: 'GRUB_CMDLINE_LINUX="$GRUB_CMDLINE_LINUX{{ iommu_boot_params }}'
30 - name: check if iommu is set by this role in {{ grub_file}}
32 path: "{{ grub_file}}"
33 regexp: '{{ iommu_help_string }}'
34 line: '{{ iommu_help_string }}'
37 register: is_nsb_iommu_role
40 - name: Check if IOMMU is set by someone else
42 path: "{{ grub_file}}"
44 line: '{{ iommu_help_string }}'
50 - name: Send info that IOMMU is configured by someone else
52 msg: "INFO: NOT modified, IOMMU is already configured by someone."
54 - not is_nsb_iommu_role.changed
58 - name: Add IOMMU when it is not set
60 path: "{{ grub_file }}"
61 regexp: "{{ iommu_help_string }}"
62 line: '{{ enable_iommu }}" {{ iommu_help_string }}'
64 - name: find boot grub.cfg
72 - include: manual_modify_grub.yml
73 # only tested on Ubuntu, kernel line is probably different on other distros
74 with_items: "{{ grub_files.files }}"
76 - ansible_distribution == "Ubuntu"
77 - not is_nsb_iommu_role.changed
78 - not is_iommu.changed
79 when: iommu_boot_params is defined