This will install & running nginx latest on Ubuntu with ip 192.168.48.133
. Tested on Ubuntu 16.04 x64 LTS
Install on OS running Ubuntu or in VM will work also.
sudo apt-get update
sudo apt-get install software-properties-common
sudo apt-add-repository ppa:ansible/ansible
sudo apt-get update
sudo apt-get install ansible
Refer to official docs here
This will contain ip to where you want to deploy. Make sure ssh key already added on that host. Refer this on how to add ssh key.
Edit file /etc/ansible/hosts
fill the following:
# Application Server
[webserver]
192.168.48.133
Create new file play.yml
with content:
---
- hosts: webserver
become: yes
become_method: sudo
tasks:
- name: install nginx
apt : pkg=nginx state=installed update_cache=true
notify:
- start nginx
handlers:
- name: start nginx
service: name=nginx state=started
Run ansible playbook:
ansible-playbook --ask-become-pass play.yml
To test if nginx is running:
curl 192.168.48.133 80