ansible - ansible action 插件扩展 ansible fact
问题描述
我一直在尝试使用此处的内容将主机名传递给模块
我有下面的代码,通常会创建一个事实,我可以在使用模板或复制模块后远程复制文件。
#!/usr/bin/python
import custommodule
# ...
hostname = {{ ansible_nodename }} # hostname should come from ansible_nodename fact.
custom_content = custommodule.render(hostname)
facts = dict()
facts['custom_content'] = custom_content
args = {
'changed': False,
'ansible_facts': {'custom_facts': facts},
}
module.exit_json(**args)
问题是如何确保变量由我不知道如何实现hostname
的事实填充。ansible_nodename
我怎么能修改这个
解决方案
推荐阅读
- c# - 如何检测当前会话是否通过 RDP 启动?
- php - 我在控制器函数中定义了两个变量,但我无法在视图中访问这两个变量
- c - 在 Linux AUART 内核驱动程序中,如何使用 I2C GPIO 扩展器的引脚而不是 RTS 来控制 RS485 方向?
- r - R 闪亮的令人费解的警告:asJSON(keep_vec_names=TRUE) 的输入是一个命名向量
- sql - SQL查询错误:日期格式图片在将整个输入转换为字符串之前结束
- machine-learning - 我如何才能仅在最后 3 个时期查看验证准确性?这是为了减少时间
- python - 此 for 循环仅显示学生记录的最后一个条目
- javascript - Javascript新手卡在XMLHttpRequest返回数据上
- python - 如何使用 aggfunc 'min' 在 dask 中做 pivot_table?
- vue.js - Vue npm run serve 在随机端口上启动