---
# @action Ensures common configuration settings are applied
# Ensures ansible_user has password set
- name: Ensure ansible_user has password set
  user:
    name: "{{ ansible_user | default(lookup('env', 'USER')) }}"
    password: "{{ ansible_password | password_hash('sha512', password_salt) }}"

- name: Set hostname
  hostname:
    name: "{{ hostname }}"
  when: hostname is defined

# @action Ensures common configuration settings are applied
# Sets Timezone
- name: Set time zone
  timezone:
    name: "{{ timezone }}"

- name: Set ANSIBLE_PLAYBOOK_USER name environment variable
  lineinfile:
    path: /etc/environment
    regex: "^ANSIBLE_PLAYBOOK_USER="
    line: "ANSIBLE_PLAYBOOK_USER={{ ansible_user | default(lookup('env', 'USER')) }}"

# @action Ensures common configuration settings are applied
# Sets MOTD on Linux and MacOS Systems
- name: Set MOTD
  copy:
    src: motd
    dest: /etc/motd
    owner: root
    mode: 0644

- name: Ensure base pip packages are installed
  pip:
    name: "{{ pip_base_packages }}"
    state: present

# TODO: Convert the above commands to Mac OS X and add to setup-Darwin.yml

- name: Customize GRUB
  include_tasks: linux/grub.yml

# @action Ensures common configuration settings are applied
# Configures Plymouth theme
- name: Customize boot loading image (Plymouth)
  include_tasks: linux/plymouth.yml

- name: Configure swap
  include_tasks: linux/swap.yml

# @action Ensures common configuration settings are applied
# Configures Autologin for various Desktop Managers on Linux Systems
- name: Ensure auto-login is enabled
  include_tasks: linux/autologin-enable.yml
  when: autologin_enabled

- name: Ensure auto-login is disabled
  include_tasks: linux/autologin-disable.yml
  when: not autologin_enabled
