---


- name: 'ACCOUNTS | SECURITY | Get home for each users'
  become: True
  shell: "getent passwd {{ item.name | quote }} | cut -d':' -f6"
  register: 'home_users'
  changed_when: False
  with_items: "{{ account_management_users }}"
  when:
    - "{{ (item.state | default('present')) == 'present' }}"


- name: 'ACCOUNTS | SECURITY | Get primary group for each users'
  become: True
  shell: "id -gn {{ item.name | quote }}"
  register: 'primary_group_users'
  changed_when: False
  with_items: "{{ account_management_users }}"
  when:
    - "{{ (item.state | default('present')) == 'present' }}"


- name: 'ACCOUNTS | SECURITY | Change permissions for user home directory'
  become: True
  file:
    dest: "{{ item.1.stdout }}"
    owner: "{{ item.0.name }}"
    group: "{{ item.0.home_group | default(item.2.stdout) }}"
    mode: "{{ item.0.home_mode | default(account_management_default_home_mode) }}"
  with_together:
    - "{{ account_management_users }}"
    - "{{ home_users.results }}"
    - "{{ primary_group_users.results }}"
  when:
    - "{{ account_management_users }}"
    - "{{ (item.0.state | default('present')) == 'present' }}"

---


- name: 'ACCOUNTS | SECURITY | Get home for each users'
  become: True
  shell: "getent passwd {{ item.name | quote }} | cut -d':' -f6"
  register: 'home_users'
  changed_when: False
  with_items: "{{ account_management_users }}"
  when: "(item.state | default('present')) == 'present'"


- name: 'ACCOUNTS | SECURITY | Get primary group for each users'
  become: True
  shell: "id -gn {{ item.name | quote }}"
  register: 'primary_group_users'
  changed_when: False
  with_items: "{{ account_management_users }}"
  when: "(item.state | default('present')) == 'present'"


- name: 'ACCOUNTS | SECURITY | Change permissions for user home directory'
  become: True
  file:
    dest: "{{ item.1.stdout }}"
    owner: "{{ item.0.name }}"
    group: "{{ item.0.home_group | default(item.2.stdout) }}"
    mode: "{{ item.0.home_mode | default(account_management_default_home_mode) }}"
  with_together:
    - "{{ account_management_users }}"
    - "{{ home_users.results }}"
    - "{{ primary_group_users.results }}"
  when:
    - "account_management_users"
    - "(item.0.state | default('present')) == 'present'"

Fix when statements with jinja2 templating delimiters
Fix when statements with jinja2 templating delimiters
