#!/bin/sh
## {{ ansible_managed }}
exec tail -n +5 $0

{% set superusers = grub__combined_users|rejectattr("superuser", "none")|map(attribute = 'name')|join(' ') %}
{% if superusers|length == 0 %}
## No users have been defined.
{% else %}
set superusers="{{ superusers }}"
{%   for item in grub__combined_users %}
password_pbkdf2 {{ item.name }} {{ lookup('file', secret + "/credentials/" + inventory_hostname + "/grub/" + item.name + "/password_hash") }}
{%   endfor %}
## Workaround for https://bugs.launchpad.net/ubuntu/+source/grub2/+bug/718670
export superusers
{% endif %}
