Ansible Lab setup in Linux
Prerequisite:
- VMware workstation
- Centos, fedora operating system iso files.
- Install 2 machines one Control node and one for managed hosts.
Step 1: Install VMWare Workstation
Step 2: Install workstation and server Operating system (GUI)
- Minimum partition 20 GB
- Username and password
$username: student $ password: student
Step 3: select virtual machine and clone as a servera
Step 4: open workstation
- Set the static IP address: 192.168.80.11/24
- Set hostname:
o hostnamectl set-hostname workstation.lab.example.com
- Username student as root access
o vim /etc/sudoers.d/student
student ALL=(ALL) NOPASSWD:ALL
o chmod 0440 /etc/sudoers.d/student
o su – student or sudo su –
- Add hosts entry
o vim /etc/hosts
192.168.80.11 workstation.lab.example.com workstation
192.168.80.12 servera.lab.example.com servera
Step 5: open Managed hosts
- Set the static IP address :
o 192.168.80.12/24
- Set hostname:
o hostnamectl set-hostname servera.lab.example.com
- Username student as root access
o vim /etc/sudoers.d/student
- student ALL=(ALL) NOPASSWD:ALL
o chmod 0440 /etc/sudoers.d/student
o su – student or sudo su –
- Add hosts entry
o vim /etc/hosts
192.168.80.11 workstation.lab.example.com workstation
192.168.80.12 servera.lab.example.com servera
- Check ping working in both machine
o ping workstation or ping servera
Step 6: passwordless authentication
- ssh-keygen
- ssh-copy-id [email protected]
- ssh servera
Step 7: install ansible in workstation
- sudo yum install epel-release
- sudo yum install ansible
Step 8: Run ansible simple program.
MD @networknuts | Hiring RedHat Instructors
3 年This is good but often when working with a large number of managed hosts, one cannot manually add the NOPASSWD line to sudoers of hundreds of severs.