ansible postgresql 报错psycopg2

运行ansible的postgresql_user模块时,报错:如下

Fatal: [192.168.118.213]: FAILED! => {"changed": false, "msg": "Failed to import the required Python library (psycopg2) on ansible3's Python /usr/bin/python. 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"}

解决方案

pip install psycopg2
pip install  pyghmi

安装报错如下:

... 
 gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -DPSYCOPG_VERSION=2.8.5 (dt dec pq3 ext lo64) -DPG_VERSION_NUM=100014 -DHAVE_LO64=1 -I/usr/include/python2.7 -I. -I/usr/pgsql-10/include -I/usr/pgsql-10/include/server -c psycopg/psycopgmodule.c -o build/temp.linux-x86_64-2.7/psycopg/psycopgmodule.o -Wdeclaration-after-statement
  In file included from psycopg/psycopgmodule.c:28:0:
  ./psycopg/psycopg.h:35:20: 致命错误:Python.h:没有那个文件或目录
   #include <Python.h>
                      ^
  编译中断。

解决方案:

yum install python-devel
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
当使用Ansible时,可能会遇到这样的错误提示:“added 'ip' (ecdsa) to the list of known hosts”。这个错误提示表示Ansible试图将目标主机的IP地址添加到已知主机列表中。 这个错误通常是由于第一次连接到远程主机时引起的,Ansible将主机密钥添加到~/.ssh/known_hosts文件中。这是Ansible的正常行为,以确保安全连接和身份验证。 要解决这个问题,有以下几种方法: 1. 忽略已知主机检查:在执行Ansible命令时,可以使用`-k`参数或`--ask-pass`参数来忽略对已知主机的检查。例如,`ansible-playbook -i inventory.ini playbook.yaml -k`。这个方法虽然简单,但会牺牲一部分安全性。 2. 更新known_hosts文件:如果你确定目标主机是安全的,你可以手动更新`~/.ssh/known_hosts`文件,添加目标主机的IP地址和密钥。你可以使用SSH命令`ssh-keyscan`来获取主机密钥并添加到known_hosts文件中。例如,`ssh-keyscan -H ip >> ~/.ssh/known_hosts`。这样做的好处是避免了每次连接时的询问,但仍保持了一定的安全性。 3. 使用ssh-keygen重新生成密钥:如果你不确定目标主机的安全性,你可以尝试使用`ssh-keygen`命令生成新的公钥和私钥。然后,将新的公钥复制到目标主机的`~/.ssh/authorized_keys`文件中。这样可以确保安全连接和身份验证。 无论你选择哪种方法,记得在操作之前确保备份重要的配置文件和数据,以免意外损失。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值