---
- name: configure second network interface first
  tags: windows_network
  become: true
  ansible.builtin.template:
    src: templates/windows-network-interface.j2
    dest: /etc/network/interfaces.d/windows-network-interface

- name: bring up windows network
  tags: windows_network
  become: true
  ansible.builtin.command:
    cmd: "ifup {{ intwin_dev }}"

- name: update package sources
  tags: always
  become: true
  ansible.builtin.apt:
    update_cache: true

- name: Initial installation of perfact-file
  tags: always
  include_role:
    name: "{{ role_pffile_base }}"
  loop:
    # Absolute base instalation
    - general/disable-ipv6
    - general/ssh_host_keys
    - base_install
    - internalit/roles/user_perfact_useradmin
    - general/postfix
    - general/pfpyroutinecheck
    - general/sshd_config
    - general/pffirewall
    - general/pfbackup
    # monit is installed at last task in main playbook to avoid tickets
  loop_control:
    loop_var: role_pffile_base

- name: Setup perfact-file cronjob
  tags: perfact-file-cron
  become: true
  block:

    - name: Copy perfact-file cronjob
      ansible.builtin.template:
        src: templates/perfact-file.j2
        dest: /etc/cron.d/perfact-file
        mode: '0640'

    - name: Copy cron scripts
      ansible.builtin.template:
        src: "templates/{{ item }}.j2"
        dest: "/opt/perfact/custom/{{ item }}"
        mode: '0750'
      loop:
        - chmod_shares.sh
        - cleanup-win-shared.sh
        - fix_permissions_and_groups.sh
