Add CPU isolation support for Yardstick NSB setup
[yardstick.git] / ansible / roles / enable_cpu_isolation_on_boot / tasks / main.yml
1 # Copyright (c) 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: Check if isolcpus is set by this role in {{ grub_file}}
16   lineinfile:
17     path: "{{ grub_file }}"
18     regexp: '{{ isolcpus_help_string }}'
19     state: absent
20   check_mode: yes
21   register: is_nsb_isolcpus_role
22   ignore_errors: True
23
24 - name: Check if isolcpus is set by someone else
25   lineinfile:
26     path: "{{ grub_file }}"
27     regexp: "isolcpus="
28     state: absent
29   check_mode: yes
30   register: is_isolcpu
31   ignore_errors: True
32
33 - name: Send warning that CPU isolation cannot be configured
34   debug:
35     msg: "WARNING: CPU isolation is not configured"
36   when:
37     - not is_nsb_isolcpus_role.changed and not is_isolcpu.changed
38     - ISOL_CPUS is not defined
39
40 - name: Send info that CPU isolation configured by someone else
41   debug:
42     msg: "INFO: NOT modified, CPU isolation is already configured by someone."
43   when:
44     - not is_nsb_isolcpus_role.changed and is_isolcpu.changed
45
46 - name: Add/update isolcpus when ISOL_CPUS is defined and not set at all or set by this role
47   lineinfile:
48     path: "{{ grub_file }}"
49     regexp: "{{ isolcpus_help_string }}"
50     line: '{{ enable_isolcpu }} {{ isolcpus_help_string }}'
51   when:
52     - is_nsb_isolcpus_role.changed or not is_nsb_isolcpus_role.changed and not is_isolcpu.changed
53     - ISOL_CPUS is defined
54
55 - name: Update grub for bare metal usage
56   command: "{{ update_grub[ansible_os_family] }}"
57   when:
58     - is_nsb_isolcpus_role.changed or not is_nsb_isolcpus_role.changed and not is_isolcpu.changed
59     - ISOL_CPUS is defined