How to assing ipv6 address(es) using ec2_instance module?

15 views
Skip to first unread message

jp

unread,
Jan 22, 2019, 9:47:28 AM1/22/19
to Ansible Project
I am trying to define new ipv6 address for ENI using ec2_instance module in ansible 2.7.6- I just don't get it how to define the task? output is just "changed: false" and nothing happens. Would anyone be able to point out how to add new and remove extra ipv6 addresses from running ec2 instance?

I have tried many versions nothing seems to work so currently I just use local action for aws which is nothing else than work around.

- name: eni fact gather
  ec2_eni_facts:
    filters:
      private-ip-address: "{{instance_launch.tagged_instances[0].private_ip}}"
  register: eni_facts

- name: Create lists
  set_fact:
    ipv6_address_list: "[]"

- name: Append list ipv6_address_list
  set_fact:
    ipv6_address_list: "{{ipv6_address_list}} + ['{{item.ipv6_address}}']"
  with_items:
    - "{{eni_facts.network_interfaces[0].ipv6_addresses}}"

- name: Add new ipv6 addresses using awscli local action
  local_action: command aws ec2 assign-ipv6-addresses --network-interface-id {{eni_facts.network_interfaces[0].id}} --ipv6-addresses {{item}}
  when: item not in ipv6_address_list
  with_items:
    - "2a05:d018:c25:1701::11"

# Not working. why?
#- name: Assign ipv6 to EC2 network interface
#  ec2_instance:
#    state: present
#    region: "{{amazon_region}}"
#    vpc_subnet_id: "{{vpcdata_subnets.results[1].subnet.id}}"
#    instance_ids:
#      - "{{instance_launch.tagged_instances[0].id}}"
#    network:
#      interfaces:
#        - "{{eni_facts.network_interfaces[0].id}}"
#      ipv6_addresses:
#        - 2a05:d018:c25:1701::11

Reply all
Reply to author
Forward
0 new messages