【问题标题】:Ansible EC2 Python Error: ValueError: No JSON object could be decodedAnsible EC2 Python 错误:ValueError:无法解码 JSON 对象
【发布时间】:2015-06-15 20:10:14
【问题描述】:

我正在愉快地前进,一切正常,但突然间,我的所有 EC2 Ansible 操作都出现错误(关于重建的警告之前就存在,不是问题):

ec2-user]# ansible -m ping -u ec2-user all
/usr/lib64/python2.6/site-packages/Crypto/Util/number.py:57: PowmInsecureWarning: Not using mpz_powm_sec.  You should rebuild using libgmp >= 5 to avoid timing attack vulnerability.
  _warn("Not using mpz_powm_sec.  You should rebuild using libgmp >= 5 to avoid timing attack vulnerability.", PowmInsecureWarning)
Traceback (most recent call last):
  File "/root/ansible/bin/ansible", line 194, in <module>
    (runner, results) = cli.run(options, args)
  File "/root/ansible/bin/ansible", line 112, in run
    inventory_manager = inventory.Inventory(options.inventory, vault_password=vault_pass)
  File "/root/ansible/lib/ansible/inventory/__init__.py", line 118, in __init__
    self.parser = InventoryScript(filename=host_list)
  File "/root/ansible/lib/ansible/inventory/script.py", line 49, in __init__
    self.groups = self._parse(stderr)
  File "/root/ansible/lib/ansible/inventory/script.py", line 57, in _parse
    self.raw  = utils.parse_json(self.data)
  File "/root/ansible/lib/ansible/utils/__init__.py", line 552, in parse_json
    results = json.loads(data)
  File "/usr/lib64/python2.6/json/__init__.py", line 307, in loads
    return _default_decoder.decode(s)
  File "/usr/lib64/python2.6/json/decoder.py", line 319, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib64/python2.6/json/decoder.py", line 338, in raw_decode
    raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded

有谁知道是什么给的?

如果我尝试运行主机,我会得到:

 ec2-user]# /etc/ansible/hosts
Looks like AWS is down again:
EC2ResponseError: 403 Forbidden
<?xml version="1.0" encoding="UTF-8"?>
<Response><Errors><Error><Code>UnauthorizedOperation</Code><Message>You are not authorized to perform this operation.</Message></Error></Errors><RequestID>9c499f04-3fd8-47cd-a7e4-655af47c1564</RequestID></Response>

我在 AWS 控制台中的所有操作仍然成功。

【问题讨论】:

    标签: python amazon-ec2 ansible


    【解决方案1】:

    我也遇到了这个问题。原来是我的 AWS 密钥有问题。以下是我的建议:

    1. 验证您是否拥有有效的密钥。我知道这似乎很明显,但从这里开始 :-)
    2. 如果您使用export AWS_SECRET_ACCESS_KEY=... 在您的环境中设置它们,请务必正确使用它们周围的标点符号。我的看起来像

    export AWS_ACCESS_KEY_ID="ASFSADFSDF"(带引号)

    export AWS_SECRET_ACCESS_KEY=ADSFASFAASFASDFSADSFDASDFSADF(无引号)

    1. 如果您在 .zshconfig 或 .bash_profile 中设置这些,请重新启动您的选项卡或窗口以确保重新读取配置文件并将您的 AWS 密钥加载到环境中。

    希望有帮助!

    【讨论】:

    • 即使密钥有效,也值得检查分配给与他们一起使用的用户的权限。
    【解决方案2】:
    1. 确保您已导出 AWS_ACCESS_KEY_ID 和 AWS_SECRET_ACCESS_KEY。 (正如其他人指出的那样)

    2. 确保你已经安装了boto,你可以通过运行来安装它:

      sudo pip install boto

    【讨论】:

      猜你喜欢
      • 2023-03-12
      • 2015-03-29
      • 2015-01-04
      • 1970-01-01
      • 2017-11-17
      • 1970-01-01
      • 1970-01-01
      • 2014-06-21
      • 1970-01-01
      相关资源
      最近更新 更多