आफ्नै धर्तीलाई सम्झंदा !!!
नयाँ भाग्य कोर्न
नयाँ मुलुकको लागी
जब घर देश बाट हिंड्छ
परिवारको भविष्यलाई
राम्रोसँग स्रिङ्गारेर
खुशि,र दुखको दोसाँझमा
अल्मलिंदै, रुमलिंदै
आफ्नो प्यारो गाउँ बेशि
पाईला पाईलाले पछि पार्दै
नयाँ सपना सम्झंदै
एउटा उदेष्यमा लम्किन्छ - परदेशी
परिवारमा बात कम
खबर कम भो परदेश बाट
न गफ छ, न भेट छ
सुन्य सुन्य छ
एकान्त छ,
उता,
आमा पिंढिमा बसेर
सोध्छिन रे !
छोरा कहिले आउँछ ?
छोरा दिन गन्दै,
महिना अनि बर्ष गन्दै
समयको वहावमा
यसरि चल्दै छ,
थाहा छैन जीवन
कहाँ पुग्दै छ,
शरीरको रुपरेखा बदलिंदै छ
कपाल फुलेर
कनिका छरे जस्तै भो
खै के को खोजीमा
केहि पाए जस्तो
केहि नपाए जस्तो
दोधारको जिन्दगी
सबै मिलेर नि
कतै केहि नमिले जस्तो
केहि छुटे जस्तो
सन्तोषको सास
फेर्न नसके जस्तो
न देश अट्यो न परिवार
यो मनमा सांच्न लाई
नयाँ मुलुक, नयाँ संसार,
नयाँ परिवार
अनि नयाँ परिवेश भो विदेश !!!
न देश भो
न भो परिवार यो मनमा साँच्न लाई
न त् देश न त् परिवार
सिक्का हावामा पल्टाएर
भाग्य बदल्न सकिने रहेनछ
बर्मा गए कर्म संगै
त्यसै भएको रहेनछ
सबैको भाग्य एउटै
हुँदो रहेनछ !!!
sikkaa paltaaer sahi halat chuttaaun sakinna
५/१८/२०२१
Vienna, VA
जिन्दगीको समयले घडी घुमाको छ
सुन्दर कुरा ओईलाएर चाउरिएको छ
समयलाई कसैले रोक्न सक्दैन
एक दिन भुईंमा झरी यहिं मिल्नु छ
जिन्दगीको समय त् आँफै चलेको छ
सुन्दर कुरा ओइलाएर आँफै झरेको छ
रितै हैछ संसारको आउने जाने यहाँ
केहि दिई केहि लिई जानु परेको छ !!!
समयसँगै हरेक सुन्दर चीज ओइलाउँदै जान्छन्, सुकेर खङ्ग्रङ्ग पर्छन् । तर हरेक चीज सुक्दैनन्, केही केही सधैं हरियै रहन्छन्- ‘एभरग्रीन’ ।
‘अ क्लकवर्क अरेन्ज’ यस्तै एभरग्रीन सिनेमा हो ।
Thursday, June 3, 2021
manako kuro
के मिल्छ ?
के मिल्छ ?
काम बाटै काम मिल्छ
काम बाटै दाम मिल्छ
दाम बाटै माम मिल्छ
माम बाटै सान मिल्छ
सान बाटै मान मिल्छ
मान बाटै नाम मिल्छ
नाम बाटै दाम मिल्छ
दाम बाटै दाम मिल्छ
दाम बाटै काम मिल्छ
काम बाटै काम मिल्छ
काम बाटै नाम मिल्छ !!!
Wednesday, June 2, 2021
Day10 - Terraform - terraform function, integration with kubernetes
------------------------
Class note:-
Today's topic
1. Intergrate terraform with kubernetes
2. How to use terraform functions
1. Start your minikube for kubernetes
> minukube start
google: terraform functions
built-in function from terrraform.io
numeric, string, encoding, filesystem, date and time, hash and more finctions are available.
terraform provides live console
> terrafrom console
gives you terraform console where you can write terraform function
> max(5, 10, 20)
> element(["a","b","c"])
> lookup ({a="ay", b="bee"}, "a", "what?")
lookup function
> mkdir wp/function; cd wp/function
e
variable "region" {
default = "ap-south-1"
}
# store ami-names based on region, since same ami can't be used on different region
variable "ami" {
type = map # map is a dictionary
default = {
"us-east-1" = "ami-1234" # if you from us east 0 use one
"us-webt-1" = "ami-234"
"ap-south-1" = "ami-345"
}
}
# print some output
# print ami based on the region
output "01" {
value = lookup(var.ami, var.region, "ami-456"
}
> tf apply
look at the output
01 ->
whats the use case?
you can use on ec2
google for - terraform ec2 resource
Code becomes more dynamic
resource "aws_instance" "web" {
ami = lookup (var.ami, var.region, "ami-456" )
instance_type = "t3.micro"
tags = {
Name = "HelloWorld"
}
}
output "01" {
value = lookup(var.ami, var.region, "ami-456"
}
> tf init
Kubernetes
----------
- a platform that manages containers
docker -> containers -> app
Images -> Containers
containers are known as POD in k8s.
> minikube start
> kubectl get pods
google:
terrafrom -> registry -> provider -> kubernetes -> documentation -> authentication
- example usage
read the doc
> mkdir kube; cd kube
> notepad k.tf
provider "kubernetes" {
config_path = "~/.kube/confg" # contains key, login info
config_context = "my-context"
}
> kc get pods
to create instance, you have to create namespace on google, same way, k8s also same thing
look for context info when you start minikube
> notepad k.tf
provider "kubernetes" {
config_path = "~/.kube/confg"
config_context = "my-context"
config_context = "minikube"
}
> tf init
> tf apply # nothing to apply at this time
look for example how to launch pod
kubernetes providers
- go to resources section
https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/resources/pod
resource "kubernetes_pod" "test" {
metadata {
name = "my-kube"
}
spec {
container {
image = "nginx:1.7.9"
name = "example"
env {
name = "environment"
value = "test"
}
port {
container_port = 8080
}
liveness_probe {
http_get {
path = "/nginx_status"
port = 80
http_header {
name = "X-Custom-Header"
value = "Awesome"
}
}
initial_delay_seconds = 3
period_seconds = 3
}
}
dns_config {
nameservers = ["1.1.1.1", "8.8.8.8", "9.9.9.9"]
searches = ["example.com"]
option {
name = "ndots"
value = 1
}
option {
name = "use-vc"
}
}
dns_policy = "None"
}
}
modify
> tf apply
> kc get pod
> kc describe <pod>
> tf destroy
launch deployment
go to deployment -> set replication
https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/resources/deployment
This is how we can work with kubernetes
How loop works with Terraform (TF)
AWS - Security group ->
EC2 -> add security group/firewall
firewall comes from outside, checked the traffic and checks with the rule (in bound traffic)
port 80/tcp if rule is there, it will allow, if not, it will deny
> mkdir sg; cd sg
> notepad sg.tf
terraform security group
look for resource: aws_security_group
provider "aws" {
region = "ap-south-1"
profile = "default"
}
#variable "sgports" {
# type = list
# default = [80,81,8080,8081]
#}
resource "aws_securit_group" "allow_tls" {
name ="mysg"
ingress {
from_port = 80
to_port = 80
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"] # allow traffic (port 80) from all over
}
}
# you will need VPC
# tf init
# it will create security group
# tf apply
===========================
using for loop
provider "aws" {
region = "ap-south-1"
profile = "default"
}
variable "sgports" {
type = list
default = [80,81,8080,8081]
}
resource "aws_securit_group" "allow_tls" {
name ="mysg"
dynamic "ingress" {
for_each = var.sgports
content {
from_port = ingress.value
to_port = ingress.value
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"] #
}
}
}
> tf apply
Tuesday, June 1, 2021
Reading.bz2 zip file
How to read bz2 zip file
# bzcat yourfile.log.bz2 | grep -i <string> | more
# bzcat /var/log/messages.2021.02.20.bz2
# bzgrep Archive $(hostname -s)-audit.log.2021.05.2*.bz2
# bxgrep -c fuser myhost-audit.log.2021.05.2*.bz2
# bzip2 -d myhost-audit.log.2021.05.2*.bz2
To uncompress
# bunzip2 myhost-audit.log.2021.05.2*.bz2
$ (hostname -s)-secure.20210520.bz2 | grep -E "Starting session.*file_upload" | cut -d' ' -f2 | sort | uniq -c
Terraform - Day 9
Terraform - class notes
$ cat providers.tf
$ cat variables.tf
variable 'x' {
default = "t2.micro"
type = string
}
output "01" {
value = var.x
}
> tf apply -var-'x-t2.medium"
$ cat aws-main.tf
resource "aws_instance" "web" {
ami = "ami-012...."
instance_type = var.x
}
$ cat variables.tf
# variable 'x' {
# default = "t2.micro"
# type = string
# }
variable 'x' {}
output "01" {
value = var.x
}
> tf apply -var="x=t2.medium"
in this case, either you pass the value or it will prompt
don't change the code, pass the variable.
or you can create a config with key/value pair.
name must the same, fix file.
> notepad terraform.tfvars
#x="value"
x="t2.micro"
here, you can come and change
we change the value of x.
> tf apply
if you don't define, it will prompt but we defined, it will not prompt but will grab from config file.
> notepad terraform.tfvars
#x="value"
x="t2.large"
> tf apply -var="x=t2.micro"
Lets go to variable file
$ cat variables.tf
# variable 'x' {
# default = "t2.micro"
# type = string
# }
variable 'x' {}
variable "y" {
type=boot
}
output "01" {
value = var.y
}
commentout the content on aws_main.tf file.
> tf apply
ask you for true or false
boolean is good if you create condition
if you want to do something check the condition, if condition is true, do this if not do the else part.
turnety operator way ,,
condition - question mark? - value1: value2
if condition comes true, display value1 else display value2
Note: true and false should be on lower case
output "01" {
value = var.y ? "Sam" : "Ram"
}
if true it will return Sam else Ram.
> cd google
provider "aws" {
region = "ap-south-1"
profile = "default"
}
provider "google" {
project = "myproj"
region = "asia-south1"
}
$ modify variable file
> tc apply
> tf plan
webapp -> Testing (QA Team) -> Prod
$ cat aws_main.tf
resource "aws_instance" "web" {
ami = "ami-01..."
instance_type = var.x
count = 5
}
cat variables.tf
append
variable "lstest" {
type = bool
}
change the value of 5
$ cat aws_main.tf
resource "aws_instance" "web" {
ami = "ami-01..."
instance_type = var.x
# count = 5
count = var.lstest ? 0 : 1 # if this is true, 0 , count 0 , this instance will not run
}
gcp_main.tf
resource "google_compute_instance" os1" {
name = "os1"
machine_type = var.mtype
zone = "asia-south-c"
count = var.istest ? 1 : 0
boot_disk {
initialize_params {
image = "debian-cloud/debian-g"
}
}
> tf apply -var="lstest=true"
ca variables.tf
append
variable "lstest" {
type = bool
}
variable "azaws" {
default = [ "ap-south-1a", "ap-south-1b", "ap-south-1c" ]
type = list
}
#output "0s2" {
# value = var.azaws
$ cat aws_main.tf
resource "aws_instance" "web" {
ami = "ami-01..."
instance_type = var.x
availability_zone = var.azaws[1]
count = 1
}
> tf apply
map data type
[ 'a', 'b', 'c' ]
system gives the index
you may want to do your own value
say a is id
variable "azaws" {
default = [ "ap-south-1a", "ap-south-1b", "ap-south-1c" ]
type = list
}
variable "types" {
type = map
default = { # maps in curly braces
us-est-1 = "t2.nano",
ap-south-1 = "t2.micro",
us-west-1 = "t2.medium"
}
}
# output "os3" {
# value = var.types
# value = var.types["ap-south-1"]
# }
> tf apply
when your signature becomes autograph you are something ...
Terraform - Modules
Terraform - 6-02-2021
class notes
Topic - Terraform Module
- Make complex idea into simpler one...
Plan:- When you want to create infrascture (cloud), create manually, or writing code (with terraform)
create module, organize your code
we try to create same infracture at Dev/test/prod env. with same app.
test -> verify -> deploy
main code variables
- mail.tf
- var.tf -> this is where we mostly make changes.
create one centralize folder and dump all your planing, code everything..
parameterize ...
$ cd /workspace; mkdir modules; cd modules; mkdir ec2; cd ec2
everything you need for ec2, define here.
$ vi main.tf
google:
teffarorm.io -> registry -> proivideers -> aws -> documents -> search for aws_instance -> aws inrtance
and copy the section resource part
provider "aws" {
region = "ap-south-1"
profile = "default"
resource "aws_instance" "web" {
ami = "ami-ssss"
instance_type = var.mytype
tags = {
Name = "Hello World !!"
}
}
get the id info for ami-id
$ vi var.tf
variable "mytype" {} # define nothing - no value is defined
> terraform init
you can put this folder on gitlab, hub or locally, nfs and make a use of it.
import the module
$ vi dev.tf
module {
# source = "github://user@passwd ...
source = "../modules/ec2"
}
> terrafrom apply
vi dev.tf
module "mydevm" {
source
}
> tf apply
> cd ../prod
> vi prod.tf
module " mydevm" {
source = "../modules/ec2"
.....
}
> terraform init
> tf apply
mkdir ../myvpc
cd ../myvpc
check terrafrom web site for vpc
there are lots of variable names such as cidr, create route .. created
you can use it..
go to section vpc module ..
$ cat main.tf
provider "aws" {
region = "ap-south-1"
profile = "default"
}
module "vpc" {
source = "terraform-aws-modules/vpc/aws"
cidr = "10.10.1.0/16"
}
}
> tf apply
practice: look for all the modules at the registry. if may not find the module you are looking for.
- Find the module you want to work on.
- Read the module documents
- you can createyour module or add content on existing modules with more features...
- create and share in public.
- recognization ...
publish on registry or github
write your plan, find the module to work on and add feature
google for
"terraform modules source "
you see the sources
- path - local ,github, ssh ...
git::username@domain.com:storage.git"
-----------------review
module "mydevm" {
source = "../modules/ec2"
mytype = ${"module.myvpc.cidr}" # verify, this is just an example..
}
you can use output function to see the default value or look gotoutput function.
RHEL7 - How to expire and Lock linux account
Lock and expire linux account
# chage -l jack
# chage -E 2021-06-01 jack
# usermod -L jack
Git branch show detached HEAD
Git branch show detached HEAD 1. List your branch $ git branch * (HEAD detached at f219e03) 00 2. Run re-set hard $ git reset --hard 3. ...
-
Creating VPN tunnel using sshutle with the help of ssh 1. Install shuttle $ sudo apt-get install sshuttle -y $ sudo yum install sshuttle $...
-
snmpconfig command allow you to managge snmpv1/v3 agent configuration on SAN switch. Event trap level is mapped with event severity level....
-
Ansible day3 - class notes 2/15/2022 Recap from Ansible - agentless - ssh - python - ansible - yaml - playbook -> task/handlers/v...