我有以下剧本,它从vcenter_inventory_vmware.yml
清单文件中收集有关 Windows VM 的信息并ansible.windows.win_updates
正确执行模块。我试图触发一个处理程序,当我的 ansible-playbook 命令中的 3 个服务器中的任何一个遇到任何类型的故障时,该处理程序都会发送电子邮件通知我。处理程序从未触发过。有人能告诉我我的代码需要修改什么吗?
ANSIBLE 命令:
ansible-playbook download_and_install_windows_updates.yml -l server1:server2:server3
下载并安装windows更新.yml
- hosts: windows
gather_facts: false
tasks:
- name: Installing missing updates
ansible.windows.win_updates:
category_names:
- Application
- Connectors
- Critical Updates
- Definition Updates
- Developer Kits
- Feature Packs
- Guidance
- Security Updates
- Service Packs
- Tools
- Update Rollups
- Updates
- Upgrade
reject_list:
- Security Intelligence Update for Microsoft Defender Antivirus
- Update for Microsoft Defender Antivirus antimalware platform
- Windows Malicious Software Removal Tool x64
state: installed
reboot: true
reboot_timeout: 6300
register: updates
notify: Email
when: ansible_failed_result.rc != 0
handlers:
- name: Email
mail:
host: <my company smtp server>
port: 25
to: (my email address>
subject: "Playbook Failed"
body: "Your playbook has failed. Please check the logs."
delegate_to: localhost