Installation setup of ansible in linux step by step guide



Installation Setup Of Ansible on Linux | In this article we learn about the installation setup of ansible



Two types of machines are required to create ansible deployment setup



Control machine: Ansible needs to install on one machine.This machine is called control machine.

Remote machine: need to define the systems in the inventory file (which is the text file) on which configuration will done.Overall we can say which machine is controlled by control machine is called remote machine.

Many remote machines are handled by one controlling machine.  For that purpose we need to install ansible on the controlling machine. 

Installation Requirement to setup ansible

Python2 and Python3 must be installed to run the ansible.

NOTE:Windows  isn’t supported for the control machine

Ansible does not required database and does not required any daemon to run the ansible service .Ansible connect to the remote nodes through ssh by default.

How to install ansible on centos 7/rhel 7/Ubuntu 16.04

To install the ansible package on rhel machine you need to enable epel repo.

After install and enabling  epel repository, we can install Ansible using below command.
yum install ansible -y

installation setup of ansible
installation setup of ansible

After running the above command you can manage remote machine through ansible.

In Ubuntu there is no need to install extra repository. By default ansible package is available in Ubuntu. We can install ansible in Ubuntu using the below command.

apt-get install ansible -y

After installing ansible  we can verify the version of ansible by hitting the  below command.
ansible --version

ansible version,installation setup of ansible
ansible version
If this aticle is helpful to know about Installation Setup Of Ansible on Linux please share this article.



Please Donate To Bitcoin Address: [[address]]
Donation of [[value]] BTC Received. Thank You.
[[error]]

Brief Introduction of Ansible

Brief Introduction of Ansible

Ansible is an IT automation open source tool which automates application deployment,managing and configuring on many numbers of systems very easily and doing infra service orchestration ,cloud provisioning and many other things.


What is Ansible


Ansible is an IT automation open source tool which automates application deployment,managing and configuring on many numbers of systems very easily and doing infra service orchestration ,cloud provisioning and many other things.



Ansible is very easy to deploy because it does not use any agents on the client side.

Ansible uses playbook to execute automation jobs and Play book uses YAML language which is very simple language and easy to understand for the human.



Ansible is totally agentless which means Ansible works by associating your hubs through ssh(by default). 

In the wake of associating with your hubs, Ansible pushes little projects called as "Ansible Modules".  Ansible runs that modules on your hubs and evacuates them when wrapped up. Ansible manages your inventory in simple text files (These are the hosts file). Ansible uses the hosts record where one can aggregate the hosts and can control the activities on a particular gathering in the playbooks.

 Introduction of Ansible
Ansible

Advantage of Ansible

  • Agentless: Ansible is completely agentless which means Ansible works by connecting your nodes through ssh.
  • Documentation: Documentation of ansible is very simple and easy
  • Ansible uses YAML language which is very simple language and easy to understand.
  • Ansible is open source IT automation tools.

yum:
     name: httpd
     state: latest
     
The above task connect to the node and check if httpd package is already installed and it is latest version or not.If it it latest version nothing will be happen. 

How ansible works

Ansible need to be installed on one machine its called control machine and need to define the systems in the inventory file which is the text file on which configuration will done.
In the wake of associating with your hubs, Ansible pushes little projects called as "Ansible Modules".  Ansible runs that modules on your hubs and evacuates them when wrapped up. Ansible manages your inventory in simple text files (These are the hosts file). Ansible uses the hosts record where one can aggregate the hosts and can control the activities on a particular gathering in the playbooks.






Please Donate To Bitcoin Address: [[address]]
Donation of [[value]] BTC Received. Thank You.
[[error]]

Snapshot of Logical Volume and Restore in LVM on Rhel 7/Centos 7/Oracle 7 Linux



LVM Snapshots of Logical Volume  on Rhel 7/Centos 7/Oracle 7 Linux  are space productive pointing time duplicates of lvm volumes. 

It works just with lvm and expend the space just when changes are made to the source intelligent volume to depiction volume. 

