2014-12-06 35 views
5

我興高采烈去的路上,一切工作,突然我從我所有的EC2 Ansible操作得到錯誤(有關重建警告是有前不是一個問題):Ansible EC2 Python的錯誤:ValueError異常:無JSON對象可以解碼

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控制檯中的所有操作都仍成功。

回答

6

我也遇到了這個問題。原來我的AWS密鑰存在問題。這是我會建議的:

  1. 驗證您有有效的密鑰。我知道這看起來很明顯,但從這裏開始:-)
  2. 如果您使用export AWS_SECRET_ACCESS_KEY=...在您的環境中設置它們,則圍繞它們的標點符號是正確的,這一點很重要。礦山看起來像

export AWS_ACCESS_KEY_ID="ASFSADFSDF"(帶引號)

export AWS_SECRET_ACCESS_KEY=ADSFASFAASFASDFSADSFDASDFSADF(不含引號)

  • 如果你在一個.zshconfig或.bash_profile中設置這些,重新啓動您的選項卡或窗口以確保重新讀取配置文件並將AWS密鑰加載到環境中。
  • 希望有所幫助!

    +1

    即使鍵是有效的,值得一試的權限分配給他們一起使用的用戶。 – 2015-02-08 23:19:40

    1
    1. 確保您已導出AWS_ACCESS_KEY_ID和AWS_SECRET_ACCESS_KEY。 (正如其他人指出)
    2. 請確保您有博託安裝,您可以通過運行安裝:

      sudo pip install boto

    相關問題