Uploaded image for project: 'Ansible Cloud Automation'
  1. Ansible Cloud Automation
  2. ACA-1843

[amazon.aws/2218] amazon.aws.ec2_eip fails to allocate and associate EIPs to secondary private IPs

XMLWordPrintable

    • False
    • Hide

      None

      Show
      None
    • False

      https://github.com/ansible-collections/amazon.aws/issues/2218

          1. Summary

      I have multiple secondary IPs on multiple ENIs, and I'm trying to allocate and then associate EIPs to all IPs (primary and secondary) on each ENI - up to the limit the instance allows. I am using t4g.small which allows 2 interfaces with 4 IPs per interface (ref: https://docs.aws.amazon.com/ec2/latest/instancetypes/gp.html).

      What I see happening is with a list of 6 items, only 2 EIPs are ever allocated and they are associated with the primary IP on each ENI. When I check the tags on the 2 EIPs that are created, I see the "ip" tag has a value that does not match the private_ip_address it has been associated with - so it looks like the loop is overwriting tags and for some reason not allocating a new EIP.

          1. Issue Type

      Bug Report

          1. Component Name

      amazon.aws.ec2_eip

          1. Ansible Version

      ```console (paste below)
      $ ansible --version
      ansible [core 2.15.12]
      python version = 3.12.4
      jinja version = 3.1.4

      ```

          1. Collection Versions

      ```console (paste below)
      $ ansible-galaxy collection list
      amazon.aws 8.1.0
      ```

          1. AWS SDK versions

      ```console (paste below)
      $ pip show boto boto3 botocore
      WARNING: Package(s) not found: boto
      Name: boto3
      Version: 1.34.131

      Name: botocore
      Version: 1.34.131
      ```

          1. Configuration

      ```console (paste below)
      $ ansible-config dump --only-changed

      ```

          1. OS / Environment

      Fedora 40

          1. Steps to Reproduce

      With `eni_info` being:
      ```
      [

      { "eni": "eni-02e27f806845a09de", "ip": "192.168.142.188" }

      ,

      { "eni": "eni-02e27f806845a09de", "ip": "192.168.133.224" }

      ,

      { "eni": "eni-02e27f806845a09de", "ip": "192.168.139.178" }

      ,

      { "eni": "eni-0fb509662f6d64604", "ip": "192.168.131.230" }

      ,

      { "eni": "eni-0fb509662f6d64604", "ip": "192.168.137.223" }

      ,

      { "eni": "eni-0fb509662f6d64604", "ip": "192.168.130.68" }

      ]

      ```
      the below task returns changed for all items, but only 2 EIPs are ever allocated, and they are associated with the primary IP of each ENI. When I check the tags on the 2 EIPs they do not match the private_ip_address they are associated with.
      <!--- Paste example playbooks or commands between quotes below -->
      ```yaml (paste below)

      • name: Associate EIP
        become: no
        delegate_to: localhost
        amazon.aws.ec2_eip:
        device_id: "{{ item.eni }}"
        private_ip_address: "{{ item.ip }}"
        in_vpc: true
        tags:
        eni: "{{ item.eni }}"
        ip: "{{ item.ip }}"
        loop: "{{ eni_info }}"

      ```

          1. Expected Results

      I expect 6 EIPs to be allocated and associated with primary and secondary private IP addresse. This can be achieved when done manually in the AWS console.

          1. Actual Results

      ```console (paste below)
      TASK [eip : Associate EIP] *******************************************************************************************************************************************************************************************************************
      changed: [myhost -> localhost] => (item=

      {'eni': 'eni-0fb509662f6d64604', 'ip': '192.168.131.230'}

      )
      changed: [myhost -> localhost] => (item=

      {'eni': 'eni-0fb509662f6d64604', 'ip': '192.168.137.223'}

      )
      changed: [myhost-> localhost] => (item=

      {'eni': 'eni-0fb509662f6d64604', 'ip': '192.168.130.68'}

      )
      changed: [myhost -> localhost] => (item=

      {'eni': 'eni-02e27f806845a09de', 'ip': '192.168.142.188'}

      )
      changed: [myhost-> localhost] => (item=

      {'eni': 'eni-02e27f806845a09de', 'ip': '192.168.133.224'}

      )
      changed: [myhost -> localhost] => (item=

      {'eni': 'eni-02e27f806845a09de', 'ip': '192.168.139.178'}

      )
      ```

      Evidence of only 2 EIPs being created and associated (note the difference in tag IP and the IP assoicated):
      ```
      $ aws ec2 describe-addresses --filters "Name=tag-key,Values=ip"
      {
      "Addresses": [
      {
      "InstanceId": "i-01a82021739b0d47d",
      "PublicIp": "3.127.161.240",
      "AllocationId": "eipalloc-00a0505ca83eb7ab2",
      "AssociationId": "eipassoc-0d5b78915e99deba0",
      "Domain": "vpc",
      "NetworkInterfaceId": "eni-02e27f806845a09de",
      "NetworkInterfaceOwnerId": "546442592561",
      "PrivateIpAddress": "192.168.142.188",
      "Tags": [

      { "Key": "ip", "Value": "192.168.139.178" }

      ,

      { "Key": "eni", "Value": "eni-02e27f806845a09de" }

      ],
      "PublicIpv4Pool": "amazon",
      "NetworkBorderGroup": "eu-central-1"
      },
      {
      "InstanceId": "i-01a82021739b0d47d",
      "PublicIp": "3.74.1.24",
      "AllocationId": "eipalloc-0178711a6fd1d4416",
      "AssociationId": "eipassoc-023fd29137ed53faa",
      "Domain": "vpc",
      "NetworkInterfaceId": "eni-0fb509662f6d64604",
      "NetworkInterfaceOwnerId": "546442592561",
      "PrivateIpAddress": "192.168.131.230",
      "Tags": [

      { "Key": "eni", "Value": "eni-0fb509662f6d64604" }

      ,

      { "Key": "ip", "Value": "192.168.130.68" }

      ],
      "PublicIpv4Pool": "amazon",
      "NetworkBorderGroup": "eu-central-1"
      }
      ]
      }
      ```

          1. Code of Conduct
      • [X] I agree to follow the Ansible Code of Conduct

            gosriniv@redhat.com Gomathi selvi Srinivasan
            jrouleau Jill Rouleau
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: