I would like to count the number of lines in a file with playbook, but the playbook should run remotely. It should be the equivalent of the linux command:
cat /etc/passwd |wc -l
Now I use this as workaround:
- name: Count number of users
shell: 'cat /etc/passwd |wc -l'
register: usercount
- name: Write the user count
debug:
msg: "{{ usercount.stdout }}"
but it will be nice if it should work with an Ansible builtin command.