Create an Ansible playbook that will retrieve newContainer IP and update the inventory. So that further Configuration of Webserver could be done inside that Container.
In the inventory we generally give the ip of the container that we will configure. But when we are to launch and configure a container then in that case we don’t know the ip of the container that will be launched.
To troubleshoot the problem of ip of container in the target node. We have concept of Tags. With the tags we tag the container with some name and that name allow us to dynamically retrieve the container ip so that we can make dynamically entry for the launched container and that can be used as host group for the play of configuration of the container.
As for the configuration of the docker container ansible will require its access means will need to log in it. For this purpose we launch container with our own custom ami which is down below:

To build the image
docker built -t image_name .
Here -t is for tag the image and . means current directory.
I launched a container with the image palshobhit/dockerssh which is built with the above Dockerfile. I also publish the 80 port of docker container on 1234 of local machine.

The playbook:

In the above the names define each task. The only thing which makes playbook powerful is the jinja raw string syntax i.e. {% raw %} {% endraw %}. We used it so that jinja does not apply its variable meaning to {{ some_name }} and render it as normal string.
Running the playbook:

After running the first play on localhost inventory look as down below:

In the inventory the host group os created with the entry of launched container. On this same os host group next play run which configures the container.
Output:

Conclusion: Jinja template is a powerful thing in ansible.