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"
25 - name: Define grub string for IOMMU
27 enable_iommu: 'GRUB_CMDLINE_LINUX="$GRUB_CMDLINE_LINUX{{ iommu_boot_params }}'
29 - name: check if iommu is set by this role in {{ grub_file}}
31 path: "{{ grub_file}}"
32 regexp: '{{ iommu_help_string }}'
33 line: '{{ iommu_help_string }}'
36 register: is_nsb_iommu_role
39 - name: Check if IOMMU is set by someone else
41 path: "{{ grub_file}}"
43 line: '{{ iommu_help_string }}'
49 - name: Send info that IOMMU is configured by someone else
51 msg: "INFO: NOT modified, IOMMU is already configured by someone."
53 - not is_nsb_iommu_role.changed
56 - name: Add IOMMU when it is not set
58 path: "{{ grub_file }}"
59 regexp: "{{ iommu_help_string }}"
60 line: '{{ enable_iommu }}" {{ iommu_help_string }}'
62 - not is_nsb_iommu_role.changed
63 - not is_iommu.changed
65 - name: find boot grub.cfg
73 - include: manual_modify_grub.yml
74 # only tested on Ubuntu, kernel line is probably different on other distros
75 with_items: "{{ grub_files.files }}"
76 when: ansible_distribution == "Ubuntu"