---
- name: Install cups and python libs
  apt:
    name:
      - cups
      - python3-ldap
    state: latest

- name: Disable cups printer browsing
  lineinfile:
    dest: /etc/cups/cupsd.conf
    regexp: '^(Browsing ).*'
    line: '\1No'
    backrefs: yes

- name: Configure pam_mount sysvol mount
  blockinfile:
    dest: /etc/security/pam_mount.conf.xml
    marker: "<!-- {mark} ANSIBLE MANAGED BLOCK (SysVol) -->"
    block: |
      <volume
        fstype="cifs"
        server="{{ smb_server }}"
        path="sysvol/"
        mountpoint="/srv/samba/%(USER)/sysvol"
        options="sec=krb5i,cruid=%(USERUID),user=%(USER),gid=1010,file_mode=0770,dir_mode=0770,mfsymlinks"
        ><not><or><user>root</user><user>ansible</user><user>Debian-gdm</user><user>sddm</user><user>virti</user></or></not>
      </volume>
    insertafter: "<!-- Volume definitions -->"

- name: Create /etc/linuxmuster-linuxclient7 Directory
  file:
    path: /etc/linuxmuster-linuxclient7
    state: directory
    mode: 0755

- name: install linuxmuster-linuxclient network.conf
  template:
    src: network.conf.j2
    dest: /etc/linuxmuster-linuxclient7/network.conf
    mode: 0644

- name: install linuxmuster-linuxclient python libs
  copy :
    src: linuxmusterLinuxclient7
    dest: /usr/lib/python3/dist-packages

- name: Create /usr/share/linuxmuster-linuxclient7/scripts Directory
  file:
    path: /usr/share/linuxmuster-linuxclient7/scripts
    state: directory
    mode: 0755

- name: install linuxmuster-scripts
  copy:
    src: scripts/sudoTools
    dest: /usr/share/linuxmuster-linuxclient7/scripts/
    mode: 0755

- name: install lmn-sudotools
  copy:
    src: 90-lmn-sudotools
    dest: /etc/sudoers.d/
    mode: 0660
    owner: root
    group: root

- name: install onLogin script
  copy :
    src: onLogin
    dest: /usr/local/bin/
    mode: 0755
    owner: root
    group: root

- name: install lmn-printer.sh in /etc/profile.d/
  copy:
    src: lmn-printer.sh
    dest: /etc/profile.d/
    mode: 0644
    owner: root
    group: root

- name: Provide service and timer for remove all printers on boot
  copy:
    src: "{{ item }}"
    dest: "/etc/systemd/system/{{ item }}"
    mode: 0644
  with_items:
    - rmlpr.service
    - rmlpr.timer

- name: enable rmlpr.timer
  systemd:
    name: rmlpr.timer
    enabled: true

