我正在尝试安装 telegraf 并更改其主配置文件的配置/etc/telegraf/telegraf.conf
。
安装成功,但更改配置文件时任务失败。这是任务/main/yml 文件
---
- name: install telegraf
apt: pkg=telegraf state=installed
become: true
- name: changing conf file
ini_file:
path: /etc/telegraf/telegraf.conf
section: outputs.influxdb
option: database
value: ['http://localhost:8086']
但任务失败,
fatal: [192.168.122.62]: FAILED! => {"changed": false, "failed": true, "module_stderr": "Shared connection to 192.168.122.62 closed.\r\n", "module_stdout": "Traceback (most recent call last):\r\n File \"/tmp/ansible_CQ_3uv/ansible_module_ini_file.py\", line 319, in <module>\r\n main()\r\n File \"/tmp/ansible_CQ_3uv/ansible_module_ini_file.py\", line 305, in main\r\n (changed,backup_file,diff,msg) = do_ini(module, path, section, option, value, state, backup, no_extra_spaces, create)\r\n File \"/tmp/ansible_CQ_3uv/ansible_module_ini_file.py\", line 268, in do_ini\r\n ini_file = open(filename, 'w')\r\nIOError: [Errno 13] Permission denied: '/etc/telegraf/telegraf.conf'\r\n", "msg": "MODULE FAILURE", "rc": 0}
这是一个权限被拒绝错误,所以我尝试become: true
在任务中添加,但它说这become
不是ini_file
.
这是/etc/telegraf/telegraf.conf
我要更改的文件部分。
[[outputs.influxdb]]
urls = ["http://192.168.1.9:8086"] # I want http://localhost:8086
database = "server-telegraf"
我不知道如何解决这个问题。需要帮助 !