Day 59: Ansible Project
Create a playbook to install Nginx
deploy a sample webpage using the ansible playbook
Prerequisite: Make sure you have set up two server instances and one master instance as explained in my previous blogs(Day 57 and Day 58)
Don't forget to update your inventory before proceeding.
create install_ngnix.yml using vim
---
- name: Install Nginx and deploy sample webpage
hosts: webserver
become: true
tasks:
- name: Install Nginx
apt:
name: nginx
state: present
- name: Deploy sample webpage
copy:
src: /home/ubuntu/playbook/website/
dest: /var/www/html/
owner: www-data
group: www-data
mode: 0755
notify:
- Restart Nginx
notify:
- Restart Nginx
handlers:
- name: Restart Nginx
service:
name: nginx
state: restarted
Ps : I have my website in website folder.

now run playbook using following command
ansible-playbook install_ngnix.yml

After execution, you can check the IP address of your server:

That was all for today's tasks. See you another day with another challenge.



