---
-
  name: "Creating the group {{ service_group }}"
  ansible.builtin.group:
    name: "{{ service_group }}"
    state: present

-
  name: "Adding user to groups: {{ service_user }}"
  ansible.builtin.user:
    name: "{{ service_user }}"
    shell: /bin/bash
    groups: "{{ service_group }},sudo"
    home: "{{ service_home_dir }}"

-
  name: "Adding user to sudoers: {{ service_user }}"
  ansible.builtin.lineinfile:
    path: "/etc/sudoers.d/{{ service_user }}"
    line: "{{ service_user }} ALL=(ALL:ALL) NOPASSWD:ALL"
    mode: '0644'
    create: true

-
  name: "Adding soft nofile limits to in limits.conf for user: {{ service_user }}"
  community.general.pam_limits:
    domain: "{{ service_user }}"
    limit_type: soft
    limit_item: nofile
    value: "{{ service_user_soft_limit }}"

-
  name: "Adding hard nofile limits to in limits.conf for user: {{ service_user }} "
  community.general.pam_limits:
    domain: "{{ service_user }}"
    limit_type: hard
    limit_item: nofile
    value: "{{ service_user_hard_limit }}"

-
  name: "Creating Installation Directories"
  ansible.builtin.file:
    path: "{{ item }}"
    state: directory
    owner: "{{ service_user }}"
    mode: '0755'
  with_items:
    - "{{ service_home_dir }}/.ansible/tmp"
