amazon-web-services - msg : No handler was ready to authenticate. 检查了 1 个处理程序。 ['HmacAuthV4Handler' ] 检查您的凭据

标签 amazon-web-services amazon-ec2 ansible ec2-ami aws-ec2

因此,我尝试在 aws 上的 ec2 实例上运行 ansible,这是第一次在新实例上运行,但每次尝试运行播放时,我都无法绕过此错误消息:

PLAY [localhost]
**************************************************************

TASK: [make one instance]
***************************************************** 
failed: [localhost] => {"failed": true} msg: No handler was ready to
authenticate. 1 handlers were checked. ['HmacAuthV4Handler'] Check
your credentials

FATAL: all hosts have already failed -- aborting

PLAY RECAP
********************************************************************
   to retry, use: --limit @/home/ubuntu/ans_test.retry

localhost                  : ok=0    changed=0    unreachable=0   
failed=1

我认为我的 IAM 用户和组中的权限可能有问题。我已经给了我的 IAM 用户和组 ReadOnlyAccess、AdministratorAccess 和 PowerUserAccess。我有一个访问 id 和 secret 访问 key ,我使用以下命令将其设置为环境变量:
   export AWS_ACCESS_KEY_ID='AK123'
   export AWS_SECRET_ACCESS_KEY='abc123'

'AK123' 和 'abc123' 替换为我的实际 ID 和键值。我还需要做什么才能使 ansible ec2 任务正常工作?

更新:
我解决了这个问题,我想我并没有真正了解环境变量是什么。我通过在我的 ec2 任务中设置我的 aws_access_key 和 aws_secret_key 来修复它,下面是我的工作手册
- hosts: localhost  
  connection: local  
  gather_facts: False  

  tasks:  
    #this task creates 5 ec2 instances that are all named demo and are copies of the image specified  
    - name: Provision a set of instances  
      ec2:  
         aws_access_key: .....  
         aws_secret_key: ....  
         key_name: .....  
         group: .....  
         instance_type: t2.micro  
         image: ......  
         region: us-east-1  
         ec2_url: .......  
         wait: true  
         exact_count: 5  
         count_tag:  
            Name: Demo  
         instance_tags:  
            Name: Demo  
      register: ec2  

我想现在我需要开始使用 ansible vault 来保存我的 key 和 ID。

最佳答案

对于遇到此问题的人,您可以通过设置 become/sudo: False 来解决它。和 connection: local在剧本中。

---
- hosts: localhost
  connection: local
  become: False
  tasks:
   ...
   ...

希望这会帮助其他人。

关于amazon-web-services - msg : No handler was ready to authenticate. 检查了 1 个处理程序。 ['HmacAuthV4Handler' ] 检查您的凭据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35748580/

相关文章:

amazon-web-services - 使用多个 UserParameters 从 CodePipeline 调用 Lambda

javascript - 从AWS SDK描述地址检索IP

django - 将敏感环境变量包含到 AWS EB Django 应用程序

java - 创建一个程序来管理 Amazon EC2 实例

ansible - 错误!在 Ansible Controller 上找不到 vars 文件 vars

amazon-web-services - 使用 AWS::SNS::Subscription 后是否还需要添加触发器?

amazon-web-services - SSL 在 Windows Server 上不起作用

amazon-web-services - Cloudformation 将实例附加到 Auto Scaling 组

Ansible 正在屏蔽与 URI 模块匹配密码的字符串

带有条件语句的 Ansible 循环