Ansible-Playbook: count flag is not updating the line count when the file size changes

184 Views Asked by At

I am reading a yaml file, and trying to count the number of lines. It works for the file originally created, but when I add/remove entries in/from the yaml file, the line count sticks to what it was originally.

   - name: reading golden output
     shell:
      cat "{{ file }}"
     register: golden_output
   - set_fact:
      len1="{{ golden_output | count }}"
   - debug: var=len1

How do I make this task update the count, and where did I possibly go wrong?

1

There are 1 best solutions below

0
On

This worked fine for me: len1="{{ golden_output.stdout_lines | count }}"