Ansible:ec2_eni 无法附加接口

Ansible: ec2_eni cannot attach interface

我正在尝试使用 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 defaults to None, but the module docs say:

Specifies if network interface should be attached or detached from instance. If ommited, attachment status won't change

然后 the code does what they claim 并跳过附件步骤。

这似乎是文档中的错误,claims the default is 'yes' 但并不准确。