msg:没有处理程序准备好进行身份验证.检查了1名处理程序.['HmacAuthV4Handler']检查您的凭据

Ale*_*hen 10 amazon-ec2 amazon-web-services ec2-ami ansible 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
Run Code Online (Sandbox Code Playgroud)

我认为我的IAM用户和组中的权限可能有问题.我已经给了我的IAM用户和组ReadOnlyAccess,AdministratorAccess和PowerUserAccess.我有一个访问ID和秘密访问密钥,我使用命令设置为环境变量:

   export AWS_ACCESS_KEY_ID='AK123'
   export AWS_SECRET_ACCESS_KEY='abc123'
Run Code Online (Sandbox Code Playgroud)

用'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  
Run Code Online (Sandbox Code Playgroud)

我想现在我需要开始使用ansible保险库来保存我的密钥和ID.

Arb*_*zar 11

对于那些遇到这个问题的人,你可以通过在剧本中设置become/sudo: False和解决它connection: local.

---
- hosts: localhost
  connection: local
  become: False
  tasks:
   ...
   ...
Run Code Online (Sandbox Code Playgroud)

希望这会有助于他人.


Ale*_*hen 4

我解决了这个问题,我想我对什么是环境变量并没有真正理解。我通过在 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  
Run Code Online (Sandbox Code Playgroud)

我想现在我需要开始使用 ansibleVault 来保存我的密钥和 ID。