tail_grep – Tail a logfile until a regex matcher is found or a timeout triggers
Note
This module is part of the middleware_automation.common collection.
It is not included in ansible-core
.
To check whether it is installed, run ansible-galaxy collection list
.
To install it, use: ansible-galaxy collection install middleware_automation.common
.
To use it in a playbook, specify: middleware_automation.common.tail_grep
.
Synopsis
This module is used to follow some application logfile and return successfully when a search string or regex is found; otherwise fail after a timeout.
Parameters
Parameter |
Comments |
---|---|
How many seconds to wait after opening the file before starting to look for the regex. Default: |
|
Backwards from end of file, lines preceeding this string will not be considered for matching regex. By default, the whole file is read. If `$` is used, start from the first line written after the file is opened. Default: |
|
The file on the remote system to tail. |
|
The string or regular expression to search in the file. |
|
After how many seconds to exit unsuccessfully without having found the search regex. Default: |
Attributes
Attribute |
Support |
Description |
---|---|---|
Support: none |
Can run in check_mode and return changed status prediction without modifying target, if not supported the action will be skipped. |
|
Support: none |
Will return details on what has changed (or possibly needs changing in check_mode), when in diff mode |
|
Platform: posix |
Target OS/families that can be operated against |
Examples
- name: Tail activemq log until the successful start status code is found
ansible.builtin.tail_grep:
path: /var/log/activemq/artemis.log
regex: AMQ220010
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
---|---|
The full string that was matched by the search regex Returned: success Sample: |
|
Actual path of file opened Returned: success Sample: |