Setup Ansible
Quick Start Ansible for AWS
Starter Ansible template for AWS
Create a host and a managed-node
Then install ansible inside host. Below command is for Amazon linux2.
Verify ansible is installed Copy contents of pem file to host (Assuming you created managed-node on AWS and you downloaded your .pem file with which you can SSH to your managed-node). Read the contents of .pem file and copy-paste to a new filekey.pem
. You can use vim or nano editor to paste contents.
You need to reduce the permission of your key file.
Now in your ansible host machine. Add key file to ssh-agent.
Create inventory file inventory.txt
. Inventory file is used to store hosts meta-data. Here we are explicityly creating a host file but the default host file is located in /etc/ansible/hosts
Create host file
Inside the file paste Try to ping the host and check if you have a successful connectionmake sure you are in the same session in which you added bash key, if not you may want to do again ssh-agent bash
& ssh-add ~/.ssh/key.pem
<!-- add your hosts to the file
Ansible will start a nginx server in your managed-node. If Ansible successfully deployed nginx and you are still cannot open your nginx site on your managed-mode, try to check your security groups, network settings and firewall settings.