# SPDX-License-Identifier: MIT
---
- name: Check if user exists
  command: id "{{ __test_uname }}"
  changed_when: false

- name: Check if password is configured
  changed_when: false
  shell: |
    set -eu
    if set -o | grep -q pipefail; then
      set -o pipefail  # no pipefail on debian, some ubuntu
    fi
    sasldblistusers2 -f /etc/pcp/passwd.db | grep -wq "{{ __test_uname }}"

# yamllint disable rule:line-length
- name: Check if a client can access metrics
  command: pminfo -f -h "pcp://127.0.0.1?username={{ __test_uname }}&password={{ __test_pswd }}" disk.dev.read
  changed_when: false
# yamllint enable rule:line-length
