PlayBook:
---
- hosts: cluster
tasks:
- name: script
script: /deeplogsd/inspect_host.sh
- name: find_remote_host_chk_result
find:
paths: /deeplogsd/onenode/
age: -10m
age_stamp: ctime
patterns: 'dailyport*'
register: logfile_name
- name: fetch_remote_host_chk_result
fetch:
src: "{{ item.path }}"
flat: yes
dest: /deeplogsd/allnode/
with_items: "{{ logfile_name.files }}"
- name: clean_old_chk_result
command: find /deeplogsd/allnode/ -mmin +15 -name dailyport* -exec rm -rf {} \;
run_once: yes
- name: assemble
assemble:
src: /deeplogsd/allnode/
dest: /deeplogsd/report/DailyReport-Kcluster.txt
remote_src: no
run_once: yes
- name: Sending mail
mail:
host: smtp.163.com
port: 25
username: xxxxxxxxx@163.com
password: xxxxxx
from: xxxxxxx@163.com
to: xxxxxx@qq.com, xxxxxxx@qq.com
subject: 邮件主题
attach: /deeplogsd/report/DailyReport-Kcluster.txt
body: 邮件正文
run_once: yes
模块含义:
- hosts: /etc/assible/hosts 中 hosts/groups
- script: 在远程主机上执行/deeplogsd/inspect_host.sh
- find: 查看远程主机/deeplogsd/onenode//目录中 10 分钟以前的文件
- fetch: 从远程主机上拷贝文件到/deeplogsd/allnode/目录中
- command: 查找/deeplogsd/allnode/目录中 15 分钟以前的文件并删除
- assemble: 将/deeplogsd/allnode/目录中的文件合并到/deeplogsd/report/DailyReport-Kcluster.txt 文件中
- mail: 通过 smtp 服务器发送结果出去
欢迎来到这里!
我们正在构建一个小众社区,大家在这里相互信任,以平等 • 自由 • 奔放的价值观进行分享交流。最终,希望大家能够找到与自己志同道合的伙伴,共同成长。
注册 关于