Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/amazon-web-services/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Amazon web services 创建公共IP并将其分配给使用ansible创建的EC2实例_Amazon Web Services_Automation_Ansible - Fatal编程技术网

Amazon web services 创建公共IP并将其分配给使用ansible创建的EC2实例

Amazon web services 创建公共IP并将其分配给使用ansible创建的EC2实例,amazon-web-services,automation,ansible,Amazon Web Services,Automation,Ansible,在从playbook创建AWS实例时,我试图将弹性ip连接到服务器。我得到了这个错误 致命:[localhost]:失败!=>{ “msg”:“'dict object'没有'instance_id'属性” } 要重试,请使用:--limit@/home/ubuntu/aws.retry 名称:aws实例创建 主持人:本地 连接:本地 收集事实:真实 变量: 操作系统映像:ami-063aa838bd7631e0b 地点:us-west-1 pem:peeps-c vpc_子网:子网-f

在从playbook创建AWS实例时,我试图将弹性ip连接到服务器。我得到了这个错误


致命:[localhost]:失败!=>{ “msg”:“'dict object'没有'instance_id'属性” } 要重试,请使用:--limit@/home/ubuntu/aws.retry



  • 名称:aws实例创建 主持人:本地 连接:本地 收集事实:真实 变量: 操作系统映像:ami-063aa838bd7631e0b 地点:us-west-1 pem:peeps-c vpc_子网:子网-fc5664a7 服务器名称:sagar测试 实例类型:t2.micro 防火墙名称:sagar 描述:sagar_测试规则 计数:1

    任务:

      - name: ec2 security group
        ec2_group:
                name: "{{firewall_name}}"
                region: "{{location}}"
                description: "{{description}}"
                state: present
                rules:
                        - proto: tcp
                          from_port: 80
                          to_port: 80
                          cidr_ip: 0.0.0.0/0
    
                        - proto: tcp
                          from_port: 22
                          to_port: 22
                          cidr_ip: 0.0.0.0/0
    
                        - proto: tcp
                          from_port: 443
                          to_port: 443
                          cidr_ip: 0.0.0.0/0
    
        register: firewall
    
      - name: Debug firewall facts
        debug: msg="{{firewall}}"
    
    
      - name: creating AWS instance
        ec2:
                key_name: "{{pem}}"
                instance_type: "{{instance_type}}"
                region: "{{location}}"
                image: "{{os_image}}"
                termination_protection: no
                group_id: "{{firewall.group_id}}"
                wait: true
                count: "{{count}}"
                instance_tags:
                        Name: "{{server_name}}"
                        state: present
                vpc_subnet_id: "{{vpc_subnet}}"
                assign_public_ip: yes
    
        register: ec2
    
      - name: Debug EC2 facts
        debug: msg="{{ec2}}"
    
    
      - name: Providing a Static IP
        ec2_eip:
                in_vpc: yes
                reuse_existing_ip_allowed: yes
                region: "{{location}}"
                device_id: "{{ec2.instance_ids}}"
                wait_timeout: "20"
    
    • 错误很明显

      “'dict object'没有'instance_ids'属性”

      当你尝试使用它的时候

          device_id: "{{ ec2.instance_ids }}"
      
      您注册并打印了ec2

      看看instance_id在哪里,或者在ec2之后

        register: ec2
      - name: Debug EC2 facts
        debug: msg="{{ ec2 }}"