- name: "Get grub timeout value"
  shell: cat /etc/default/grub | grep GRUB_TIMEOUT | sed 's/GRUB_TIMEOUT=//g'
  register: current_grub_timeout

- name: 'Configure grub timeout if not already'
  shell: sed 's/^GRUB_TIMEOUT=.*/GRUB_TIMEOUT={{ timeout }}/g' -i /etc/default/grub
  when: current_grub_timeout.stdout != "{{ grub_timeout }}"
  
- name: 'Update grub'
  shell: update-grub
  when: current_grub_timeout.stdout != "{{ grub_timeout }}"