# {{ ansible_managed }}

{% for item in sudoers_server_file_defaults | default([]) %}
Defaults {{ item }}
{% endfor %}

# Host alias specification
{% for item in sudoers_server_file_host_aliases | default([]) %}
Host_Alias {{ item.name }} = {{ item.entry }}
{% endfor %}

# User alias specification
{% for item in sudoers_server_file_user_aliases | default([]) %}
User_Alias {{ item.name }} = {{ item.entry }}
{% endfor %}

# Cmnd alias specification
{% for item in sudoers_server_file_cmnd_aliases | default([]) %}
Cmnd_Alias {{ item.name }} = {{ item.entry }}
{% endfor %}

# Runas alias specification
{% for item in sudoers_server_file_runas_aliases | default([]) %}
Runas_Alias {{ item.name }} = {{ item.entry }}
{% endfor %}

# User privilege specification

{# rule for user 'back' #}
{% for item in sudoers_server_file_user_back_privileges | default([]) %}
back {{ item }}
{% endfor -%}


{%- if ansible_virtualization_role == 'host' %}

{% for item in sudoers_server_file_user_back_disk_privileges | default([]) %}
back {{ item }}
{% endfor %}
{% endif -%}

{# other (host specific) rules #} 
{%-  if (sudoers_server_file_user_privileges is defined and sudoers_server_file_user_privileges) %}

{% for item in sudoers_server_file_user_privileges | default([]) %}
{{ item.name }} {{ item.entry }}
{% endfor %}
{% endif %}

# Group privilege specification
{% for item in sudoers_server_file_group_privileges | default([]) %}
{{ item.name }} {{ item.entry }}
{% endfor -%}
