[英]Ansible: How to mail attachments with files from remote hosts
我知道如何通過電子郵件發送附件,但這是假設文件位於ansible控制器上。
一天中多次要求我將兩台不同服務器上的日志文件發送給某些人。 我想經營一本能做到這一點的劇本。
這是我到目前為止的內容:
---
- hosts: server1:server2
remote_user: joe
become: yes
become_method: sudo
tasks:
- name: Sending error and debug logs to Bob, Suzie
mail:
host: localhost
port: 25
subject: Logs from {{ ansible_hostname }}
body: Here are the logs that you have requested
from: webuser <webuser@something.com>
to:
- Bob Smith <bob@something.com>
- Suzie Owens <suzie@something.com>
attach:
- /var/www/stg.something.com/logs/debug.log
- /var/www/stg.something.com/logs/error.log
headers:
- Reply-To=webuser@something.com
charset: us-ascii
become: yes
become_user: webuser
become_method: sudo
delegate_to: localhost
我以為我的問題是proxy_to。 我的問題是包括server1和server2的格式是什么?
請使用proxy_to:“ {{庫存主機名}}”
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.