amazon.aws icon indicating copy to clipboard operation
amazon.aws copied to clipboard

Add support for Route53 DNS in aws_ec2

Open fostermi opened this issue 4 years ago • 6 comments

Summary

The old ec2.py script supported using Route53 DNS entries for hostnames, and we laid out our deployment inventory host_vars to take advantage of that. However, Route53 dns is no longer an option with the aws_ec2 module, only public or private DNS. Creating a host_vars inventory with these doesn't make a whole lot of sense since EC2 instances should be disposable and those values can/will change, but using Route53 can be permanent since we can move the DNS record from instance to instance. We have several apps/containers running on a single host and using Route53 DNS is an efficient way to identify those. Using tags to map to a Route53 dns entry would be cumbersome as each key needs to be unique.

Issue Type

Feature Idea

Component Name

aws_ec2

Additional Information


Code of Conduct

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

fostermi avatar Nov 04 '21 18:11 fostermi

Files identified in the description:

  • [plugins/inventory/aws_ec2.py](https://github.com/['ansible-collections/amazon.aws', 'ansible-collections/community.aws', 'ansible-collections/community.vmware']/blob/main/plugins/inventory/aws_ec2.py)

If these files are inaccurate, please update the component name section of the description or use the !component bot command.

click here for bot help

ansibullbot avatar Nov 04 '21 18:11 ansibullbot

Hi @fostermi,

This would indeed be a nice feature. Would you like to implement it in the inventory plugin?

goneri avatar Nov 16 '21 20:11 goneri

That's probably beyond my capabilities. However, this was available in the deprecated ec2.py script, so I was hoping that the aws_ec2 module would have feature parity before deprecating the old script.

fostermi avatar Nov 17 '21 20:11 fostermi

We could probably work around this by using multiple tags, but I don't see a way to use a regex in the hostnames parameter with "tags" as one of the list-items. Everything looks to have to be hard-coded. Even worse, the plugin only takes the first item in the list so something like

hostnames: - tag:DNS_1 - tag:DNS_2

only returns hosts matching the first tag.

fostermi avatar Nov 17 '21 23:11 fostermi

This has really bit us since the module is not returning all hostnames that our roles are using to pull in inventory_hostnames variables of Docker containers. We are deploying a database and an app that needs to reference the database host IP from the docker_container results from the database container deploy, but this module only returns a single hostname (i.e. the first item in the hostnames list) so we can't have separate inventory host_vars in Ansible that correspond to a Docker container. For example we define an Ansible variable for the app, using an Ansible variable from the database inventory host_vars: APP_DB_NAME: "{{ hostvars['my_app_mariadb.application.local'].DB_NAME }}"

fostermi avatar Dec 01 '21 21:12 fostermi

There are also reverse DNS parameters in boto3 ec2 run_instance()

    PrivateDnsNameOptions={
        'HostnameType': 'ip-name'|'resource-name',
        'EnableResourceNameDnsARecord': True|False,
        'EnableResourceNameDnsAAAARecord': True|False
    },

that ` ec2_instance is currently missing

markuman avatar Apr 01 '22 07:04 markuman