WhatsApp Group

The next version of Ubuntu is here!

Friday, 21 December 2018

How to setup Puppet (Master and Clients) on Ubuntu 18.04 Server


How to setup Puppet Master and Clients on Ubuntu 18.04 Server: *****************************************************************************************************
This entire process has been divided into the following six parts.
1. Base server configuration.
2. Puppet repo configuration.
3. Puppet master configuration.
4. Puppet client configuration.
5. Initiating the Puppet Modules.
6. Module testing.

Assuming We having three Ubuntu systems with the following configurations:
1. One Ubuntu 18.04, 64 bit Server with 4+ Gib RAM, 4+ core processor, and 100 Gib HDD space.
2. Two or more Ubuntu 18.04, 64 bit Server/Desktop with 2+ Gib RAM, 2+ core processor and 100+ Gib HDD space.

Step 1.
Base server configuration.
First of all, we are going to set up a Puppet master server.

A. Configure Static IP :
Open file : /etc/netplan/50-cloud-init.yaml, and made it as follows:
# vim /etc/netplan/50-cloud-init.yaml
**********************************************************
network:
ethernets:
ens3:
addresses:
- (IP Address)/(Subnet)
dhcp4: false
gateway4: (Router IP)
nameservers:
addresses:
- 8.8.8.8
search: [your Domain Name]
version: 2
**********************************************************
Apply your changed IP in your system :
# netplan apply

B. Change the host name with FQDN
Open a file called:

/etc/cloud/cloud.cfg
and change preserve_hostname: false to preserve_hostname: true
Then Open file called /etc/hosts
# vim /etc/hosts

and defien your FQDN along with the IP as well disable all IPV 6

**********************************************************
(your system IP) (your FQDN)
**********************************************************
Then open file called: /etc/hostnameame
and define your FQDN here.
#vim /etc/hostnameame
**********************************************************
(your FQDN)
**********************************************************
Then change your FQDN as:
# hostnamectl set-hostname (your FQDN)
Reboot the system:
# init 6

Step 2.
Puppet repo configuration.
Add these repo to the file called : /etc/apt/sources.list
deb http://archive.ubuntu.com/ubuntu bionic universe
deb http://archive.ubuntu.com/ubuntu bionic-security universe
deb http://archive.ubuntu.com/ubuntu bionic-updates univers
# vim /etc/apt/sources.list
**********************************************************
deb http://archive.ubuntu.com/ubuntu bionic main
deb http://archive.ubuntu.com/ubuntu bionic-security main
deb http://archive.ubuntu.com/ubuntu bionic-updates main
#######
deb http://archive.ubuntu.com/ubuntu bionic universe
deb http://archive.ubuntu.com/ubuntu bionic-security universe
deb http://archive.ubuntu.com/ubuntu bionic-updates universe
**********************************************************
Then update and upgrade your system:
# apt update && apt upgrade
Now Downlaod puppetlabs repo and install:
# wget https://apt.puppetlabs.com/puppet6-release-bionic.deb
Install above downloaded pack:
# dpkg -i puppet6-release-bionic.deb
Update & upgrade the system:
# apt update && apt upgrade
Step 3.
Puppet master server configuration:
Installing the puppet Master server
# apt-get install puppetserver
Allocate memory to puppet master server:
Open a file called: /etc/default/puppetserver and find the following line
JAVA_ARGS="-Xms2g -Xmx2g -Djruby.logger.class=com.puppetlabs.jruby_utils.jruby.Slf4jLogger"
In above line Change -Xms2g -Xmx2g by -Xms1g -Xmx1g

Now open a file called: /etc/puppetlabs/puppet/puppet.conf and make it as follows:
# vim /etc/puppetlabs/puppet/puppet.conf
**********************************************************
[master]
vardir = /opt/puppetlabs/server/data/puppetserver
logdir = /var/log/puppetlabs/puppetserver
rundir = /var/run/puppetlabs/puppetserver
pidfile = /var/run/puppetlabs/puppetserver/puppetserver.pid
codedir = /etc/puppetlabs/code
dns_alt_names = (your system FQDN)
environment_timeout = 0

[main]
certname = (your system FQDN)
server = (your system FQDN)
environment = production
runinterval = 35m
**********************************************************

Again, open a file called: /etc/puppetlabs/code/environments/production/environment.conf and uncomment following line:
modulepath = ./modules:$basemodulepath
# vim /etc/puppetlabs/code/environments/production/environment.conf **********************************************************
# Allowed settings and default values:
modulepath = ./modules:$basemodulepath
**********************************************************

Reboot the system:
# init 6

Step 4.
Puppet client configuration.
Follow above Step 1 and Step 2 in your Puppet server clients.
Then Install Puppet Agent in your Puppet client server:

# apt install puppet-agent

Now open a file called: /etc/puppetlabs/puppet/puppet.conf and edit as follows:
# vim /etc/puppetlabs/puppet/puppet.conf
**********************************************************
[main]
certname = (your puppet client FQDN)
server = (your puppet master FQDN)
environment = production
runinterval = 35m
**********************************************************

Reboot the system:
# init 6

Step 5.
Initiating the Puppet Modules.
Log in into your Puppet master system
Create CA for Puppet Master Server
# systemctl disable puppetserver
# systemctl stop puppetserver
# /opt/puppetlabs/bin/puppetserver ca setup
Start your puppet master server.
# systemctl start puppetserver
# systemctl enable puppetserver

Log in into your puppet client/s server/s and start your puppet agent
# systemctl start puppet
# systemctl enable puppet


Again Log in into your Puppet master system
Find the certificate signing request from puppet client/s
# /opt/puppetlabs/bin/puppetserver ca list
First time the output lookalike :
Requested Certificates:
(your puppet client FQDN)(SHA256) B9:A1:16:D2:7D:BD:12:44:A4:C8:15:16:7A:A5:88:A7:D1:2C:20:AD:16:C4:AE:04:1A:F8:11:A4:FF:B2:15:AD
Need to accept certificate signing request by your puppet master server
# /opt/puppetlabs/bin/puppetserver ca sign --certname (your puppet client FQDN as displayed in Requested Certificates)
Now log in into your puppet client/s system and put below command
# /opt/puppetlabs/bin/puppet agent -t
If the output are as mentioned below..... then all is good !
Info: Using configured environment 'production'
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Retrieving locales
Info: Loading facts
Info: Caching catalog for (your puppet client FQDN)
Info: Applying configuration version '1545417591'
Notice: Applied catalog in 0.14 seconds

Step 6.
Module testing.
In module testing, I am going to create
1. A file "ajay.txt"
2. Create a n user "karn"
in puppet client/s from my puppet master server.

For this, go to the directory :

/etc/puppetlabs/code/environments/production/manifests/
and create a file "nodes.pp".
# vim nodes.pp
**********************************************************
node '(your puppet client FQDN)' {
file { '/home/ajay/test.txt':
content => "This is a test file\n",
}
user { 'karn':
ensure => present,
home => '/home/karn',
managehome => true,
password => '$6$WNZOtHIQZEnok$q6.uPSlTqbrrzLdvi/5wTjgKVHP5TY06A5Yh7H4xS9STSHo0e.Tyqt2XLpca5Y7AV2H7q7SzQ/9z.NMfVm/H7.',
}
}
**********************************************************
For password, I used SHA1 password hash.
Log in to a system and use following command to create SHA1 password has
# mkpasswd -m sha-512
Now restart puppet master server:
# systemctl restart puppetserver
# systemctl enable puppetserver

Then log in to your puppet client server and run this command if want to execute module instantly, else it will auto execute after define time as in your puppet master server
# /opt/puppetlabs/bin/puppet agent -t
Now check the file and user in your puppet client.
Hoping... you can able to find both.


© Ajay Kumar Karn-2018-19



Thursday, 29 November 2018

How to mount & use, Google Drive, in Ubuntu 18.04


How to mount Google Drive in Ubuntu 18.04: *****************************************************************************************************
For using your Google drive in Ubuntu 18.04 Desktop, need to install "Gnome Online Accounts"

$ sudo apt install gnome-online-accounts



Now open "Gnome Online Accounts"

$ gnome-control-center online-accounts


Choose "Google"

Login with your Google user name and password

Allow access

Grant access what you want to sync

Remember... If using Gnome Online Accounts for your Google Drive ,your Google Drive files are not stored locally in your computer.
For Downloading your Google Drive file/s locally, you need to install this pack.

$ sudo add-apt-repository ppa:alessandro-strada/ppa


$ sudo apt install google-drive-ocamlfuse



