prerequisites -So, lets get started we’re going to run all the tasks on localhost (controller node), so there is no need to configure static inventory of controller node.
In this file, Add your inventory location, host_key_checking, ask_pass add remote_user - here, ec2-user because in AWS instances by default root login is not enabled.
Now, its time to write Ansible playbook to create EC2 Instance for Launching Apache Web server so, create a workspace in controller node and start writing playbook and extension should be “.yml or .yaml” of file, because we write playbook in yaml format.
Now after launching the instance we have to add the public IP of instance in the dynamic inventory of Ansible.
After that my playbook is waiting for SSH enable in instance because Ansible need to login into instance to configure as web server.