If source volume has a huge changes made to sum of 500MB the same changes will be made to the snapshot volume.
Incase the preview comes up short on capacity, we can utilize lvextend to develop.

On the off chance that we have incidentally erased any record in the wake of making a Snapshot we don't need to stress in light of the fact that the preview have the first document which we have erased.

To remove the snapshot we can use lvremove command.


Step 1: Create LVM Snapshot


First, check for free space in volume group to create a new snapshot.For that we are using using following vgs command.

# vgs

 VG       #PV #LV #SN Attr   VSize VFree
  VolGroup   1   2   0 wz--n- 7.51g    0
  testvg     2   1   0 wz--n- 3.99g 1.99g

# lvs
LV      VG       Attr       LSize   Pool Origin Data%  Move Log Cpy%Sync Convert
  lv_root VolGroup -wi-ao----   6.71g
  lv_swap VolGroup -wi-ao---- 816.00m
  testlv  testvg   -wi-ao----   2.00g

You see, there is 1.99GB of free space left in above vgs output. So, let’s create a snapshot for one of my volume named testlv.
For an example we are going to create only 1GB snapshot volume using following commands.


# lvcreate -L 1GB -s -n testlv_snap /dev/testvg/testlv
  Logical volume "testlv_snap" created

Where

1GB= Size of snapshot Iam creating here.
-s= Creates snapshot.
-n= Creates name for the snapshot.
testlv_snap= New snapshots name.
/dev/testvg/testlv= Volume which we are going to create a snapshot.


Snapshot of Logical Volume and Restore in LVM
create snapshot
We can use the below command to list new created snapshot. 

# lvs
  LV          VG       Attr       LSize   Pool Origin Data%  Move Log Cpy%Sync Convert
  lv_root     VolGroup -wi-ao----   6.71g
  lv_swap     VolGroup -wi-ao---- 816.00m
  testlv      testvg   owi-aos---   2.00g
  testlv_snap testvg   swi-a-s---   1.00g      testlv   0.00



Snapshot of Logical Volume and Restore in LVM
List snapshot


You see above, a snapshot was created successfully. 

# df -Th /dev/mapper/testvg-testlv
Filesystem                Type  Size  Used Avail Use% Mounted on
/dev/mapper/testvg-testlv ext4  2.0G   67M  1.9G   4% /testlvm


Let’s add some new files into testlv. 

Now check the volume using the follwing command.

#lvs

 LV          VG       Attr       LSize   Pool Origin Data%  Move Log Cpy%Sync Convert
  lv_root     VolGroup -wi-ao----   6.71g
  lv_swap     VolGroup -wi-ao---- 816.00m
  testlv      testvg   owi-aos---   2.00g
  testlv_snap testvg   swi-a-s---   1.00g      testlv   0.13

You see, 0.13% of snapshot volume was used now.

If we copy more than 1GB of files in testlV you will get error message appear On the screen  Input/output error, it means out of space in snapshot.



Step 2: Extend Snapshot in LVM




First we check available PE using vgdisplay command

# vgdisplay
  --- Volume group ---
  VG Name                    testvg
  System ID
  Format                        lvm2
  Metadata Areas          2
  Metadata Sequence No  4
  VG Access               read/write
  VG Status                resizable
  MAX LV                  0
  Cur LV                    2
  Open LV                 1
  Max PV                   0
  Cur PV                    2
  Act PV                    2
  VG Size                 3.99 GiB
  PE Size                 4.00 MiB
  Total PE                1022
  Alloc PE / Size       768 / 3.00 GiB
  Free  PE / Size       254 / 1016.00 MiB
  VG UUID               mz7AN3-jsR0-rnsQ-XpvM-2W0N-M8q8-pki2kB

# lvextend -l +254 /dev/testvg/testlv_snap
 Extending logical volume testlv_snap to 1.99 GiB
  Logical volume testlv_snap successfully resized

Now verify the size using the below command. 