Now create a directory where you are going to download your Google Drive file locally.

$ mkdir ~/Google_Drive



Now point your Google Drive files to your newly created directory.

$ google-drive-ocamlfuse ~/Google_Drive

It will ask you your google credential.
Kindly provide your "google" user ID and respective password.



At the end, allow to access your Google Drive .

Now Open your File Manager, and you can able to see your Goole drive mounted under your created directory Google_Drive
.





© Ajay Kumar Karn-2018-19



Sunday, 4 November 2018

How to configure Base System for KVM based Virtual machine and installing VM In Ubuntu 18.04


Call Sysadmin: *****************************************************************************************************
How to configure Base System for KVM based Virtual machine and installing VM In Ubuntu 18.04

Requirements:

1. Ubuntu 18.04 LTS 64 bit Desktop System (you can use server too).
2. Minimum 8GiB RAM, 1TiB HDD and I/O MMU virtualization (AMD-Vi and Intel VT-d) Chipset.
3. Gigabyte Ethernet Adapter.

Verifying Hardware

Open a terminal and insert this command:

# lscpu

In Output,if showing Virtualization: VT-x, then your Hardware support Virtualization.


Installing required packages in base system:

Open a terminal and insert these commands:

# apt-get update
#apt-get upgrade -y
#apt-get install qemu-kvm libvirt-bin ubuntu-vm-builder bridge-utils tightvncserver -y

Now Configure Bridge Network
For this, open a file /etc/network/interfaces

# vim /etc/network/interfaces

auto lo
iface lo inet loopback
#####################
auto lo
iface lo inet loopback
auto br0
iface br0 inet static
address YOUR IP ADDRESS
netmask YOUR SUBNET MASK
network YOUR NETWORK
broadcast LAST IP ADDRESS OF YOUR NETWORK
gateway YOUR GATEWAY
dns-nameservers 8.8.8.8
bridge_ports YOUR ETHERNET ADAPTER NAME
bridge_stp off
bridge_maxwait 0

Now create directories then create qcow2 file (Disk) and xml file.

# mkdir ~/vm; ~/vm/qcow2; ~/vm/xml
# qemu-img create -f qcow2 disk.qcow2 125G
Create a xml file for defining your Virtual system:

# vim ~/vm/xml/first_vm.xml

[domain type='kvm']
[name]first_vm[/name]
[uuid]d846fc14-c72a-3a38-8c8c-113f1e9a1002[/uuid]
[memory unit='KiB']4194304[/memory]
[currentMemory unit='KiB']4194304[/currentMemory]
[vcpu placement='static']2[/vcpu]
[os]
[type arch='x86_64' machine='pc-i440fx-bionicbeaver']hvm[/type]
[boot dev='cdrom'/]
[boot dev='hd'/]
[/os]
[features]
[acpi/]
[/features]
[clock offset='utc'/]
[on_poweroff]destroy[/on_poweroff]
[on_reboot]restart[/on_reboot]
[on_crash]destroy[/on_crash]
[devices]
[emulator]/usr/bin/kvm[/emulator]
[disk type='file' device='disk']
[driver name='qemu' type='qcow2'/]
[source file='/home/linux4it/vm/disk/disk.qcow2'/]
[target dev='hda' bus='ide'/]
[address type='drive' controller='0' bus='0' target='0' unit='0'/]
[/disk]
[disk type='file' device='cdrom']
[driver name='qemu' type='raw'/]
[source file='/home/linux4it/Ubuntu-18.04-LTS-Server.iso'/]
[target dev='hdc' bus='ide'/]
[readonly/]
[address type='drive' controller='0' bus='1' target='0' unit='0'/]
[/disk]
[controller type='usb' index='0' model='piix3-uhci']
[address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/]
[/controller]
[controller type='pci' index='0' model='pci-root'/]
[controller type='ide' index='0']
[address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/]
[/controller]
[interface type='bridge']
[mac address='aa:54:6d:64:7a:a8'/]
[source bridge='br0'/]
[model type='rtl8139'/]
[address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/]
[/interface]
[input type='mouse' bus='ps2'/]
[input type='keyboard' bus='ps2'/]
[graphics type='vnc' port='-1' autoport='yes' listen='0.0.0.0']
[listen type='address' address='0.0.0.0'/]
[/graphics]
[video]
[model type='cirrus' vram='16384' heads='1' primary='yes'/]
[address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/]
[/video]
[memballoon model='virtio']
[address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/]
[/memballoon]
[/devices]
[/domain]


