- Create an “index.html file” on Ansible Master to host on the ansible worker node through Ansible Inventory & Ansible Playbook file:
<!DOCTYPE html>
<html>
<body>
<h1>Welcome to the new era of devops</h1>
<p>This is hosting a webpage through ansible playbook</p>
</body>
</html>
- Create “deploy_webpage.yml"
-
name: this is a simple HTML project
hosts: servers
become: yes
tasks:
- name: Install nginx
apt:
name: nginx
state: latest
- name: Start nginx
service:
name: nginx
state: started
- name: Deploy webpage
copy:
src: index.html
dest: /var/www/html
- We want to deploy this HTML page on the Ansible worker node defined on “prod_inv” inventory file.
ansible-playbook -i inventories/prod_inv deploy_webpage.yml
- Fetch the details of the Public IP of the Ansible worker node defined in "prod_inv" inventory file.
- Browse this public IP of Ansible worker node:
Kindly follow the previous blog https://hashnode.com/post/cle5mp4wy000909kx068g7fvq
Thank you for reading!Happy Learning!!
Santosh Chauhan