Ansible Lab setup in Linux

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.

No alt text provided for this image

 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

No alt text provided for this image

Step 3: select virtual machine and clone as a servera

No alt text provided for this image

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

No alt text provided for this image
No alt text provided for this image

Step 7:   install ansible in workstation

  •  sudo yum install epel-release
  •  sudo yum install ansible

Step 8:  Run ansible simple program.

No alt text provided for this image
No alt text provided for this image


Aryan Srivastava

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.

回复

要查看或添加评论,请登录

Ashish G.的更多文章

社区洞察

其他会员也浏览了