Update EC2 instances hostnames to their EC2 instance tags

Hi everyone,

I have got a question about the EC2 and it related modules. I would like to update the hostnames of all of the EC2 instances created by another role within the same playbook (all EC2 instances are dynamic inventories, no host file) by using their EC2 instance tag. For example, if an instance has a tag “Name: dbserver01”, I would like to update its hostname to “dbserver01.mydomain,mycompany.local”. What should I do?