3 | Ansible Hands-On Demo Project | Step by Step for Beginners
Automation Step by Step
@raghavpalAbout
Simple Basic Beginners Step-by-Step tutorials ❤️ I create videos on Automation, Testing, DevOps, CI and related tools, technologies and platform Raghav is a teacher and founder of AutomationStepByStep.com He was an Automation Architect and has led multiple teams of Automation and DevOps Engineers. For over a decade, Raghav witnessed, worked, and delivered multiple Automation Testing Projects and worked with some awesome people in this industry ► https://automationstepbystep.com/ Some topics covered: - Jenkins - JMeter - Selenium - Appium - Cypress - Playwright - Katalon Studio - API Testing - Postman - Docker - Kubernetes - Other DevOps topics Words from Raghav We often need someone to hold our hand and help us take the first few steps before we learn to walk and run. I am on a mission to spread education and make it available to anyone willing to learn Never Stop Learning Raghav All education here is FREE FOR ALL, FOREVER Share with as many people as you can in your lifetime
Video Description
All Free Tutorials - https://AutomationStepByStep.com/ How to setup Ansible Controller machine How to setup Ansible Host machines Making connection between Controller and Hosts Adding host and playbook file on Controller Run Playbook to configure Host Machines We will need Linux machines for this DEMO You can use any Linux machines or setup using any cloud platforms like AWS In this Demo I am going to use Vagrant to create Linux Virtual Machines In any case the process and steps will remain same Ref: Create Free Linux on AWS and connect from Windows and Mac OS - https://youtu.be/6bb-OqbI8-E Vagrant Beginner Playlist - https://www.youtube.com/playlist?list=PLhW3qG5bs-L9S272lwi9encQOL9nMOnRa Vagrant VM Boxes - https://app.vagrantup.com/centos/boxes/7 Part A Ansible Controller Machine Setup Step 1 - Install VirtualBox and Vagrant on your local machine. Step 2 - Open a terminal and navigate to the directory where you want to set up your Ansible project. Step 3 - Create a new directory for your Ansible controller VM by running the command mkdir ansible-controller Step 4 - Navigate to the directory and create a new file called Vagrantfile by running the command vagrant init centos/7 Step 5 - Edit the Vagrantfile and add the lines to the end of the file to provision Ansible on the VM Vagrantfile for creating VM for Ansible Controller Vagrant.configure("2") do |config| config.vm.define "ansible-controller" do |controller| controller.vm.hostname = "controller" end config.vm.box = "centos/7" config.vm.provision "shell", inline: <<-SHELL sudo yum install epel-release -y sudo yum install ansible -y SHELL end Step 6 - Save & check its a valid vagrantfile vagrant validate Then run command vagrant up to start the VM Step 7 - Once the VM is up and running, connect to it using SSH by running the command vagrant ssh Check ansible is installed - ansible --version Step 8 - Create a new directory for your Ansible project on the controller VM by running the command mkdir ansible-project Step 9 - Navigate to the ansible-project directory and create a new file called hosts by running the command touch hosts Step 10 - Create a new file called playbook.yml. This file will contain the tasks you want to perform on your managed hosts As of now the hosts and the playbook file are empty We will now create some host machines that will be controlled by the Ansible controller Part B Ansible Host Machines Setup Step 1 - On terminal navigate to your Ansible Project folder Step 2 - Create a new directory for your host machines by running the command mkdir host-machines Step 3 - Navigate to host-machines directory and create a new Vagrantfile by running the command vagrant init centos/7 Step 4 - Edit the Vagrantfile and modify the following lines to set up two Vagrant machines: Vagrantfile for creating VMs for Ansible Host Vagrant.configure("2") do |config| config.vm.box = "centos/7" config.vm.define "web" do |web| web.vm.hostname = "web" web.vm.network "private_network", ip: "192.168.33.10" end config.vm.define "db" do |db| db.vm.hostname = "db" db.vm.network "private_network", ip: "192.168.33.11" end config.vm.network "forwarded_port", guest: 80, host: 8080, auto_correct: true config.vm.usable_port_range = (8000..9000) end Step 6 - Save & check its a valid vagrantfile vagrant validate Then run command vagrant up to start the VM Step 7 - Check the status of machines vagrant status Once the VMs are up, connect to them using SSH vagrant ssh <machine-name> e.g vagrant ssh web This completes the process of setting up host machines Part C Making connection between controller and host machines Step 1 - Make sure all machines are up and running Step 2 - Run command ip addr on each machine and check they have IP addresses in the same range (e.g. 192.168.33.x). Step 3 - On Controller machine run the command ssh-keygen to generate an SSH key pair Step 4 - Goto ~/.ssh folder and check the public and private keys generated Step 5 - Copy the public key to the host machines by running the command ssh-copy-id <user>@<host> For example, to copy the public key to the web machine, run the command ssh-copy-id [email protected] Can do this manually by copying the contents of the .pub file generated by ssh-keygen and pasting it into the ~/.ssh/authorized_keys file on the host machines Step 6 - Test the SSH connection by running the ssh command with the IP address of the host machines- For example: ssh [email protected] ssh [email protected] Due to limitation of characters I am adding notes in this PDF file - https://drive.google.com/file/d/1UHOMwQuvnIbCeSrEDeV6CO6S2ofa5Cs9/view?usp=sharing ▬▬▬▬▬▬▬ You can support my mission for education by sharing this knowledge and helping as many people as you can If my work has helped you, consider helping any animal near you, in any way you can Never Stop Learning Raghav Pal —
Upgrade Your Everyday
AI-recommended products based on this video

