ansible - 从 ansible 发送电子邮件,邮件不是 Play 的有效属性
问题描述
我正在尝试遵循本教程:
https://www.infinitypp.com/ansible/email-notifications-with-examples
从中我构建了以下名为 test.yml 的剧本,其中包含以下代码:
---
- name: sending an email
hosts: localhost
tasks:
- name: send email
local_action: mail
subject="ansible sent this"
to="my name <myemail.example.com>"
body="this is the body"
但是我收到此错误:
ERROR! 'mail' is not a valid attribute for a Play
The error appears to have been in '/path/test.yml': line 1, column 3, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
- name: Send email
^ here
我想知道我做错了什么
解决方案
您的 yaml 格式错误,正确的剧本是:
---
- name: sending an email
hosts: localhost
tasks:
- name: send email
local_action:
module: mail
subject: "ansible sent this"
to: "my name <myemail.example.com>"
body: "this is the body"
使用时local_action
,应使用 key 指定模块module
。此外,您应该使用:
键/值对,而不是=
.
推荐阅读
- javascript - 导入的类关系从一个到另一个
- java - ClassLoader加载的两个类,不能互相调用
- c# - C# 使用 Profit Combobox SelectedIndex 属性计算加价
- python - 我的 odoo 记录集,如何按字典键分组..到新字典?
- entity-framework - 创建 DbContext.Set
使用反射 - pandas - 根据另一列 pandas 快速实现按天递增日期
- excel - 为什么我的子,删除我另一张表中的一行数据 - VBA
- php - 转换 - 成 - PHP
- java - 当查询相同的 ID 时,存储库是否应该始终在内存中返回相同的引用?
- c++ - 生成伪随机 16 位整数