---
- 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

---
- hosts: kv:index
  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

Reset memory on index nodes as well
Reset memory on index nodes as well

Change-Id: I718683ca1e9cbf9c3fcb530145c700e82b67ea85
Reviewed-on: http://review.couchbase.org/92717
Tested-by: Build Bot <80754af91bfb6d1073585b046fe0a474ce868509@couchbase.com>
Reviewed-by: Pavel Paulau <dd88eded64e90046a680e3a6c0828ceb8fe8a0e7@gmail.com>
