What I am doing : I am reading a file using shell module and get the unique error code from the entire file , the result of this is result.out I am local file file1 which have list of known error code Now i want to check if any value of result.out match in file1 then restart the service
I can achive this using following command in shell
hosts: tsm_client
remote_user: root
vars_file: error_code
tasks:
- name: Read error file code
shell: "cat /tsm_error/dsmerrorlog.log |cut -d ' ' -f 5 |sort | uniq | egrep 101|102|103|104 | cat "
register: output
ignore_errors: true
#- debug: var=output.stdout_lines
- name: Restart Cron Service
service:
name: crond
state: restarted
when: output.stdout != ""
- debug: msg='Error Code does not macth Please cont to Backup'
when: output.stdout == ""
Could you please help me use ansible module instead of shell with grep