通过ansible创建ec2实例时,公共IP不可用

时间:2019-03-07 10:25:58

标签: amazon-ec2 ansible subnet vpc

我正在使用ansible设置EC2实例,并将其添加到vpc,子网和安全组。正在将assign_public_id设置为yes,并且还将专用IP分配给子网。

但是在创建虚拟机之后,它将显示公共DNS和IP为空。

在创建子网时也将map_public添加到yes。

下面是ec2和子网的代码

    - name: Provisioning server with tag AAS
      local_action:
      module: ec2
      assign_public_ip: yes
      group_id: "{{sg_id}}"
      instance_type: "{{instance_type}}"
      key_name: "keypair"
      image: "{{image}}"
      region: "{{region}}"
      vpc_subnet_id: "{{ internal_subnet_id }}"
      private_ip: "{{ private_ip }}"
      wait: true
     exact_count: "{{count}}"
     count_tag:
       Role: "{{aws_role}}"
     volumes:
      - device_name: "{{ec2_device_name}}"
        volume_type: "{{MANAGED_DEVICE_TYPE}}"
        volume_size: "{{vm_size_testvm}}"
        delete_on_termination: true
  register: test_vm

子网代码

- name: " Create an Internal Subnet for VPC ID - {{vpc_id}}"
  ec2_vpc_subnet:
    state: present
    vpc_id: "{{vpc_id}}"
    cidr: "{{ subnet_cidr_internal }}"
    map_public: yes
    resource_tags:
      Name: Internal_Subnet 
  register: internal_subnet

如何解决?

0 个答案:

没有答案