---
- block:
  - name: Create tss group
    group:
      name: tss

  - name: Add zoox user to tss group
    user:
      name: zoox
      groups: tss
      append: yes

  - name: Install udev rule to set tss group for TPM devices
    copy:
      src: 10-tss.rules
      dest: /etc/udev/rules.d/10-tss.rules
      owner: root
      group: root
      mode: '644'
    notify:
      - Reload udev rules
      - Trigger udev TPM rules

  # All of these packages come from the "Product Security" apt repo on Artifactory
  - name: Install TPM tools from apt
    apt:
      name:
        - curl-7.71.0
        - openssl-1.1.1g
        - tpm2-tools
        - tpm2-tss
        - tpm2-tss-engine
      cache_valid_time: "{{ apt_cache_valid_time }}"

  - name: Add TPM bin directories to PATH
    copy:
      src: tss.bash
      dest: /home/zoox/.bashrc.d/tss.bash
      owner: zoox
      group: zoox
      mode: '755'

  become: yes
  when: "zoox_compute_version is version('3.5', '>=')"
