Политика монтирования шары

Костюков Владимир

Команда форума
Админ
Регистрация
04.03.23
Сообщения
386
Реакции
62
Код:
{% set node = salt['grains.get']('nodename') %}
{% set gpo_name = 'rbta_ldap_custom_gp_host_pam_mount' %}
{% set gpo = salt['pillar.get']('aldpro-hosts:' + node + ':' + gpo_name) %}
{% if gpo %}
install_packages:
  pkg.installed:
    - pkgs:
      - cifs-utils
      - libpam-mount
/etc/security/pam_mount.conf.xml:
  file.managed:
    - makedirs: True
    - contents: |
        <pam_mount>
            <debug enable="0" />
            <cifsmount>mount.cifs //%(SERVER)/%(VOLUME) %(MNTPT) -o %(OPTIONS) </cifsmount>
{%- for args in gpo %}
{%- set server = args.get('server') %}
{%- set resource = args.get('resource') %}
            <volume
                fstype="cifs"
                server="{{ server }}"
                path="{{ resource }}"
                mountpoint="/mnt/%(DOMAIN_USER)/{{ resource }}"
                uid="1402000000-2000000000"
                options="user=%(DOMAIN_USER),cruid=%(DOMAIN_USER),sec=krb5i,file_mode=0666,dir_mode=0777"
            />
{%- endfor %}
            <mntoptions allow="nosuid,nodev,loop,encryption,fsck,nonempty,allow_root,allow_other" />
            <mntoptions require="nosuid,nodev" />
            <logout wait="50000" hup="1" term="1" kill="1" />
            <mkmountpoint enable="1" remove="true" />
        </pam_mount>
{% endif %}

Уникальный идентификатор pam_mount
uid="1402000000-2000000000" Заменить на свои

msg5992624950-150357.jpg



Код:
{% if user is not defined %}
  {% set user = salt['pillar.get']("user") %}
{% endif %}
{% if salt['pillar.get']('aldpro-users:'+ user) is defined %}
  {% set homedir = salt['user.info'](user).home %}
  {% set gpo_name = 'rbta_ldap_custom_gp_user_shares_to_desktop' %}
  {% set gpo = salt['pillar.get']('aldpro-users:'+ user +':'+ gpo_name) %}
  {% if gpo %}
    {% set listres = [] %}
    {% set name = gpo.get('name') %}
    {% set name_ru = gpo.get('name_ru') %}
{{ homedir }}/Desktops/Desktop1/{{ name }}:
  file.directory:
    - user: {{ user }}
{{ homedir }}/Desktops/Desktop1/{{ name }}/.directory:
  file.managed:
    - user: {{ user }}
    - mode: 644
    - makedirs: True
    - contents: |
        [Desktop Entry]
        Name={{ name }}
        Name[ru]={{ name_ru }}
        Type=Directory
        Icon=network-local
    {% set dirs = salt['file.find']("/mnt/"+ user, type='d', mindepth=1, maxdepth=1) %}
    {% if dirs %}
      {% for dir in dirs %}
        {% set dirname = salt['file.basename'](dir) %}
      {% if dirname not in listres %}
        {% set listres = listres.append(dirname) %}
      {% endif %}
{{ homedir }}/Desktops/Desktop1/{{ name }}/{{ dirname }}:
  file.symlink:
    - target: {{ dir }}
      {% endfor %}
    {% endif %}
    {% set listfiles = salt['file.find'](homedir +'/Desktops/Desktop1/'+ name, mindepth=1, maxdepth=1) %}
    {% for file in listfiles %}
      {% if salt['file.basename'](file) not in listres %}
        {% if salt['file.basename'](file) != '.directory'%}
remove_{{ file }}:
  cmd.run:
    - name: rm -r "{{ file }}"
        {% endif %}
      {% endif %}
    {% endfor %}
  {% endif %}
{% endif %}

Уникальный идентификатор shares_to_desktop

msg5992624950-150363.jpg
 

Вложения

  • msg5992624950-150362.jpg
    msg5992624950-150362.jpg
    52.6 KB · Просмотры: 188
  • msg5992624950-150356.jpg
    msg5992624950-150356.jpg
    47 KB · Просмотры: 191
Последнее редактирование:
Назад
Сверху Снизу