【发布时间】:2017-10-10 17:09:59
【问题描述】:
今天我正在尝试将多个弹性 IP 分配给多个不同的私有 IP 地址。
注意:IP 地址是假的,我这样写是为了让你明白我想做什么。
这是我目前所取得的成就:
Server 1
Elastic Network Interface
Private IP 172.x.x.1 (public IP: 55.x.x.1)
Secondary Private IP
172.x.x.2 (public IP: NONE SET)
172.x.x.3 (public IP: NONE SET)
Server 2
Elastic Network Interface
Private IP 174.x.x.1 (public IP: 57.x.x.1)
Secondary Private IP
174.x.x.2 (public IP: NONE SET)
174.x.x.3 (public IP: NONE SET)
这就是我想要实现的目标:
Server 1
Elastic Network Interface
Private IP 172.x.x.1 (public IP: 55.x.x.1)
Secondary Private IP
172.x.x.2 (public IP: 55.x.x.2)
172.x.x.3 (public IP: 55.x.x.3)
Server 2
Elastic Network Interface
Private IP 174.x.x.1 (public IP: 57.x.x.1)
Secondary Private IP
174.x.x.2 (public IP: 57.x.x.2)
174.x.x.3 (public IP: 57.x.x.3)
这是我目前编写的 Ansible 剧本:
{{ platform }} 是一个通过 CLI 传递的额外变量。
- name: Provision a set of Edge instances
ec2:
key_name: ec2user
group: "launch-wizard-1"
instance_type: "m4.2xlarge"
image: "ami-xxxxxxx"
region: "eu-west-1"
wait: true
exact_count: 2
count_tag:
PlatformName: "{{ platform }}"
Role: Edge
instance_tags:
Name: "{{ platform }}::Edge"
PlatformName: "{{ platform }}"
Role: Edge
LongName: "Edge server for {{ platform }}'s platform"
Groups: common,server,rabbitmq,memcache,stats,cache-manager,media,content,icecast
register: edge_ec2
- name: Find ENIs created for Edge instances
ec2_eni_facts:
region: "eu-west-1"
filters:
attachment.instance-id: "{{ item }}"
with_items: "{{ edge_ec2.instance_ids }}"
register: edge_enis
- name: Adds an additional private IP to the Edge ENIs
ec2_eni:
region: "eu-west-1"
eni_id: "{{ item.interfaces[0].id }}"
subnet_id: "{{ item.interfaces[0].subnet_id }}"
state: present
secondary_private_ip_address_count: 2
register: created_ips
with_items: "{{ edge_enis.results }}"
- name: Adds additional elastic IPs to the Edge ENIs
ec2_eip:
device_id: "{{ item.0.interface.attachment.instance_id }}"
region: "eu-west-1"
private_ip_address: "{{ item.1.private_ip_address }}"
in_vpc: true
register: eips
with_subelements:
- "{{ created_ips.results }}"
- interface.private_ip_addresses
为什么 ansible 不将新分配的弹性 IP 分配给辅助私有 IP,而只分配给主 IP,即使我明确告知将其分配给辅助私有 IP?
【问题讨论】:
-
在您的帖子中找不到任何问题。
-
添加了问题,抱歉
标签: amazon-web-services amazon-ec2 ansible