---
- name: Prepare
  hosts: all
  gather_facts: false
  pre_tasks:
    - name: include vars
      include_vars: "{{ role_path }}/../ansible_vaults/molecule_prepare/{{ item }}"
      loop:
        - "prepare.vault"
    - name: Install python for Ansible
      raw: test -e /usr/bin/python || (apt -y update && apt install -y python-minimal)
      become: true
      changed_when: false
    - name: create users (as deployed in production)
      user:
        name: "{{ item.name }}"
        uid: "{{ item.uid }}"
        create_home: "yes"
        shell: "/bin/bash"
      loop: "{{ vault_molecule_users | flatten(levels=1) }}"
      become: true
    - name: add nonfree repos
      apt_repository:
        repo: "deb http://ftp2.de.debian.org/debian/ buster main non-free contrib"
        state: present
        update-cache: "yes"
      become: true
    - name: Install required packages
      apt:
        name: [
          'aptitude',
          'gpg',
          'less',
          'libuser'
        ]
        state: present
      become: true
  roles:
    - {role: ansible_lza_install_common, become: true}
    - {role: ansible_lza_server_hardening, become: true}
