---
# common test setup tasks
- name: Determine if system is ostree and set flag
  when: not __tlog_is_ostree is defined
  block:
    - name: Check if system is ostree
      stat:
        path: /run/ostree-booted
      register: __ostree_booted_stat

    - name: Set flag to indicate system is ostree
      set_fact:
        __tlog_is_ostree: "{{ __ostree_booted_stat.stat.exists }}"

- name: Skip test if not supported on ostree
  meta: end_host
  when:
    - __tlog_is_ostree | d(false)
    - __tlog_unsupported_ostree | d(false)

- name: Ensure sssd user/group exist in /etc files
  shell: |
    if ! grep -q ^sssd /etc/passwd && grep -q ^sssd /usr/lib/passwd; then
      grep ^sssd /usr/lib/passwd >> /etc/passwd
    fi
    if ! grep -q ^sssd /etc/group && grep -q ^sssd /usr/lib/group; then
      grep ^sssd /usr/lib/group >> /etc/group
    fi
  when: __tlog_is_ostree | d(false)
  changed_when: true
