Skip to main content

Posts

Showing posts from July, 2021

Install AWS CLI on Ubuntu localhost using Ansible Playbook

Install AWS CLI on Ubuntu localhost using Ansible Playbook --- - hosts: localhost tasks: - name: Installing Unzip package package: name: unzip state: present when: ansible_facts['os_family'] == "Debian" become: true - name: Create awscli directory in home directory file: path: ~/awscli state: directory mode: '0755' - name: Download bundled installer zip file get_url: url: https://s3.amazonaws.com/aws-cli/awscli-bundle.zip dest: ~/awscli/awscli-bundle.zip - name: Extract zip file unarchive: src: ~/awscli/awscli-bundle.zip dest: ~/awscli - name: Run install command shell: /home/ubuntu/awscli/awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws become: true Same script is also avail...

EFS Provisioning using TF

Full script is available at https://github.com/JaydeepUniverse/terraform/tree/master/aws/efs Prerequisites - Along with EFS creation we'd need to mount on subnet as well where we would going to use it, hence To get existing subnet details follow below steps Import existing subnet details by adding below code to main.tf and resource "aws_subnet" "subnet-aaa" { } resource "aws_subnet" "subnet-aaa" { } Run terraform import command - terraform import aws_subnet.subnet-aaa subnet-aaa terraform import aws_subnet.subnet-aaa subnet-aaa Then add subnet values from terraform.tfstateto main.tf else terraform will add/remove parameters accordingly for the same subnet ex. ...

How to skip resources, compiler, surfire, install plugin in maven's default build process

When we want to use maven command line to upload zip type artifact to artifact repository then we don't want resources, compiler, surefire, install phases in maven process, only assembly would be enough. To skip particular phases go to each plugin's original website phase according to latest running plugin version download the same to our own project refer the skip phase configuration of particular phase, either it can be done command line or as part of the build-plugin-configuration. Example using POM.xml file <project> [...] <build> <plugins> <plugin> <groupId...

How to give permission to particular user to particular dir. or file in Linux

Permission error: ubuntu@ip-192-168-62-113:~/bbb/testing$ ls -ltrh total 4.0K -rwx------ 1 ubuntu ubuntu 70 Mar 18 09:43 test.sh ubuntu@ip-192-168-62-113:~/bbb/testing$ sudo su - abc abc@ip-192-168-62-113:~$ cat /home/ubuntu/jaydeep/testing/test.sh cat: /home/ubuntu/bbb/testing/test.sh: Permission denied Command - how to give permission to particular user to particular dir. or file ubuntu@ip-192-168-62-113:~/bbb/testing$ sudo setfacl -m u:abc:r test.sh ubuntu@ip-192-168-62-113:~/bbb/testing$ sudo su - abc abc@ip-192-168-62-113:~$ cat /home/ubuntu/bbb/testing/test.sh #!/bin/bash read -p "What is your name? " name echo "Welcome $name!" For the Directory setfacl -m u:userID:rwx /dir/subdir/ setfacl -m u:userID:rwx /d...

How to break lines in HTML

<br> tag helps to break the line in paragraph or any other tag. <html> <body> <p> Line 1 <br> Line 2 <br> Line 3 <br> Line 4 <p> <body> <html> Output of this code would be as below Line 1 Line 2 Line 3 Line 4

How to clone Github repository using SSH

Run ssh-keygen Upload ssh public key to github account curl -u "gitUsername:password" --data '{"title":"keyName","key":"'"$(cat ~/.ssh/id_rsa.pub)"'"}' https://api.github.com/user/keys Sample output of ssh public key upload command { "id": 1234567890, "key": "ssh-rsa aaaaaaaaaaaaaaaaaaaa/dddd/+aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "url": "https://api.github.com/user/keys/123456...

Add coding block in HTML using Code Tag

<html> <style> pre code { background-color: #eee; border: 1px solid #999; display: block; padding: 20px; color: black; } code{ color: blue; } <style> <body> <code> #!/bin/bash read -p "What is your name ?" name echo "Welcome $name!" <code> <body> <html> Output of this code would be as below #!/bin/bash read -p "What is your name ?" name echo "Welco...

How to read user's input in Bash Script

Create shell script file as below: #!/bin/bash echo "Enter your name!" read name echo "Welcome to Mars $name" Make script file executable chmod u+x test.sh Run script sh test.sh Output of the script: Enter your name! Rectangle Welcome to Mars Rectangle

Python Formatter: Not enough arguments for format string

Example code: formatter = "%r %r %r %r" print formatter % (1, 2, 3, 4) print formatter % ("one", "two", "three", "four") print formatter % (True, False, True, False) print formatter % (formatter, formatter, formatter, formatter) print formatter % ( "I am typing without single quote in it." "Now I'm using single qoute." ) Error output: Traceback (most recent call last): File "8-more_printing.py", line 8, in <module> "I am typing without single quote in it." TypeError: not enough arguments for format string In above example in last line, there are only 2 values given whereas for "formatter" variable there are 4 values must be define. Hence, if we run above pr...

Install Jenkins on AWS EKS using Helm

Prerequisites Create namespace for jenkins kubectl create ns jenkins We'll store jenkins data on AWS EBS as persistent storage hence for that Create storage class apiVersion: storage.k8s.io/v1 kind: StorageClass metadata: name: jenkins-sc provisioner: kubernetes.io/aws-ebs parameters: type: gp2 fsType: ext4 Create persistent volume claim apiVersion: v1 kind: PersistentVolumeClaim metadata: name: jenkins-pvc namespace: devops-tools spec: storageClassName: jenkins-sc resources: requests: storage: 50Gi accessModes: - ReadWriteOnce ...

EKS Provisioning Using TF

Full script is available at https://github.com/JaydeepUniverse/terraform/tree/master/aws/eks Prerequisites Install kubectl Install AWS CLI Install AWS IAM Authenticator Update kubeconfig file if needed aws eks update-kubeconfig --name eksClusterName Please keep in mind about below commented notes while changing names of name,cluster,environment else EKS,ASG,VPC all resources will be created but while running kubectl get nodes command it won't show any worker nodes provider "aws" { region = "us-east-2" # region } module "vpc" { source = "../../modules/vpc" vpc-location = "Ohio" # location name as per region namespace = "nextgen-c...

Public domain connectivity issue due to DNS

Problem It may possible that sometimes if DNS is not properly configured or not able to resolve public domains. Solution To resolve this add nameserver 8.8.8.8 in /etc/resolve.conf and then try to nslookup the website again.

Install AWS CLI on Ubuntu localhost using Ansible Playbook

Install AWS CLI on Ubuntu localhost using Ansible Playbook --- - hosts: localhost tasks: - name: Installing Unzip package package: name: unzip state: present when: ansible_facts['os_family'] == "Debian" become: true - name: Create awscli directory in home directory file: path: ~/awscli state: directory mode: '0755' - name: Download bundled installer zip file get_url: url: https://s3.amazonaws.com/aws-cli/awscli-bundle.zip dest: ~/awscli/awscli-bundle.zip - name: Extract zip file unarchive: src: ~/awscli/awscli-bundle.zip dest: ~/awscli - name: Run install command shell: /home/ubuntu/awscli/awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws become: true Same script is also avail...

Install Ansible on Ubuntu using Shell Script

Shell Script to Install Ansible in Ubuntu #!/bin/bash echo "UPDATING ALL PACKAGES" sudo apt update -y for i in 1 2 3 4 5 do echo " " done echo "INSTALLING software-properties-common" sudo apt install software-properties-common -y for i in 1 2 3 4 5 do echo " " done echo "INSTALLING ppa:ansible/ansible REPOSITORY" sudo apt-add-repository --yes --update ppa:ansible/ansible -y for i in 1 2 3 4 5 do echo " " done echo "INSTALLING ANSIBLE" sudo apt install ansible -y Same script is also available at https://github.com/JaydeepUniverse/automation/blob/master/ansible.sh

Nexus installation on EKS

Create nexus namespace apiVersion: v1 kind: Namespace metadata: name: nexus Create storage class for nexus to store data on AWS EBS apiVersion: storage.k8s.io/v1 kind: StorageClass metadata: name: nexus provisioner: kubernetes.io/aws-ebs parameters: type: gp2 fsType: ext4 allowVolumeExpansion: true Create persistent volume claim apiVersion: v1 kind: PersistentVolumeClaim metadata: name: nexus namespace: nexus labels: app: nexus spec: storageClassName: nexus resources: requests: storage: 50Gi accessModes: - ReadWriteOnce Create deployment for p...

Install kubectl on Ubuntu localhost using Ansible Playbook

Install kubectl on Ubuntu localhost using Ansible Playbook --- - hosts: localhost tasks: - name: Installing Kubectl step-1 package: name: apt-transport-https state: present when: ansible_facts['os_family'] == "Debian" - name: Installing Kubectl step-2 shell: sudo curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add - when: ansible_facts['os_family'] == "Debian" - name: Installing Kubectl step-3 command: sudo echo "deb https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee -a /etc/apt/sources.list.d/kubernetes.list when: ansible_facts['os_family'] == "Debian" - name: Installing Kubectl step-4 snap: name: kubectl classic: yes when: ansible_facts['os_family'] == "Debian" - name: Ins...

Install Helm on Ubuntu localhost using Ansible Playbook

Install Helm on Ubuntu localhost using Ansible Playbook --- - hosts: localhost tasks: - name: Check for latest version pause: prompt: "check latest versions to download from url https://github.com/helm/helm/releases before proceeding" - name: Installing Unzip package package: name: unzip state: present when: ansible_facts['os_family'] == "Debian" become: true - name: Create helm-install directory in home directory file: path: ~/helm-install state: directory mode: '0755' - name: Download zip file get_url: url: https://get.helm.sh/helm-v3.0.2-linux-amd64.tar.gz dest: ~/helm-install/helm-v3.0.2-linux-amd64.tar.gz - name: Extract zip file unarchive: src: ~/helm-install/helm-v3.0.2-linux-amd64.tar.gz dest: ~/helm-install ...

Install Docker on Ubuntu localhost using Ansible Playbook

Install Docker on Ubuntu localhost using Ansible Playbook --- - hosts: localhost tasks: - name: Update all packages to the latest version apt: name: "*" state: latest when: ansible_facts['os_family'] == "Debian" become: true - name: Upgrade all packages to the latest version apt: upgrade: dist when: ansible_facts['os_family'] == "Debian" become: true - name: Install apt-transport-https package: name: apt-transport-https state: present when: ansible_facts['os_family'] == "Debian" become: true - name: Install ca-certificates package: name: ca-certificates state: present when: ansible_facts['os_family'] == "Debian" become: true - name: Install curl package: ...

Docker in Brief

Docker Hub Registry Docker is a platform for developers and sysadmins to build, run, and share applications with containers. The use of containers to deploy applications is called containerization. Containerization is increasingly popular because containers are: Flexible: Even the most complex applications can be containerized. Lightweight: Containers leverage and share the host kernel, making them much more efficient in terms of system resources than virtual machines. Portable: You can build locally, deploy to the cloud, and run anywhere. Loosely coupled: Containers are highly self sufficient and encapsulated, allowing you to replace or upgrade one without disrupting others. Scalable: You can increase and automatically distribute container replicas across a datacenter. Secure: Container...

Maven in Brief

What is Maven Apache Maven is a software project management and comprehension tool. Based on the concept of a project object model (POM), Maven can manage a project's build, reporting and documentation from a central piece of information. Below are features provided by maven: Build Automation Tool Dependency Management Tool Project Management Tool Standard approach to building software Command line tool IDE Integration Managed by Apache Software Foundation Terminologies POM(Project Object Model) POM is an XML file, and this file really describes the configuration and the customization for our project. So it's going to spell out the different plugins, different dependencies and different profiles ...

Install Spinnaker as a Docker Container on Ubuntu using Ansible Playbook

Install Spinnaker as a Docker Container on Ubuntu using Ansible Playbook --- - hosts: localhost vars: environment: PYTHONPATH: "{{ lookup('env','PYTHONPATH') }}:/usr/local/lib/python2.7/dist-packages:/usr/local/lib/python2.7/site-packages" tasks: - name: Update all packages to the latest version apt: name: "*" state: latest when: ansible_facts['os_family'] == "Debian" become: true - name: Upgrade all packages to the latest version apt: upgrade: dist when: ansible_facts['os_family'] == "Debian" become: true - name: Install python2 pip package: name: python-pip when: ansible_facts['os_family'] == "Debian" become: true - name: Install python-requests module apt: name: python-requests...

Install Python3.7 on Ubuntu localhost using Ansible Playbook

Install Python3.7 on Ubuntu localhost using Ansible Playbook --- - hosts: localhost tasks: - name: Upgrade all packages to the latest version apt: name: "*" state: latest when: ansible_facts['os_family'] == "Debian" - name: Install software-properties-common package: name: software-properties-common state: present when: ansible_facts['os_family'] == "Debian" - name: Add repository apt_repository: repo: ppa:deadsnakes/ppa state: present when: ansible_facts['os_family'] == "Debian" - name: Again Upgrade all packages to the latest version apt: name: "*" state: latest when: ansible_facts['os_family'] == "Debian" - name: Install python3.7 package: name: python3.7...

Docker Commands

Docker Hub Registry sudo docker login - To login into default docker registry https://hub.docker.com/ sudo docker login registryURL - To login into private registry sudo docker push repoName/imageName:tag - Push image to registry in given repoName=respository name, as imageName with tag=ex. 1.0.0 sudo docker pull repoName/imageName:tag - Pulgl docker image sudo docker tag existingRepoName/imageName:tag newRepoName/imageName:tag - Create new tagged image Interacting with Container sudo docker run -it imageName – -i means interactive, -t means provide terminal sudo docker run -d imageName - -d means run in background mode sudo docker cp [OPTIONS] CONTAINER:SRC_PATH DEST_PATH|- sudo docker cp [OPTIO...

Docker Networks

Docker Networks One of the reasons Docker containers and services are so powerful is that you can connect them together, or connect them to non-Docker workloads. Docker’s networking subsystem is pluggable, using drivers. Several drivers exist by default, and provide core networking functionality: Bridge: The default network driver. If you don’t specify a driver, this is the type of network you are creating. Bridge networks are usually used when your applications run in standalone containers that need to communicate. Host: For standalone containers, remove network isolation between the container and the Docker host, and use the host’s networking directly. host is only available for swarm services on Docker 17.06 and higher. See use the host network. Overlay: Overlay networks connect multiple Docker...