Ansible Playbook with dynamic inventory

Ansible Playbook for dynamically updating the inventory with the new container IP to deploy a webserver in it!

Playbook:

Running the playbook:

Inventory gets dynamically updated as we used blockinfile module and retrieved ip using ansible facts.

The inventory has been updated; the IP of our container is 172.17.0.2