Hello,
I have a mail task that sends some log files and I would like to make it more clear what process generated them:
- name: send logs
mail:
host: smpthost
port: 25
body: “Please review the attached logs from the process. Process executed on {{ ansible_hostname}} triggered by ansible on {{ ansible_control_machine }}”
attach: log1.txt log2.txt
Of course variable {{ ansible_control_machine }} does not exist. How should I get the name of the control machine. One way I found is to use {{ lookup(‘env’,‘HOSTNAME’) }}. Is there another way without relying on environment variables? What if I want to access a random fact of the control machine?
Thank you very much for your response!
Regards
Rambius