wait_for -> check for no moving logs, and skip string "Consul Health Check"

hi,

at the moment we use something like:

`

      - name: wait for possible traffic
        shell: "tail -n 5 /var/log/nginx/ssl-*access*log"
        register: watch_nginx_log
        retries: 30
        delay: 5
        until: "watch_nginx_log.stdout_lines | reject('search','nginx_status') | list | count == 0"
        when: zero_weight is defined

`

The goal is to search, if there is any string in the Nginx log file, but drop/skip the nginx_status, which comes from a Consul health check. So, if there is any other string, “wait_for” should “wait” and counting, until there is no other lines and then do the next part. An example logfile with no other strings looks like:

`

172.16.1.4 - - [29/Aug/2019:08:43:22 +0200] “GET /nginx_status HTTP/1.1” 200 111 “-” “Consul Health Check”
172.16.1.4 - - [29/Aug/2019:08:43:42 +0200] “GET /nginx_status HTTP/1.1” 200 111 “-” “Consul Health Check”
172.16.1.4 - - [29/Aug/2019:08:44:02 +0200] “GET /nginx_status HTTP/1.1” 200 111 “-” “Consul Health Check”
172.16.1.4 - - [29/Aug/2019:08:44:22 +0200] “GET /nginx_status HTTP/1.1” 200 111 “-” “Consul Health Check”
172.16.1.4 - - [29/Aug/2019:08:44:42 +0200] “GET /nginx_status HTTP/1.1” 200 111 “-” “Consul Health Check”
172.16.1.4 - - [29/Aug/2019:08:45:02 +0200] “GET /nginx_status HTTP/1.1” 200 111 “-” “Consul Health Check”

`

I want to replace it with a more Ansible way. I found, that there is a “wait_for” with search_regex. Is it possible ? I have to do the same with a squid access.log :slight_smile:

cu denny