# lvdisplay /dev/testvg/testlv_snap

 --- Logical volume ---
  LV Path                /dev/testvg/testlv_snap
  LV Name                testlv_snap
  VG Name                testvg
  LV UUID                eVvo1m-OZhv-PfP2-caja-r67k-W2o6-PD9Fcm
  LV Write Access        read/write
  LV Creation host, time localhost.localdomain, 2018-06-16 08:17:05 +0530
  LV snapshot status     active destination for testlv
  LV Status              available
  # open                 0
  LV Size                2.00 GiB
  Current LE             512
  COW-table size         1.99 GiB
  COW-table LE           510
  Allocated to snapshot  0.07%
  Snapshot chunk size    4.00 KiB
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:3


# lvs

 LV          VG       Attr       LSize   Pool Origin Data%  Move Log Cpy%Sync Convert
  lv_root     VolGroup -wi-ao----   6.71g
  lv_swap     VolGroup -wi-ao---- 816.00m
  testlv      testvg   owi-aos---   2.00g
  testlv_snap testvg   swi-a-s---   1.99g      testlv   0.07


Step 3: Restoring Snapshot or Merging



To restore the snapshot, we need to un-mount the file system first.

# unmount /testlvm

Just check for the mount point whether its unmounted or not.

# df -h

Here our mount has been unmounted, so we can continue to restore the snapshot. To restore the snap using command lvconvert.

# lvconvert --merge /dev/testvg/testlv_snap
 Merging of volume testlv_snap started.
  testlv: Merged: 100.0%
  Merge of snapshot into logical volume testlv has finished.
  Logical volume "testlv_snap" successfully removed


After the merge is finished, snapshot  volume will be expelled naturally. Now we can check partition space using the below command.

# df -Th

If this article is helpful to know about LVM Snapshots on Rhel 7/Centos 7/Oracle 7 Linux and restore the snapshot please share and subscribe this article.



How to Extend Logical Volume in rhel 7/Centos 7/Oracle 7 Linux LVM



Extend Logical Volume In rhel 7/CentOS 7/ Oracle 7 |In creating Logical Volume section we create testlv with 5GB

We want to increase the size of  the LV from 5GB to 10GB

we can do it two different ways

1. Extend LV Size with new hardDisk 

2. Extend LV Size from extra space of existing VG 

Extend LV Size  with new hardDisk 


We add new disk /dev/sde to LVM using  ‘fdisk ’ command

To do this activity we need to execute the below command. 

# fdisk /dev/sde

  • Type ‘n’ to create new partition

  • Afer that type ‘p’ to create the primary partition 

  • After that we need to enter first and last cylinder value.

  • Then type ‘t’ and we will enter the partition id to create LVM . Now we need to enter 8e and press w to save change.

Now our disk is prepared to add our existing LV. We have to follow the below steps.

 Create Physical volume
Now we create a Physical volume by executing the following command

# pvcreate /dev/sde

To Check PV we use ‘pvdisplay’ command,

Extend Volume group ‘testvg’ to add /dev/sde
# vgextend testvg /dev/sde

To Verify new VG Size we execute  ‘vgdisplay’ command

Extend Logical volume ‘testlv’ we need to follow below command.

# lvextend –L +5G /dev/testvg/testlv



Extend logical volume
Extend logical volume


Here, ‘-L +5G’ means that the size of LV’testlv’ will  increased by 5GB, we can verify the new size by executing ‘lvdisplay’ command.

But the LV Size is not affected.After execute the resize command the new LV Size will be affected.

To resize the filesystem we need to execute the below command.
# resize2fs /dev/testvg/testlv

To verify new LV Size we execute lvdisplay command.


Extend LV Size from  extra space of testvg


Lets take an example  we have 2 GB extra space in our existing Volume Group ‘testvg’ . we add that extra space  to our lv to inctease the size by following  the below process.


Extend Logical volume ‘testlv’ execute the below command.
# lvextend –L +2G /dev/testvg/testlv

To resize the filesystem we need to execute the below command.
# resize2fs /dev/testvg/testlv

To verify new LV Size we execute lvdisplay command.

If this article is helpful to know about Extend Logical Volume In rhel 7/CentOS 7/ Oracle 7 please share and subscribe this article.