Forum Discussion
RiverFish
Jan 11, 2022Altostratus
Well I found one way to do it. Instead of counting the occurrence of a specific string/word in the output, you can just count the length of the output. The length of two local user accounts is 6. So if someone tried to secretly create another user account the length would be greater than 6.
- name: local users
bigip_device_info:
gather_subset:
- users
provider: "{{ providerA }}"
register: user_output
- name: count the length of user_output.users
debug:
msg: "User-ouput.users length is: {{ user_output.users | length }}"
failed_when: user_output.users|length > 2