Ansible:尝试使用influxdb_write时,未能在本地主机上导入所需的Python库(influxdb)
我在本地机器上运行了以下ansible playbook和XDB。 我只是想尝试使用ansible向我的本地XDB写一些东西。这里的想法是创建一个名为connections的表,其中包含host、region和time列Ansible:尝试使用influxdb_write时,未能在本地主机上导入所需的Python库(influxdb),ansible,influxdb,Ansible,Influxdb,我在本地机器上运行了以下ansible playbook和XDB。 我只是想尝试使用ansible向我的本地XDB写一些东西。这里的想法是创建一个名为connections的表,其中包含host、region和time列 --- - name: Influx test hosts: PE gather_facts: false tasks: - name: Write points into database influxdb_write: hostname
---
- name: Influx test
hosts: PE
gather_facts: false
tasks:
- name: Write points into database
influxdb_write:
hostname: "localhost"
database_name: "test"
data_points:
- measurement: connections
tags:
host: "{{inventory_hostname}}"
region: test-region
time: "test time"
PE看起来像这样:
[PE]
local ansible_host=localhost ansible_connection=local hostname=Lab_R1 ansible_python_interpreter=/usr/bin/python3
结果是,当我运行我的剧本时,我得到:
The full traceback is:
Traceback (most recent call last):
File "/tmp/ansible_influxdb_write_payload_v07tkyyd/ansible_influxdb_write_payload.zip/ansible/module_utils/influxdb.py", line 23, in <module>
from influxdb import InfluxDBClient
ModuleNotFoundError: No module named 'influxdb'
fatal: [local]: FAILED! => {
"changed": false,
"invocation": {
"module_args": {
"data_points": [
{
"measurement": "connections",
"tags": {
"host": "local",
"region": "test-region"
},
"time": "test time"
}
],
"database_name": "test",
"hostname": "localhost",
"password": "root",
"port": 8086,
"proxies": {},
"retries": 3,
"ssl": false,
"timeout": null,
"udp_port": 4444,
"use_udp": false,
"username": "root",
"validate_certs": true
}
},
"msg": "Failed to import the required Python library (influxdb) on localhost.localdomain's Python /usr/bin/python3. Please read module documentation and install in the appropriate location. If the required library is installed, but Ansible is using the wrong Python interpreter, please consult the documentation on ansible_python_interpreter"
}
完整的回溯是:
回溯(最近一次呼叫最后一次):
文件“/tmp/ansible\u influxdb\u write\u payload\u v07tkyyd/ansible\u influxdb\u write\u payload.zip/ansible/module\u utils/influxdb.py”,第23行,in
从influxdb导入InfluxDBClient
ModuleNotFoundError:没有名为'influxdb'的模块
致命:[本地]:失败!=>{
“更改”:错误,
“调用”:{
“模块参数”:{
“数据点”:[
{
“测量”:“连接”,
“标签”:{
“主机”:“本地”,
“区域”:“测试区域”
},
“时间”:“测试时间”
}
],
“数据库名称”:“测试”,
“主机名”:“本地主机”,
“密码”:“根”,
“端口”:8086,
“代理”:{},
“重试”:3,
“ssl”:错误,
“超时”:空,
“udp_端口”:4444,
“使用udp”:false,
“用户名”:“根”,
“验证证书”:正确
}
},
“msg”:“未能在localhost上导入所需的Python库(influxdb)。localdomain的Python/usr/bin/python3。请阅读模块文档并安装到适当的位置。如果安装了所需的库,但Ansible使用了错误的Python解释器,请参阅Ansible_Python_解释器上的文档。”
}
如python库中所述,xdb>=0.9是必需的
任务的目标需要此要求,在您的情况下是localhost
因此,您需要使用您选择的方法(系统包或
pip
)。是否安装了Pythoninfluxdb
模块?