Day 59: Ansible Project
Ansible playbooks are amazing, as you learned yesterday. What if you deploy a simple web app using ansible, sounds like a good project, right?
Task-01
Create 3 EC2 instances. make sure all three are created with same key pair.
To create 3 EC2 instances, navigate to the EC2 service and launch
Add the Ansible PPA repository using the following command:
sudo apt-add-repository ppa:ansible/ansible
Install Ansible using the following command:
sudo apt install ansible
Once the installation is complete, you can check the version of Ansible using the following command:
ansible --version
Copy the private key from local to Host server (ansible_host) at (/home/ubuntu/.ssh)
Copy private key from your local.
To proceed with the setup, copy the private key to the Ansible control node (ansible_host) by creating a new file at /home/ubuntu/.ssh and pasting the private key in that file.
Access the inventory file using sudo nano /etc/ansible/hosts
Create a playbook to install Nginx
ansible-playbook file-name.yml
Deploy a sample webpage using the ansible playbook
Create a new file index.html in the playbook directory, and add some sample content
This playbook will copy the index.html file to the default Nginx web server document root directory at /var/www/html/.
Run the playbook
Once the playbook finishes executing, open a web browser and enter the public IP address of one of the EC2 instances running Nginx
InfraOps
1 年??