Use "<" and ">" in place of "[" and "]" in your xml file


For Youtube Video(Installing Package and configuring Bridge Network), Click here


For Youtube Video(Creating qcow2 file), Click here


For Youtube Video(Creating xml file -Part1), Click here

For Youtube Video(Creating xml file -Part2), Click here

Now define xml file.

# virsh define [PATH OF YOUR XML FILE]


For Youtube Video(Define your xml file and start your VM - Part-01), Click here

For Youtube Video(Define your xml file and start your VM - Part-02), Click here

Now Boot your VM through ISO file and install the OS (Ubunru 18.04 LTS 64 bit Server).

Open your running VM through VNC Viewer:
# vncviewer [YOUR BASE SYSTEM IP:5900]
Now follow the onscreen instructions
All processes are shown in below linked youtube videos.

For Youtube Video(Installing your VM - Part-01), Click here

For Youtube Video(Installing your VM - Part-02), Click here

For Youtube Video(Installing your VM - Part-03), Click here

After finishing the VM installation, destroy your running VM by using this command:
# virsh destroy [YOUR RUNNING VM NAME]
Now remove CD drive from your defined xml file, by removing mentioned file and boot record.
# vim /etc/libvirt/qemu/[YOUR DEFINED XML FILE NAME]

[domain type='kvm']
[name]first_vm[/name]
[uuid]d846fc14-c72a-3a38-8c8c-113f1e9a1002[/uuid]
[memory unit='KiB']4194304[/memory]
[currentMemory unit='KiB']4194304[/currentMemory]
[vcpu placement='static']2[/vcpu]
[os]
[type arch='x86_64' machine='pc-i440fx-bionicbeaver']hvm[/type]
[boot dev='cdrom'/]
[boot dev='hd'/]
[/os]
[features]
[acpi/]
[/features]
[clock offset='utc'/]
[on_poweroff]destroy[/on_poweroff]
[on_reboot]restart[/on_reboot]
[on_crash]destroy[/on_crash]
[devices]
[emulator]/usr/bin/kvm[/emulator]
[disk type='file' device='disk']
[driver name='qemu' type='qcow2'/]
[source file='/home/linux4it/vm/disk/disk.qcow2'/]
[target dev='hda' bus='ide'/]
[address type='drive' controller='0' bus='0' target='0' unit='0'/]
[/disk]
[disk type='file' device='cdrom']
[driver name='qemu' type='raw'/]
[source file='/home/linux4it/Ubuntu-18.04-LTS-Server.iso'/]
[target dev='hdc' bus='ide'/]
[readonly/]
[address type='drive' controller='0' bus='1' target='0' unit='0'/]
[/disk]

[controller type='usb' index='0' model='piix3-uhci']
[address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/]
[/controller]
[controller type='pci' index='0' model='pci-root'/]
[controller type='ide' index='0']
[address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/]
[/controller]
[interface type='bridge']
[mac address='aa:54:6d:64:7a:a8'/]
[source bridge='br0'/]
[model type='rtl8139'/]
[address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/]
[/interface]
[input type='mouse' bus='ps2'/]
[input type='keyboard' bus='ps2'/]
[graphics type='vnc' port='-1' autoport='yes' listen='0.0.0.0']
[listen type='address' address='0.0.0.0'/]
[/graphics]
[video]
[model type='cirrus' vram='16384' heads='1' primary='yes'/]
[address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/]
[/video]
[memballoon model='virtio']
[address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/]
[/memballoon]
[/devices]
[/domain]

In above mentioned file, remove RED contents from your defined file and save it.

Now again define your saved XML file and start your vm

# virsh define /etc/libvirt/qemu/[YOUR DEFINED XML FILE NAME]

# virsh start [YOUR DEFINED VM NAME]

For Youtube Video, Click here

Hence You can use your installed VM.

********************************************************************

आप हमें YouTube पर भी, देख और सुन सकतें हैं।
मेरे YouTube Chanel को देखने हेतु, यहाँ click करें।
आपकी टिप्पणियाँ और सुझाव की,मैं सराहना करता हूँ।
आप मुझे,ajay.karn@gmail.com पर लिख सकते हैं।


HOME





© Ajay Kumar Karn-2018-19