<commit_before>---

# Main task file for account-management role

- name: Load the OS specific varibles
  include_vars: "{{ role_path }}/vars/{{ ansible_os_family }}.yml"


# Install required packages
- include: install_debian.yml
  tags:
    - install
    - user-management
  when: ansible_os_family == "Debian"


- include: create_accounts.yml
  tags:
    - config
    - user-management
    - sudo


- include: configure_sudo.yml
  tags:
    - config
    - user-management
    - sudo


- name  : Create user authorized-keys file
  authorized_key :
    user  : "{{ item.0.name }}"
    key   : "{{ lookup('file', {{ item.1.filename }}) }}"
    state : "{{ item.1.state | default('present') }}"
    key_options : "{{ item.1.key_options | default('') }}"
    exclusive   : "{{ item.0.exclusive_public_keys | default(True) }}"
  with_subelements:
    - "{{ account_management_users }}"
    - "authorized_public_keys"


- name       : Get home for each users
  shell      : "getent passwd {{ item.name }} | cut -d: -f6"
  register   : home_users
  with_items : "{{ account_management_users }}"


- name  : Change permissions for user home directory
  file  :
    dest    : "{{ item.1.stdout }}"
    group   : "{{ item.0.name }}"
    owner   : "{{ item.0.name }}"
    mode    : "{{ item.0.home_mode | default('0700') }}"
  with_together:
    - "{{ account_management_users }}"
    - "{{ home_users.results }}"
  when :
    - "{{ item.0.name }} == 'present'"<commit_msg>Fix get home if user state is absent<commit_after>---

# Main task file for account-management role

- name: Load the OS specific varibles
  include_vars: "{{ role_path }}/vars/{{ ansible_os_family }}.yml"


# Install required packages
- include: install_debian.yml
  tags:
    - install
    - user-management
  when: ansible_os_family == "Debian"


- include: create_accounts.yml
  tags:
    - config
    - user-management
    - sudo


- include: configure_sudo.yml
  tags:
    - config
    - user-management
    - sudo


- name  : Create user authorized-keys file
  authorized_key :
    user  : "{{ item.0.name }}"
    key   : "{{ lookup('file', {{ item.1.filename }}) }}"
    state : "{{ item.1.state | default('present') }}"
    key_options : "{{ item.1.key_options | default('') }}"
    exclusive   : "{{ item.0.exclusive_public_keys | default(True) }}"
  with_subelements:
    - "{{ account_management_users }}"
    - "authorized_public_keys"


- name       : Get home for each users
  shell      : "getent passwd {{ item.name }} | cut -d: -f6"
  register   : home_users
  with_items : "{{ account_management_users }}"
  when :
    - "{{ item.0.name }} == 'present'"


- name  : Change permissions for user home directory
  file  :
    dest    : "{{ item.1.stdout }}"
    group   : "{{ item.0.name }}"
    owner   : "{{ item.0.name }}"
    mode    : "{{ item.0.home_mode | default('0700') }}"
  with_together:
    - "{{ account_management_users }}"
    - "{{ home_users.results }}"
  when :
    - "{{ item.0.name }} == 'present'"
{'fraction_non_alphanumeric': 0.1587195731910637, 'fraction_numerical': 0.010336778926308769, 'mean_word_length': 2.6363636363636362, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1595223', 'n_tokens_mistral': 1045, 'n_tokens_neox': 1010, 'n_words': 217}