wait_for module - document self match avoidance (#85251)

When using static string to search system log, avoid matching self execution
logged by Ansible by default.

Co-authored-by: Abhijeet Kasurde <akasurde@redhat.com>
pull/85321/head
Brian Coca 6 months ago committed by GitHub
parent 02c21742a3
commit 137036e96f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -76,6 +76,8 @@ options:
description:
- Can be used to match a string in either a file or a socket connection.
- Defaults to a multiline regex.
- When inspecting a system log file and a static string, remember that Ansible by default logs its own actions there;
see the notes and examples for information.
type: str
version_added: "1.4"
exclude_hosts:
@ -105,13 +107,13 @@ attributes:
platform:
platforms: posix
notes:
- The ability to use search_regex with a port connection was added in Ansible 1.7.
- Prior to Ansible 2.4, testing for the absence of a directory or UNIX socket did not work correctly.
- Prior to Ansible 2.4, testing for the presence of a file did not work correctly if the remote user did not have read access to that file.
- Under some circumstances when using mandatory access control, a path may always be treated as being absent even if it exists, but
can't be modified or created by the remote user either.
- When waiting for a path, symbolic links will be followed. Many other modules that manipulate files do not follow symbolic links,
so operations on the path using other modules may not work exactly as expected.
- When searching a static string within a system log file, it is important to account for potential self-matching against log entries
generated by the Ansible modules. To prevent this, add a regular expression construct into the search string. For example, to match
a literal string 'this thing', one could use a regular expression like 'this t[h]ing'.
seealso:
- module: ansible.builtin.wait_for_connection
- module: ansible.windows.win_wait_for
@ -156,6 +158,11 @@ EXAMPLES = r"""
path: /tmp/foo
search_regex: completed
- name: Wait until the string "tomcat up" is in syslog, use regex character set to avoid self match
ansible.builtin.wait_for:
path: /var/log/syslog
search_regex: 'tomcat [u]p'
- name: Wait until regex pattern matches in the file /tmp/foo and print the matched group
ansible.builtin.wait_for:
path: /tmp/foo

Loading…
Cancel
Save