Monday, September 25, 2023

1) Search and replace text script  -- script name replace.sh


#!/bin/bash
# script to search and replace text and take backup file
if [ $# != 3 ] ; then
echo "Input error : syntax replace < search path> <search string> < replace string>
exit 1
elif [ ! -e $1 ] ; then
echo "Given Path $1 doesnt exist"
exit 1
else
find $1 -type f -iname *.log -exec sed -i-$(date +%d-%m-%y) "s/$2/$3/g" {} \;
exit 0
fi

2) Execution outcome 



Tuesday, May 12, 2020

Ubuntu 20.4 manual ip config

1) cat /etc/netplan/00-installer-config.yaml 
# This is the network config written by 'subiquity'
network:
  ethernets:
    enp0s3:
      dhcp4: no
      addresses: [192.168.0.200/24]
      gateway4: 192.168.0.1  
      nameservers:
              addresses: [8.8.8.8,8.8.4.4]
  version: 2
2) netplan apply

3) ip a

Saturday, October 19, 2019

ocp 3.9 origin installation on centos 7

1) install required packages 

yum install -y wget git  nano net-tools docker-1.13.1 bind-utils iptables-services bridge-utils bash-completion kexec-tools sos psacct openssl-devel httpd-tools NetworkManager python-cryptography python-devel python-passlib java-1.8.0-openjdk-headless "@Development Tools";

2) Add ansible repo for 2.6 version 

[ansible]
name = Ansible Repo
baseurl = https://releases.ansible.com/ansible/rpm/release/epel-7-x86_64/
enabled = 1
gpgcheck =  0

3) update centos 7

yum update -y

4) start and enable docker 

systemctl start docker && systemctl enable docker && systemctl status docker

5) install ansible 2.6 required for ocp 3.9 ansible playbook 

yum -y install ansible-2.6* pyOpenSSL

6) clone ansible repository 

git clone https://github.com/openshift/openshift-ansible.git -b release-3.9

7) create ssh key and copy to target system 

ssh-keygen
ssh-copy-id   master infra worker

7) edit inventory ini for 1 master 1 worker and 1 infra node without LB


8) Run playbooks

ansible-playbook -i inv.ini playbooks/prepare.yml
ansible-playbook -i inv.ini playbooks/deploy_cluster.yml

Wednesday, February 14, 2018

Linux command line proxy / docker proxy configuraiton

Linux command line proxy configuration 

 If your system  placed in the restricted network and it  require to connect Internet through proxy server then you need to setup proxy server configuration by exporting http_proxy  or https_proxy linux environment value.

syntax :

export http_proxy=http://username:password@proxyserver:proxyport

export https_proxy=https://username:password@proxyserver:proxyport

example:

export http_proxy=http://kamal:kamal@myproxy.mynetwork.com:8080

export https_proxy=http://kamal:kamal@myproxy.mynetwork.com:8443

if you want to revert http_proxy config then simply type  $unset http_proxy from linux command prompt .

Docker proxy configuration

Same way you need to setup proxy configuration for docker too so that you can download / search / push / pull docker images from public docker registry.

by default docker wont take proxy config from environment variable you need to config by creating http-proxy.config file in the docker service directory.

1) Create a directory path and config file as a root user ( remember your user need to be a member of docker group or you must be a root user to perform this docker config by default directory and configuration file doesn't exist  )

# mkdir -p /etc/systemd/system/docker.service.d

vi /etc/systemd/system/docker.service.d/http-proxy.conf    or      #vi /etc/systemd/system/docker.service.d/https-proxy.conf

2) Edit docker proxy  config file
  
#vi /etc/systemd/system/docker.service.d/https-proxy.conf
[Service]
Environment="HTTP_PROXY=http://kamal:durai@proxy.myserver.com:8080"

3)Reload systems daemon configurations

 #systemctl daemon-reload

4) Restart docker service
  #systemctl restart docker
  
5) Verify docker proxy config
  #systemctl show --property=Environment docker    

6) Search docker images from docker registry 

#docker search nginx 

now you can see number of  nginx docker iamges from varies registry   

Thursday, July 13, 2017

Ansible installation yum based

Ansible:-

 Ansible is a push method config management tool, Relay on ssh protocol and Python is required on master and other nodes,support windows too through winRM module.

Installation :

1) ansible package is available in EPEL repository so EPEL is required.
2)yum -y install ansible
3)boto module installation for aws modules support
4)pip install boto ; pip upgrade boto

Verification:
#ansible --version

user creation and access path creation 

Ansible master node public key needs to copy all the nodes and ansible user sudo access must create.

master node :
 #useradd ansible;passwd ansible;su - ansible;ssh-keygen ;ssh-copy-id -i id_pub ansible@node1
   visudo ; ansible ALL=(ALL)  NOPASSWD
node1:
 #useradd ansible;passwd ansible;su - ansible

Tuesday, December 8, 2015

Docker installation and proxy settings from docker site (Cent OS)

I - Installation :-

1)Adding docker yum repository to your local machine.

#vi  /etc/yum.repos.d/docker.repo

[dockerrepo]
name=Docker Repository
baseurl=https://yum.dockerproject.org/repo/main/centos/7
enabled=1
gpgcheck=1
gpgkey=https://yum.dockerproject.org/gpg
#Proxy config -- optional
#proxy=http://192.168.1.1:80
#proxy_username=domainname\username
#proxy_password=password

2)Install docker throught yum

#yum install docker-engine

3)start & check status of docker service using systemctl

#systemctl start docker.service
#systemctl status  docker.service

II - Docker Proxy configuration for  docker image :- 

1)create a directory for docker service

#mkdir /etc/systemd/system/docker.service.d

2)Add proxy settings in config file

#vi /etc/systemd/system/docker.service.d/http-proxy.conf

[Service]
Environment="http_proxy=http://domainname\username:password@192.168.1.1:80"

3)Reload docker config and restart docker service

  # systemctl daemon-reload
  # systemctl show docker --property Environment
  # systemctl restart docker

4)Check docker service and pull ubuntu image

  #docker run hello-world
  #docker run -it ubuntu bash

5)check docker version
 
  #docker info

Monday, October 26, 2015

Raspberry PI static IP setup - Wireless wlan0


1)Edit network card and add ip / broadcast / gateway address

pi@raspberrypi ~ $ cat /etc/network/interfaces
auto lo
iface lo inet loopback

auto eth0
allow-hotplug eth0
iface eth0 inet manual

auto wlan0
allow-hotplug wlan0
iface wlan0 inet static
address 192.168.1.33
netmask 255.255.255.0
broadcast 192.168.1.255
gateway 192.168.1.254
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

auto wlan1
allow-hotplug wlan1
iface wlan1 inet manual
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

pi@raspberrypi ~ $

2) Add wifi router name & password

pi@raspberrypi ~ $ sudo cat  /etc/wpa_supplicant/wpa_supplicant.conf
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1

network={
        ssid="hubname"
        psk="password"
        key_mgmt=WPA-PSK
}
pi@raspberrypi ~ $

3)View your ip


pi@raspberrypi ~ $ ifconfig wlan0
wlan0     Link encap:Ethernet  HWaddr
          inet addr:192.168.1.33  Bcast:192.168.1.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:915 errors:0 dropped:148 overruns:0 frame:0
          TX packets:329 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:202526 (197.7 KiB)  TX bytes:49840 (48.6 KiB)

pi@raspberrypi ~ $

simple google search can fetch lots of results  but this post is for my reference :) ,Today My Raspberry PI2 DAY :)