--- - hosts: all vars: grub_password: grub.pbkdf2.sha512.10000.6595E... grub_user: admin tasks: - name: Install user template template: src: 01_users.j2 dest: /etc/grub.d/01_users owner: root group: root mode: '0700' become: yes - name: "add password" lineinfile: path: /etc/grub.d/01_users regexp: '^password_pbkdf2 {{ grub_user }} ' state: present line: 'password_pbkdf2 {{ grub_user }} {{ grub_password }}' become: yes - name: "insert unrestricted" lineinfile: path: /etc/grub.d/10_linux regexp: '^CLASS=\"--class gnu-linux --class gnu --class os\"' state: present line: 'CLASS="--class gnu-linux --class gnu --class os --unrestricted"' become: yes - name: run update-grub command: update-grub become: yes