【发布时间】:2018-06-04 07:57:42
【问题描述】:
我最近开始学习 ansible,现在我有一个问题:
这是我的剧本:
---
- name: execute command with sudo
hosts: all
user: root
become: yes
tasks:
- name: executing
command: sed -i "s/print_thresholds($name,undef,undef,92,98);/#print_thresholds($name,undef,undef,92,98);/g" /etc/munin/plugins/df
它运行良好,sed 取代了我所有需要的东西,但我收到了这个警报。
[警告]:考虑使用替换、lineinfile 或模板模块 而不是运行 sed。如果您需要使用命令,因为替换, lineinfile 或模板不足,您可以在其中添加 warn=False 命令任务或在 ansible.cfg 中设置 command_warnings=False 以摆脱 这条消息。
那么,你能告诉我请纠正剧本吗?
【问题讨论】:
-
我们可以建议您阅读警告并使用其中列出的任何方法。
-
列在哪里?你能给我方法的链接吗?
-
在警告消息中,您将自己添加到上述问题中。