# 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](https://hashnode.com/post/clj84jmh8000409moagquh57h) and [Day 58](https://hashnode.com/post/clj9kdnto000j0al9hmlqhhm0))

Don't forget to update your inventory before proceeding.

create `install_ngnix.yml` using vim

```bash
---
- 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.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1687587623902/ab2bf66d-831d-4090-9a3f-dc2f2ddabcbd.png align="center")

now run playbook using following command

```bash
ansible-playbook install_ngnix.yml
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1687587455245/720cad2b-bd56-4b37-a94c-a8ab7242ad9b.png align="center")

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

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1687587499738/af4abac0-f4de-4d98-b728-77039edf58f6.png align="center")

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