How i can match a text form a log to make the wait for task continue

16 views
Skip to first unread message

Mario Gamboa

unread,
May 23, 2016, 9:05:34 AM5/23/16
to Ansible Project
Ok i have a software that always when restart needs to insert password is really pain in the ass so i trying to automate

This is my playbook

# tasks file for terminal

- name: restart terminal   <--this is working fine
  service:  name=terminal state=restarted



Ok here is the problem after restart the sever i need to see in the logs of the application and i found the following


[2016-05-22 04:32:19.581] INFO  [Terminal-PasswordCallback] + more stuff in this line but i would like just to trigger the next task when found the content into the  brackets because info is really common after restart the log stop specific to get the password 

as i said befor the  message that my software is waiting for the password so i create the following regex like waiting for this result to continue with the next task but is no working at all , i don't know if I'm doing correctly  or something is missing


- name: service ready for password
  wait_for: path=/var/point/terminal/logs/terminal.log   search_regex="*INFO [Terminal-PasswordCallback]


if the result is ok now i need to execute another program to ingest the password

i create the following task for it

- name: execute terminalpasswd
  expect:
       command: /opt/terminal/terminalpasswd
       response:
         Please enter password for terminal:"te2331"


when i run the program is give me a prompt that said Please enter password for terminal  in this case i don't sure if this is possible with the expect or no to ingest the password when the prompt is coming, any suggestions really appreciate

Thank you

Reply all
Reply to author
Forward
0 new messages