---
- hosts: kv
  vars:
    grub_cfg: /boot/grub2/grub.cfg
    grub_defaults: /etc/default/grub

  tasks:
  - name: checking if there are custom memory settings
    shell: grep -E ' mem=[0-9]+G' {{ grub_defaults }}
    register: grep
    ignore_errors: yes

  - name: changing the GRUB configation
    shell: sed -i -E 's/ mem=[0-9]+G//g' {{ grub_defaults }}
    when: grep.stdout

  - name: applying new GRUB settings
    shell: grub2-mkconfig -o {{ grub_cfg }}
    when: grep.stdout

  - name: restarting servers
    shell: sleep 1 && shutdown -r now
    async: 1
    poll: 0
    when: grep.stdout

  - name: waitings for servers to restart
    wait_for_connection:
      delay: 10
      sleep: 10
    when: grep.stdout

Add Ansible playbook for resetting kernel memory settings
Add Ansible playbook for resetting kernel memory settings

This playbook can be added as a mandatory post build task. Those
tasks are triggered even when performance tests are manually aborted.

Usage:

  env/bin/ansible-playbook -i clusters/hera.ini playbooks/reset_mem.yml

Change-Id: I9262aed60a4aee6f2ee8093a1316d3a77abbe234
Reviewed-on: http://review.couchbase.org/88670
Tested-by: Build Bot <80754af91bfb6d1073585b046fe0a474ce868509@couchbase.com>
Tested-by: Pavel Paulau <dd88eded64e90046a680e3a6c0828ceb8fe8a0e7@gmail.com>
Reviewed-by: Paolo Cocchi <9dd88c9f3e5cbab6e19a6c020f107e0c648ac956@couchbase.com>
Reviewed-by: Pavel Paulau <dd88eded64e90046a680e3a6c0828ceb8fe8a0e7@gmail.com>
