---
- name: Ensure nomad user and plugin directory exist
  hosts: nomad_clients
  become: yes
  tasks:
    - name: Ensure nomad group exists
      group:
        name: nomad
        state: present

    - name: Ensure nomad user exists
      user:
        name: nomad
        group: nomad
        shell: /usr/sbin/nologin
        system: yes
        create_home: no

    - name: Ensure plugin directory exists with correct ownership
      file:
        path: /opt/nomad/data/plugins
        state: directory
        owner: nomad
        group: nomad
        mode: '0755'