Wednesday, January 08, 2020

Ansible using Oracle Virtual box

Please follow below given step religiously else VM installation will not be as per requirement and everytime new instance creation will take time
'- Installation of Oracle Virtual box, download site https://www.virtualbox.org/wiki/Downloads or https://download.virtualbox.org/virtualbox/6.1.0/VirtualBox-6.1.0-135406-Win.exe as we are using windows so VirtualBox-6.1.0-135406-Win.exe
'- Centos os ISO image download, download site:- https://wiki.centos.org/Download we are using Centos 7 version of ISO CentOS-7-x86_64-DVD-1908.iso having size 4.5 GB.
'- As we will requiring two machine one server where Ansbile will be installed and client where we want to execute module we need to create main network NAT so that two machine can have different ip and can ping each other
Please follow below given steps
1- File -->preference
Image1Image2
2- Now let create our 2 virtual machine one for server where we will install our Ansible and another our client we will connect using ssh and execute out module
Ansible - Controller machine or server or Localmachine [Ansible will be installed on this box] and Ansible- client machine use the same step for both the virtual machine.
Please follow below step to create Controller machine
Image3Image4Image5Image6Image7Image8Image9Image10

Now lets do configuration of this newly created machine by clicking on setting

Image11Image12Image13Image14Image15Image16Image17
'- After installation machine and it is up check following things. [Note make sure to chose GNOME package in Centos for better UI]


'- it can access internet, if no internet configuration ifup command. and check we get the internet using ping google.com

'- Check the list of the files above folder contains and find the one that is needed by your i.e. ifcfg-eth0 or ifcfg-eth03 etc
No_Internet1

'- Open this files i.e. vi /etc/sysconfig/network-scripts/ifcfg-eth03 and check if ONBOOT="yes"

No_Internet2

ifup.JPG
'- check both server and client machine has different ip using ifconfig
'- Check both of them can ping each other and have ssh access to eachother.Atleast server or controller machine can do ssh on client machine
Image18
'- install ansible , configure host, create yml files
To insall ansible use below command
yum install ansible -y
let the installation be complete
'- now lets modify the host file also called as inventory in ansible to inform where is the client and how to connect it
#siddhu.yml
---
- hosts: siddhu_ansible_clients
tasks:
- name: run echo command
command: /bin/echo hello world
Image19Image20
'- now create a simple yml file lets call it as siddhu.yml with following commands line

Image21Image22
'- Finally run the below command and check if our ansible is able to connect the client and execute the code properly

Image23
Note :- If you get below error then apply the solution given in the screen

error1

No comments: