【问题标题】:ANSIBLE: boto - "TypeError: a bytes-like object is required, not 'str'"ANSIBLE:boto -“TypeError:需要一个类似字节的对象,而不是'str'”
【发布时间】:2021-07-06 14:34:05
【问题描述】:

使用 ansible=2.10.0boto=2.49.0,当尝试执行 ec2_vol playbook 以管理磁盘到具有代理环境的 AWS 实例时。 收到此错误 -

connection.py",line 796, in proxy_ssl, sock.sendall("CONNECT %s HTTP/1.0\r\n" % host), TypeError: a bytes-like object is required, not 'str',

有开放的 PR 可以修复它,但尚未合并 - https://github.com/boto/boto/pull/3699。 ec2_vol 之类的社区模块也无法使用 - https://galaxy.ansible.com/community/aws

除了使用fork来解决,比如python中的monkeypatching,有没有其他解决方案?

【问题讨论】:

  • 您对用于那些ec2_vol 任务的python 解释器有影响,因此您可以通过使用python2 来解决该问题,或者(如您所述)您可以将补丁应用于boto 库作为剧本的一部分(通过lineinfile: 或类似方式)

标签: python-3.x amazon-ec2 ansible boto


【解决方案1】:

经过长时间的研发,我找到了上述错误的解决方案-

我们可以使用amazon.aws:1.4.1 版本来解决问题。 我没有像上面那样抛出 ec2_vol 任务的错误。

【讨论】:

    猜你喜欢
    • 2016-01-05
    • 1970-01-01
    相关资源
    最近更新 更多