I tried to start JBoss service via Ansible and use wai_for module to wait till the JBoss started. However, the JBoss service started, however, the wait_for still progressing until there is time out then hit error. Below is my code
- name: Get the contents of the last line from log
command: "tail -n 1 /home/nityo/application.log"
register: tail_output
- name: Create a variable with a meaningful name, just for clarity
set_fact:
last_line_of_the_log_file: "{{ tail_output.stdout }}"
- name: JBoss service starting
service:
name: "jboss.service"
state: started
become: yes
become_user: root
- name:Wait for server started
wait_for:
path: "//home/nityo/application.log"
search_regex: "{{ last_line_of_the_log_file }}\r(.*\r)*.*JBoss EAP.*started.*"
timeout: 600
Besides that can we combine all thsi into 1 task rrather than having multiple task
Sample output log
2020-10-11 01:13:42,009 INFO [org.jboss.as] JBoss EAP 7.2 (WildFly Core) running in 100281ms - service to be running
2020-10-11 01:13:42,005 INFO [org.jboss.as] processing data
2020-10-11 01:13:43,009 INFO [org.jboss.as] JBoss EAP 7.2 (WildFly Core) stopped in 100281ms - service to be stopped
-
-
-
-
-
-
-
2020-10-11 01:13:48,009 INFO [org.jboss.as] JBoss EAP 7.2 (WildFly Core) started in 100281ms - service to be started