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

2019-08-29 Thread Denny Fuchs
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 :-)

cu denny

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-devel/6ae49b6c-760e-41ea-8696-950f49503101%40googlegroups.com.


[ansible-devel] Execute module only, if package is installed

2019-06-18 Thread Denny Fuchs
hi,

I'm pretty new to Ansible (2.8 on Debian Stretch) and we have very simple 
playbook for upgrading packages, including run rkhunter / puppet / reboot 
etc. My problem is, that I do not have puppet an all nodes installed, so I 
tried:

---
#vim:ts=2:sts=2:sw=2:et
  - hosts: all
serial: 1
tasks:
  - name: Gather package facts
package_facts:
  manager: auto
  - name: Run puppet to apply last changes
puppet:

  - include_tasks: update_packages.yaml

  - include_tasks: reboot.yaml

  - name: "Puppet test result"
debug:
  msg: "Puppet found"
when: "'puppet' in ansible_facts.packages"

  - name: Run puppet to fix possible changes
puppet:

Problem is: on  nodes where "puppet" is installed, puppet is skipped and on 
nodes, where puppet is NOT install, the task fails. What I'm doing wrong ?

cu denny

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-devel/371fbf81-4bd3-4a9e-808c-14c3d78dd44f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.