---
- name: Include variables based on the operating system
  include_vars: "{{ ansible_os_family }}.yml"

# @action Ensures OpenSSH Server is installed
# Installs OpenSSH Server on Archlinux, CentOS, Debian, Fedora, macOS, Ubuntu, and Windows
# @action Ensures OpenSSH Server is configured
# Installs Fail2ban on Archlinux, CentOS, Debian, Fedora, macOS and Ubuntu
# @action Ensures OpenSSH Server is configured
# Configures SSHD settings
# @action Ensures OpenSSH Server is configured
# Starts sshd service
# @action Ensures OpenSSH Server is configured
# Starts fail2ban service on Linux and MacOS Systems
- name: Include tasks based on the operating system
  become: true
  become_method: "{{ 'runas' if ansible_os_family == 'Windows' else 'sudo' }}"
  become_user: "{{ ansible_user if ansible_os_family == 'Windows' else omit }}"
  block:
    - include_tasks: "install-{{ ansible_os_family }}.yml"

# @action Ensures OpenSSH Client is configured
# Sets up SSH client config
# @action Ensures OpenSSH Client is configured
# Sets up known_hosts
# @action Ensures OpenSSH Client is configured
# Secures the private key
- name: Run tasks for each specified user
  include_tasks: user-continue.yml
  loop: "{{ user_configs }}"
  loop_control:
    label: "{{ user.username }}"
    loop_var: user
