---
# pm-suspend is from pm-utils package (required by libvirt-client)
- name: user | Add doas config for user {{ username }}
  blockinfile:
    path: /etc/doas.conf
    block: |
      permit persist :wheel
      {% if nopasswd_commands | length > 0 %}
      {% for command in nopasswd_commands %}
      permit nopass {{ username }} cmd {{ command }}
      {% endfor %}
      {% endif %}
    marker: '# {mark} ANSIBLE MANAGED SETTINGS'
    owner: root
    group: root
    mode: '600'
    validate: /usr/bin/doas -C %s
