<?xml version="1.0" encoding="utf-8"?>

<creole>

    <files>
        <file filelist="workstation-manager" name="/etc/bareos/bareosfichiers.d/workstation.conf"/>
        <file name='/etc/sudoers.d/eole' source='eole.sudoers' mkdir='True'/>
    </files>
    <containers>
        <container name="domaine">
            <package>eole-workstation-pkg</package>
            <file filelist="workstation-manager" name="/etc/salt/master.d/workstation-manager.conf"/>
            <file filelist="workstation-manager" name="/etc/salt/master.d/reactor.conf"/>
            <file filelist="workstation-manager" name="/usr/share/eole/saltstack/pillar/eole-workstation.sls" rm='True' />
            <file filelist="workstation-manager" name="/usr/share/eole/saltstack/pillar/ad.sls" rm='True' />
            <file filelist="workstation-manager" name="/usr/share/eole/saltstack/pillar/pam-mount.sls" rm='True' />

            <!-- Extract periodically Veyon AuthorizedUsergroups from LDAP -->
            <file filelist="workstation-manager" name="/etc/salt/master.d/ldap.conf" source="master-ldap.conf" />
            <file filelist="workstation-manager" name="/etc/salt/master.d/schedule-veyon.conf" />
            <file filelist="workstation-manager" name="/usr/share/eole/saltstack/schedule-tasks/veyon-extract-ldap-authorized-user-groups.sls" mkdir="True" rm='True' />
            <file filelist="workstation-manager-autoaccept" name="/etc/salt/master.d/autoaccept.conf" rm='True'/>

            <!--
https://dev-eole.ac-dijon.fr/issues/37246
Suivant les version de Scribe, salt n'utilise pas le même dossier pour stocker les clés des clients "pki_dir"
            -->
            <file filelist="workstation-manager" name="/etc/salt/master" source="master_salt.conf" />

            <service servicelist="workstation-manager">eole-workstation-manager</service>

            <service_access service='eole-workstation-manager'>
                <port>4505</port>
                <port>4506</port>
            </service_access>
        </container>
    </containers>

    <variables>
        <family name="services">
            <variable name="activer_workstation_manager" type="oui/non" description="Activer le service de gestion des postes clients">
                <value>oui</value>
            </variable>
        </family>

        <family name="Workstation" icon='desktop'>
            <variable name="eole_workstation_enable_join" type="oui/non" description="Activer la jonction automatique au domaine" mode="expert">
                <value>oui</value>
            </variable>
            <variable name="eole_workstation_autoaccept" type="oui/non" description="Accepter automatiquement le renouvellement d'un certificat SALT en ne se basant que sur l'ID du certificat (solution peu sécurisé)" mode="expert">
                <value>oui</value>
            </variable>
            <variable name="eole_workstation_enable_veyon" type="oui/non" description="Activer l’installation et la configuration de Veyon" mode="expert">
                <value>oui</value>
            </variable>

            <variable name="eole_workstation_veyon_authorized_user_groups" type="string" description="Filtres de groupes d’utilisateurs pouvant visualiser les postes" mode="expert" multi="True">
                <value>cn=Domain Admins</value>
                <value>cn=professeurs*</value>
            </variable>
            <variable name="veyon_allow_adding_hidden_locations" type="oui/non" description="Pouvoir prendre le contrôle de postes dans la salle et visualiser les postes non listés" mode="expert">
                <value>non</value>
            </variable>
            <variable name="veyon_computer_organization_type" description="Déduire la salle des ordinateurs via" mandatory="True"/>
            <variable name="eole_workstation_enable_firefox" type="oui/non" description="Activer la configuration de Firefox" mode="expert">
                <value>non</value>
            </variable>
        </family>
    </variables>

    <constraints>
        <check name='valid_enum' target='veyon_computer_organization_type'>
            <param>['attribut_location','ou']</param>
        </check>
        <condition name='disabled_if_in' source='activer_workstation_manager'>
            <param>non</param>
            <target type='servicelist'>workstation-manager</target>
            <target type='filelist'>workstation-manager</target>
        </condition>
        <condition name='disabled_if_in' source='eole_workstation_enable_join'>
            <param>oui</param>
            <target>eole_workstation_autoaccept</target>
        </condition>
        <condition name='disabled_if_in' source='eole_workstation_autoaccept'>
            <param>non</param>
            <target type='filelist'>workstation-manager-autoaccept</target>
        </condition>
    </constraints>

    <help>
        <variable name="activer_workstation_manager">Le service de gestion des postes clients utilise SaltStack</variable>
        <family name="Workstation">Gestion des postes clients</family>
        <variable name="eole_workstation_enable_veyon">Veyon est un logiciel libre qui permet de surveiller, contrôler et administrer les postes à distance</variable>
        <variable name="eole_workstation_veyon_authorized_user_groups">Les filtres doivent être de la forme "ATTRIBUT"="VALEUR"</variable>
        <variable name="veyon_computer_organization_type">Pour retrouver les ordinateurs dans la même salle que son ordinateur, Veyon peut intérroger l'attribut location des ordinateurs ou lister les ordinateurs de la même OU</variable>
    </help>

</creole>
