aboutsummaryrefslogtreecommitdiffstats
path: root/ansible/roles/enable_hugepages_on_boot/tasks
diff options
context:
space:
mode:
authorJan Malanik <janx.malanik@intel.com>2017-11-21 11:05:07 -0800
committerRoss Brattain <ross.b.brattain@intel.com>2017-12-22 10:43:44 +0000
commitd2c4c4f8a798506ee88d0412ee1ab7cae5f394e5 (patch)
tree3645ff8087e11638abf7a50aa107ed99c10471fb /ansible/roles/enable_hugepages_on_boot/tasks
parent057b1a79717c12eb283baeed94963cda2ff26df8 (diff)
Bugfix in role enable_hugepages_on_boot
Make role idempotent. Current regex doesn't match for: linux /boot/vmlinuz-4.10.0-30-generic root=/dev/nvme0n1p1 ro vga=788 text Change-Id: If5eb20fce4ddc35bb109c00eb7565853b3763950 Signed-off-by: Jan Malanik <janx.malanik@intel.com> Signed-off-by: Malanik Jan <janx.malanik@intel.com>
Diffstat (limited to 'ansible/roles/enable_hugepages_on_boot/tasks')
-rwxr-xr-xansible/roles/enable_hugepages_on_boot/tasks/main.yml55
-rw-r--r--ansible/roles/enable_hugepages_on_boot/tasks/manual_modify_grub.yml17
2 files changed, 38 insertions, 34 deletions
diff --git a/ansible/roles/enable_hugepages_on_boot/tasks/main.yml b/ansible/roles/enable_hugepages_on_boot/tasks/main.yml
index 29432d2e4..75526eb19 100755
--- a/ansible/roles/enable_hugepages_on_boot/tasks/main.yml
+++ b/ansible/roles/enable_hugepages_on_boot/tasks/main.yml
@@ -31,34 +31,37 @@
msg: "Hugepages already set by someone else"
when: is_mine_huge.stdout == "" and is_huge.stdout != ""
-- name: use 16 for auto num_hugepages and 1G size
- set_fact:
- num_hugepages: 8
- when: num_hugepages|default("auto") == "auto"
+- name: configure hugepages as idempotent block
+ block:
+ - name: use 8 for auto num_hugepages and 1G size
+ set_fact:
+ num_hugepages: 8
+ when: num_hugepages|default("auto") == "auto"
-- name: set hugepages in grub
- lineinfile:
- dest: /etc/default/grub
- regexp: '{{ hugepage_param_regex }}'
- line: '{{ hugepage_param }}'
- state: present
+ - name: set hugepages in grub
+ lineinfile:
+ dest: /etc/default/grub
+ regexp: '{{ hugepage_param_regex }}'
+ line: '{{ hugepage_param }}'
+ state: present
-- name: create hugetables mount
- file:
- path: "{{ hugetable_mount }}"
- state: directory
+ - name: create hugetables mount
+ file:
+ path: "{{ hugetable_mount }}"
+ state: directory
-- name: mount hugetlbfs
- mount:
- name: "{{ hugetable_mount }}"
- src: nodev
- fstype: hugetlbfs
- state: present
+ - name: mount hugetlbfs
+ mount:
+ name: "{{ hugetable_mount }}"
+ src: nodev
+ fstype: hugetlbfs
+ state: present
-- service:
- name: procps
- enabled: yes
+ - service:
+ name: procps
+ enabled: yes
-- include: manual_modify_grub.yml
- # only tested on Ubuntu, kernel line is probably different on other distros
- when: ansible_distribution == "Ubuntu"
+ - include: manual_modify_grub.yml
+ # only tested on Ubuntu, kernel line is probably different on other distros
+ when: ansible_distribution == "Ubuntu"
+ when: is_mine_huge.stdout == ""
diff --git a/ansible/roles/enable_hugepages_on_boot/tasks/manual_modify_grub.yml b/ansible/roles/enable_hugepages_on_boot/tasks/manual_modify_grub.yml
index cac10e80e..6fa0c1d25 100644
--- a/ansible/roles/enable_hugepages_on_boot/tasks/manual_modify_grub.yml
+++ b/ansible/roles/enable_hugepages_on_boot/tasks/manual_modify_grub.yml
@@ -20,16 +20,17 @@
recurse: yes
register: grub_files
+- name: check if hugepages are already enabled
+ command: "grep -o 'default_hugepagesz=' {{ item.path }}"
+ register: hugepage_enabled
+ ignore_errors: True
+ with_items: "{{ grub_files.files }}"
-- name: added hugepages to grub manually because we can't run update-grub in chroot
+- name: add hugepages to grub manually because we can't run update-grub in chroot
replace:
dest: "{{ item.path }}"
- # console= should end the line
- regexp: '(linux\s+/boot/vmlinuz.*console=\S+$)'
- # default_hugepagesz=1G hugepagesz=1G hugepages=8
+ regexp: '(linux\s+/boot/vmlinuz.*$)'
replace: '\1 default_hugepagesz={{ huge_pagesize_short[huge_pagesize_mb] }} hugepagesz={{ huge_pagesize_short[huge_pagesize_mb] }} hugepages={{ num_hugepages }}'
with_items: "{{ grub_files.files }}"
-
-
-
-
+ # we suppose consistent /boot/grub/grub.cfg files
+ when: hugepage_enabled['results'][0].stdout == ""