Hi, I am fairly new to Ansible, so would appreciate some help.
I am trying to look in a .csv or .txt file. I need to email it when the
entry '0 rows' does not appear. Basically the file has been produced by a
software vendor, and a result of '0 rows' confirms no errors. Any other
result would mean there are errors.
I have tried the following code, after not having much success with
'lineinfile'. However, the play emails me whether it has found the text or
not. I did try a debug argument on it to view the output and noted that
'json' was full off characters similar to:
"presence.stdout": "ÿþJ\u0000o\u0000b\u0000
\u0000'\u0000P\u0000a\u0000u\u0000s\u0000e\u0000 \u0000a\u0000n\u0000d\u0000
However, the 'standard out' does contain the information I require:
(0 rows(s) affected)
Any suggestions are much appreciated. Thanks.
- hosts: localhost
tasks:
- name: read the fileout file
shell: cat /directory/directory/fileout.txt
register: presence
- name: a task that only happens if the entry exists
when: "'0 rows' not in presence"
mail:
host: localhost
port: 25
subject: "Ansible Task. Checking for retained information Completed"
body: "This email is confirmation that this task completed as
designed"
from: emailaddress
to: emailaddress
attach: /directory/directory/fileout.txt
charset: utf8
ignore_errors: true
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/1a428317-317f-4481-bc78-770e0db867d5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.