Kasa Smart Outdoor Smart Plug by TP-Link (KP400) - Smart WiFi Outlet with 2 Sockets, IP64 Waterproof, Works with Alexa and Google Home, 2.4GHz WiFi Required, No Hub Required, Sunset & Sunrise Offset

Oraolo Open Ear Headphones, Bluetooth 5.4 Wireless Earbuds with Stereo Sound, ENC Clear Call, 21H Playtime, Type-C Charging, Touch Control, IPX6 Waterproof Open Ear Clip-On Earbuds for outdoor workout

Open Ear Wireless Earbuds, Sports Bluetooth Headphones with Real Time Translation, 80Hrs Playtime with LED Power Display, Noise Canceling Headset, IP55 Waterproof Earphones for Workout/Running (Black)

Wireless Earbuds, Sports Bluetooth Headphones, 80Hrs Playtime Ear Buds with LED Power Display, Noise Canceling Headset, IPX7 Waterproof Earphones for Workout/Running Z(Black)

Monster Wireless Earbuds Open Ear AC311, Bluetooth 5.4 Open Ear Headphones, Up to 30 Hours Playtimes Bluetooth Ear Earphones with Stereo Sound, Touch Control and IPX5 Waterproof Open Ear Buds

Brita Stainless Steel Premium Filtering Water Bottle, BPA-Free, Reusable, Insulated, Replaces 300 Plastic Water Bottles, Filter Lasts 2 Months or 40 Gallons, Includes 1 Filter, Carbon - 20 oz.

Simple Modern Filtered Water Bottle | Insulated Stainless-Steel Carbon Filter Travel Water Bottles | Reusable for Clean Drinking Water On The Go | 24oz, Sea Glass Sage

FITVII Health & Fitness Tracker (Answer/Make Calls), Smart Watch with 24/7 Heart Rate and Blood Pressure, Sleep Tracking Monitor, 120+ Sport Mode Activity Tracker

AYATAHA AYATAHA Smart Watch for Kids, Smartwatch Fitness Tracker for Boys Girls, Children's Activity Watch 37 Sports Modes SMS Notification, HD Full Touchscreen IP67 Waterproof, Blue

Iaret Iaret Smart Watch for Women, 1.83" HD Fitness Tracker with 4 Bands, Answer/Make Calls, Heart Rate/Sleep/SpO2/Step Tracking, 100+ Sport Modes, Android/iPhone Compatible Gift (Rose Gold)

Smart Watch for Men Women 1.8" Fitness Tracker, Bluetooth Call, DIY Dial, Heart Rate Sleep Blood Oxygen Monitor, 100+ Sports Modes, IP68 Waterproof Smartwatch for Android iPhone, Alexa Built-in

Hand Warmers 2 Pack, 14000mAh Rechargeable Hand Warmers, Electric Hand Warmer Reusable, Portable Power Bank USB Hand Warmers 4 Levels 8 Heating, Gifts for Raynauds Ski Golf Camping

