For example, given the file and the playbook
shell> cat test.txt
XX
shell> cat playbook.yml
- hosts: localhost
tasks:
- ansible.builtin.command:
cmd: cat test.txt
register: sync_status
until: sync_status.stdout == 'SSUS'
the task will fail
TASK [ansible.builtin.command] ********************************************
FAILED - RETRYING: ansible.builtin.command (3 retries left).
FAILED - RETRYING: ansible.builtin.command (2 retries left).
FAILED - RETRYING: ansible.builtin.command (1 retries left).
fatal: [localhost]: FAILED! => changed=true
attempts: 3
cmd:
- cat
- test.txt
delta: '0:00:00.003479'
end: '2021-06-16 07:27:19.927499'
rc: 0
start: '2021-06-16 07:27:19.924020'
stderr: ''
stderr_lines: <omitted>
stdout: XX
stdout_lines: <omitted>
But, if you insert the string "SSUS" into the file before or during the testing the task will succeed, e.g.
TASK [ansible.builtin.command] ********************************************
FAILED - RETRYING: ansible.builtin.command (3 retries left).
FAILED - RETRYING: ansible.builtin.command (2 retries left).
changed: [localhost]
Fit the parameters to your needs.
Q: "If the output is multiple lines, I will need to use stdout_lines."
A: Test the presence of the string in the list, e.g.
- ansible.builtin.command:
cmd: cat test.txt
register: sync_status
until: "'SSUS' in sync_status.stdout_lines"