create network interface (ENI) on EC2 instance? possible to use "raw" boto commands?

Someone asked for this a while back before the modules were reorganized, but I’ve seen no mention since, so I’m guess it’s still not possible to create (or manipulate) an Elastic Network Interface (eni) on an EC2 instance yet. That being the case, since this is supported by boto (create_network_interface), is it possible for me to make my own calls via boto somehow? I’m not very deep into Ansible so perhaps this is a nonsensical question.

Thanks

+1 for this request. Have you seen this module though: https://github.com/cybosol/ansible/blob/master/library/cloud/ec2_eni
haven’t tried it my self but maybe it can help.

Hi guys,

Recently had this requirement myself.

I’ve written a module here https://github.com/wimnat/ansible-modules-extras/blob/feature/ec2_eni/cloud/amazon/ec2_eni.py

I’d appreciate testing / feedback and if all good I’ll submit a PR to ansible-modules-extras

Thanks,

Hi Rob
Thanks for module!

I was just looking for something like this.

One thing I’m missing is the ability to set the deleteOnTermination attribute to True.
Something like

`
connection.modify_network_interface_attribute(network_interface.id,‘deleteOnTermination’,True, attachment_id=network_interface.attachment.id)

`

Unfortunately you wouldn’t be able to create the interface with this attribute. Boto doesn’t support it. You’d have to create the interface and then immediately modify it.

Would this be acceptable?

Unfortunately you wouldn’t be able to create the interface with this attribute. Boto doesn’t support it. You’d have to create the interface and then immediately modify it.

Would this be acceptable?

Yes, this is what I’m doing now.

The latest commit has added support for delete_on_termination and source_destination_check. Please test and let me know how it goes.

If you’d like to leave any comments regarding the module, there’s a PR here https://github.com/ansible/ansible-modules-extras/pull/410

The latest commit has added support for delete_on_termination and source_destination_check. Please test and let me know how it goes.

Can you please give a full example of attaching an interface and setting the delete_on_termination?

Not sure how to extract the eni.interface.id for the second.

Should I use it as part of a local_action, like I do for ec2_tag?

Sorry for the naive questions, I’m relativity new to Ansible.

I assume you have referenced eni.interface.id because you’ve seen the example? Note the code above that which contains a register statement. This allows you to reference output from that command. See http://docs.ansible.com/playbooks_variables.html for more on that.

Once you’ve used that register command you can reference all the values of the ENI creation.

If you’re still having issues, post your playbook as it stands and any errors you’re getting.

The latest commit has added support for delete_on_termination and source_destination_check. Please test and let me know how it goes.

Can you please give a full example of attaching an interface and setting the delete_on_termination?

Not sure how to extract the eni.interface.id for the second.

Should I use it as part of a local_action, like I do for ec2_tag?

Sorry for the naive questions, I’m relativity new to Ansible.

I assume you have referenced eni.interface.id because you’ve seen the example? Note the code above that which contains a register statement. This allows you to reference output from that command. See http://docs.ansible.com/playbooks_variables.html for more on that.

Once you’ve used that register command you can reference all the values of the ENI creation.

If you’re still having issues, post your playbook as it stands and any errors you’re getting.

I had two issues, solve one:

  • region parameter was missing, I set AWS_REGION to solve it.
    Would it be nicer to have an explicit parameter for it, like ec2_tag have?
  • subnet_id was missing, and I cant find an elegant way to get. For me having the instance subnet as a default will solve this problem.

The module does support region. You should be able to specify it without issue.

Can you get the subnet_id from the ec2_fact module?