Hand Warmers Rechargeable, 10000mAh Electric Heated Gloves Power Bank Portable Graphene Handwarmers Pouch with 3 Levels & Double-Sided Heating for Hunting Camping Golf Xmas Gifts for Women Men Kids

2Pack Rechargeable Hand Warmer, 8000mAh Electric Hand Warmer Power Bank, Portable USB-C Hand Warmer for Pocket, Reusable Hand Warmer Up to 8 hrs Each, Warm Gift for Men Women, for Hunting, Camping

GTOCE Portable Charger,40000mAh Power Bank with 22.5W Fast Charging LED Digital Display Battery Pack with 6 Outputs 2 Inputs, Type C Powerbank Portable Charger for iPhone 16 pro Samsung AirPods,Black

Monster Sleep Ear200, Wireless in-Ear Headphones, Bluetooth 6.0 Sleep Headphones, with ANC Active Noise Cancellation Designed for Side Sleepers, 30 Hours of bass Stereo Sound.

Monster Sleep Ear100 Ear Buds, Sleep Earbuds with Stereo Sound, Design for Side Sleeper, 32H Playtime, Bluetooth 6.0, ENC Noise Cancelling, IPX6 Waterproof Mini Headphones, White

Monster Sleep Ear100 Ear Buds, Sleep Earbuds with Stereo Sound, Design for Side Sleeper, 32H Playtime, Bluetooth 6.0, ENC Noise Cancelling, IPX6 Waterproof Mini Headphones, Black

Monster Sleep Ear100 Ear Buds, Sleep Earbuds with Stereo Sound, Design for Side Sleeper, 32H Playtime, Bluetooth 6.0, ENC Noise Cancelling, IPX6 Waterproof Mini Headphones, Black

Hydroponics Growing System Indoor Garden - Herb Garden with Grow Light, 15 Pods Stainless Steel Indoor Garden Kit, Auto Timer, Gardening Gift for All Ages

Umbra Triflora Hanging Planter for Window, Indoor Herb Garden, Set of 5, White/Black

Large Hydroponics Growing System 14 Pods, Indoor Herb Garden with LED Grow Light, 5L Water Tank, Hydroponic Grow Kit with 3 Auto-Timers, Rotatable Light Panel and Child Lock for Home School Gardening

Hanging Planter Hanging Plant Holder, 6 Inch 4 Indoor Plant Pots, Wall/Window Plant Hanger Indoor Herb Garden

slopehill Multi Hair Stylers & Hair Straightener - 2 in 1 Wet to Dry Air Straightener and Hair Dryer Combo with High Speed Air + Rapid Heat-Up + Customizable Temperature(Pink)

Hi.FANCY Portable Laptop Stand with Dual Cooling Fans for 14-17inch Laptops, Grey, 23.5 x 25.9 x 0.95cm

Laptop Stand for Desk, Adjustable Laptop Riser ABS+Silicone Foldable Portable Laptop Holder, Ventilated Cooling Notebook Stand for 10-15.6” Laptops,Tablet-Black

JETech 5 in 1 Case for Samsung Galaxy S25 Ultra 5G with 2-Pack Each Tempered Glass Screen Protector and Camera Lens Protector, Non-Yellowing Shockproof Bumper Phone Cover (Clear)

TAURI for iPhone 17 Pro Max Case 6.9" with 1-Pack Screen Protector, Camera Lens Full Protection, Military-Grade Protection, Shockproof Transparent Back Bumper Phone Cover - Clear Global Recycled Standard

TAURI for iPhone 17 Pro Case 6.3" with 1-Pack Screen Protector, Camera Lens Full Protection, Military-Grade Protection, Shockproof Transparent Back Bumper Phone Cover - Clear Global Recycled Standard

JOINPAYA 1Set Rechargeable Hand Warmer Hand Heater for Winter Heating Levels Compact

Shakven Rechargeable Hand Warmer | Cute Comfortable Portable Hand Warmers,Ergonomic Adjustable Energy-Efficient Small Heater for Travel, Outdoor, Winter

OCOOPA IP45 Waterproof Hand Warmer Rechargeable, Up to 15hrs Heat,10000mAh Durable Quick Charge Electric Hand Heater, PD Compatible, 3 Levels for Outdoors, Heavy Duty, H01-PD PRO



















