Ansible:ec2_eni无法连接接口



使用 ansible,我正在尝试创建 ec2 实例并将一个额外的网络接口附加到每个实例,以便它们具有两个私有 IP 地址。 但是,由于某种原因,ec2_eni模块似乎可以创建网络接口,但不会将它们附加到指定的实例。我做错了什么? 以下是我的剧本:

---
- hosts: localhost
connection: local
gather_facts: false
tasks:
- name: Create new servers
ec2:
region: "{{ region }}"
vpc_subnet_id: "{{ subnet }}"
group_id: "{{ sec_group }}"
assign_public_ip: yes
wait: true
key_name: '{{ key }}'
instance_type: t2.micro
image: '{{ ami }}'
exact_count: '{{ count }}'
count_tag:
Name: "{{ server_name }}"
instance_tags:
Name: "{{ server_name }}"
register: ec2
- name: Show ec2 instance json data
debug:
msg: "{{ ec2['tagged_instances'] }}"
- name: allocate new elastic IPs and associate it with instances
ec2_eip:
region: "{{ region }}"
device_id: "{{ item['id'] }}"
with_items: "{{ ec2['tagged_instances'] }}"
register: eips
- name: Show eip instance json data
debug:
msg: "{{ eips['results'] }}"
- ec2_eni:
subnet_id: "{{ subnet }}"
state: present
secondary_private_ip_address_count: 1
security_groups: "{{ sec_group }}"
region: "{{ region }}"
device_index: 1
description: "test-eni"
instance_id: "{{ item['id'] }}"
with_items: "{{ ec2['tagged_instances'] }}"

奇怪的是,ec2_eni任务成功了,说它已将网络接口附加到每个实例,而实际上它只是创建网络接口,然后不对其进行任何操作。

据我所知,因为attached默认为None,但模块文档说:

指定是应从实例附加还是分离网络接口。如果省略,附件状态不会更改

然后代码执行它们声称的操作并跳过附件步骤。

这似乎是文档中的一个错误,该错误声称默认值为"是",但不准确。

最新更新