aboutsummaryrefslogtreecommitdiffstats
path: root/ansible/roles/enable_cpu_isolation_on_boot/tasks/main.yml
blob: e11288bfdc8d02c08a72e92fcaf615d9eeb45d9f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# Copyright (c) 2018-2019 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
---
- name: Check if isolcpus is set by this role in {{ grub_file}}
  lineinfile:
    path: "{{ grub_file }}"
    regexp: '{{ isolcpus_help_string }}'
    state: absent
  check_mode: yes
  register: is_nsb_isolcpus_role
  ignore_errors: True

- name: Check if isolcpus is set by someone else
  lineinfile:
    path: "{{ grub_file }}"
    regexp: "isolcpus="
    state: absent
  check_mode: yes
  register: is_isolcpu
  ignore_errors: True

- name: Send warning that CPU isolation cannot be configured
  debug:
    msg: "WARNING: CPU isolation is not configured"
  when:
    - not is_nsb_isolcpus_role.changed and not is_isolcpu.changed
    - ISOL_CPUS is not defined

- name: Send info that CPU isolation configured by someone else
  debug:
    msg: "INFO: NOT modified, CPU isolation is already configured by someone."
  when:
    - not is_nsb_isolcpus_role.changed and is_isolcpu.changed

- name: Add/update isolcpus when ISOL_CPUS is defined and not set at all or set by this role
  lineinfile:
    path: "{{ grub_file }}"
    regexp: "{{ isolcpus_help_string }}"
    line: '{{ enable_isolcpu }} {{ isolcpus_help_string }}'
  when:
    - is_nsb_isolcpus_role.changed or not is_nsb_isolcpus_role.changed and not is_isolcpu.changed
    - ISOL_CPUS is defined

- name: Update grub for bare metal usage
  command: "{{ update_grub[ansible_os_family] }}"
  when:
    - is_nsb_isolcpus_role.changed or not is_nsb_isolcpus_role.changed and not is_isolcpu.changed
    - ISOL_CPUS is defined