Ansible roles in ec2 machine creation and Code Deployement

I am working on a use case where I am creating ec2 machine and then deploying code on that machine .
I have monolith playbook for the same (all tasks in same playbook)
I am looking for a case where I create roles for each tasks example creating ec2 machine would be a role and then installing supervisor to that machine would be another role.
I just want to know how can I pass the public IP address of newly created machines with help of roles to the task which is going to install supervisor on those machines .