Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Devops Interview Questions With Answers 1

Download as pdf or txt
Download as pdf or txt
You are on page 1of 12

DevOps Interview Hack

DevOps Interview Questions & Answer.

Here is DevOps Intw questions, Which helps you on your upcoming Intw.
Please put comments in comment section, If you feel any missing topic, I will update this
post accordingly.

Topics

• Linux
• AWS
• Ansible
• Jenkins
• Git
Please write in comments if you feel any topics should be here. I will update this post
accordingly.

##### Topic 1. Ansible #####

Que. What is ansible and why we should use ansible ?


Ans: Ansible is an configuration management tool, It works over 22 port for communication
between master and client.
This is very easy to use and we can mange our infrastructure by using it. We dont need
any extra authentication or root access to use ansible.

Que. How to install and configure Ansible in any machine?


Ans: To installing Ansible in any machine we need python > 2.4 or upper version. We can
install Ansible by git installation, PIP or yum installation.
to manage aws infrastructure by ansible we should have boto 3 on our base machine.

Que. What is Role in Ansible?


Ans: Role is set of tasks in ansible.

Que. What is Task, Inventory, template in Ansible?


Ans: Group of play is call task in ansible, Inventory where you can store your hosts details,
template more like to put the template files which is used
in different hosts. [Jinja template]

Que: How to check ansible playbook syntax?


Ans: ansible-playbook naem_of_the_playbook.yml --syntax-check

Que: How to create ansible role?


Ans: To creating ansible role command is "ansible-galaxy init name_of_role"

Que. What is mean by register, notify and wait_for in ansible playbook?


Ans: register is simply store the out-put of any task as variable for others,
Que. How to print output of any command in ansible?
Ans: By using "debug" we can see the command out-put

Que. What is fact and set_fact in ansible?


Ans: This module allows setting new variables. Variables are set on a host-by-host basis
just like facts discovered by the setup module.

Que. What is type of template ansible support?


Ans: Ansible support jinja_template

11. What is "tag" in Ansible?


Ans: If you have a large playbook it may become useful to be able to run a specific part of
the configuration without running the whole playbook.
For this we are using "tag" module.

12. What is "assemble" in ansible?


Ans: Assembles a configuration file from fragments.
Often a particular program will take a single configuration file and does not support a
conf.d style structure
where it is easy to build up the configuration from multiple sources.
assemble will take a directory of files that can be local or have already been transferred to
the system, and concatenate them together to produce a destination file. F

Files are assembled in string sorting order.

# Example from Ansible Playbooks


- assemble: src=/etc/someapp/fragments dest=/etc/someapp/someapp.conf

# When a delimiter is specified, it will be inserted in between each fragment


- assemble: src=/etc/someapp/fragments dest=/etc/someapp/someapp.conf
delimiter='### START FRAGMENT ###'

13. How pause module work in ansible playbook?


Ans: Pauses playbook execution for a set amount of time, or until a prompt is
acknowledged. All parameters are optional. The default behavior is to pause with a prompt.
You can use ctrl+c if you wish to advance a pause earlier than it is set to expire or if you
need to abort a playbook run entirely. To continue early: press ctrl+c and then c. To abort a
playbook: press ctrl+c and then a.

14. What is the default configuration file location of ansible?


Ans: /etc/ansible

15. What is item and with_item in ansible?


Ans: Basica1ly "item" is use to define the variable and "with_item" is used to use that
variable inside the playbook.
16. How to run adhoc commands in ansible
Ans: An ad-hoc command is something that you might type in to do something really quick,
but don’t want to save for later.

Exam. $ ansible atlanta -a "/usr/bin/foo" -u username

18. How to run an ansible playbook if my host file is in /tmp location?


Ans: $ ansible atlanta -i /tmp/hosts -a "/usr/bin/foo" -u username

19. I am running ansible playbook? How I can run it with debug mode?
Ans: By using "debug" module inside that playbook.

20. Can you please differentiate ansible with other configuration management tool like chef
or puppet?
Ans: Ansible is not depend on any client, So we can say it’s not an server/client
architecture.

############## Topic 2 Jenkins ######

1. What do you mean by CI/CD?


Ans: CI/CD is Continuous integration and Continuous Deployment. This support Agile
method.

2. How to install Jenkins on any machine?


Ans: We can Install Jenkins by repository installation or We can use source code installation
by using tar ball or zip file.

3. What are the Plugins you have used in Jenkins mostly and why? Named five at least.
Ans: git plugins, maven plugin, Build Pipeline Plugin, Copy Artifact Plugin, JIRA Plugin for
Jenkins, Mask Passwords Plugin.

4. How to notify team after completion of job in Jenkins?


Ans: By sending mail notification.

5. What is Pipeline in Jenkins?


Ans: Jenkins have the Build Pipeline Plugin, which is used to create build, deployment jobs
interconnected. So that after build
It will automatically trigger deployment jobs after completion of build job.

6. Which version of Jenkins you are using now?


Ans: I am using the current version of Jenkins which is 2.25. This is also printed on bottom
right of Jenkins.

7. How to configure master and slave in Jenkins?


Ans: Jenkins supports master and slave configuration. Mostly we are configure only build
jobs in master and for compiling all the build and deployment
jobs in slave server.
To configure slave we are installing the slave.jar file on slave machine.

8. How to take daily backup of jobs in Jenkins?


Ans: Jenkins has a backup plugin which can used to backup critical configuration settings
related to Jenkins.

9. How to run more than one ant version or java version in Jenkins?
Ans: By using "configure system" we can create more than one jdk.

10. How to create an scm pool job in Jenkins?


Ans: Go to configure page of a project.
Go to “Build Triggers” section. Check “Poll SCM”
Enter the schedule that you want in cron-style.
save.

11. How to install any plugins in Jenkins?


Ans:
Download the plugin
Inside Jenkins: Manage Jenkins > Manage Plugins > There is a tab called 'Advance
configuration' and in that page there is an option to upload a plugin (the extension of the
file must be hpi)

13. How to recover Jenkins admin password


Ans:

You can try to re-set your Jenkins security:

Stop the Jenkins service


Open the config.xml with a text editor (notepad++), maybe be in C:\jenkins\config.xml
Find this <useSecurity>true</useSecurity> and change it to
<useSecurity>false</useSecurity>
Start Jenkins service
You might create a admin user and enable security again

15. What are the basic permissions set of any user's in jenkins
Ans: For any user by default permission is read-only

16. What is DSL [Seed Jobs] in jenkins


Ans: The Jenkins "Job DSL / Plugin" is made up of two parts: The Domain Specific Language
(DSL) itself that allows users to describe jobs using a Groovy-based language, and a Jenkins
plugin which manages the scripts and the updating of the Jenkins jobs which are created
and maintained as a result.

17. What is default database jenkins use?


Ans: Hudson/Jenkins doesn't quite work that way. It stores configurations and job
information in /var/lib/jenkins by default (if you're using the .deb package). If you want to
setup persistence for a specific application, that's something you'll want to handle yourself -
Hudson is a continuous integration server, not a test framework.

18. What is default path of jenkins configuration file.


Ans:
Jenkins needs some disk space to perform builds and keep archives. You can check this
location from the configuration screen of Jenkins.
By default, this is set to ~/.jenkins, but you can change this in one of the following ways:
Set "JENKINS_HOME" environment variable to the new home directory before launching the
servlet container.
Set "JENKINS_HOME" system property to the servlet container.
Set JNDI environment entry "JENKINS_HOME" to the new directory.
########## Topic - 3 AWS ############
1. What is region and Aviability zone in aws.
Ans: Amazon EC2 is hosted in multiple locations world-wide. These locations are composed
of regions and Availability Zones.
Each region is a separate geographic area. Each region has multiple, isolated locations
known as Availability Zones.

2. What is EC2?
Ans:
Amazon Elastic Compute Cloud (Amazon EC2) is a web service that provides resizable
compute capacity in the cloud. It is designed to make web-scale cloud computing easier for
developers.
Amazon EC2's simple web service interface allows you to obtain and configure capacity with
minimal friction.

3. How to launch EC2 machine please share the steps.


Ans: There is following steps to launch EC2 machine.

A. Select AMI
B. Select machine type.
C. Select the network option
D. Add Volume
E. Add Security Group
F. Tag instance
G. Preview the configuration
H. Launch

4. What is the Difference between Key pair and Security group?


Ans: Key pair is the key by which we can login to the ec2 machine and Security group is
virtual firewall.

5. How to allow any port in Security group?


Ans: By editing the Inbound rule we can allow any port in SG.

6. How to access EC2 machine after launch?


Ans: By downloading the key pair and save it on your local machine. If you are login with
windows machine convert the key pair from .pem to .ppk file.
7. May I update the security group after launching the EC2 instance?
Ans: Yes

8. What is EBS?
Ans: EBS is the plug-in play device for EC2 machine.

9. How to increase the size of any EBS volume?


Ans: There is two methods to increase the size of EBS volume.

A. By snapshot and launching the new EBS and attach it to running EC2 machine.
B. By editing the EBS volume

10. What is snapshot and AMI?


Ans: A snapshot is of an EBS volume where you are able to save state and reboot with the
same data at a certain point in time. An AMI is similar, but it’s for the EC2 instances
themselves. You cannot take a snapshot of a non ebs backed instance, but you can create a
AMI (system image) of

11. What are the difference between Spot, Reserved and On-Demand Instance.?
Ans:
Spot instances enable you to bid on unused EC2 instances, which can lower your Amazon
EC2 costs significantly.
Reserved Instances provide you with a significant discount compared to OnDemand
Instance pricing. Reserved Instances are not physical instances, but rather a billing discount
applied to the use of On-Demand Instances in your account. These On-Demand Instances
must match certain attributes in order to benefit from the billing discount.

12. What is S3, why it called Object Storage?


Ans: Since S3 does not follow any file structure and Its store everything as an objects so it
is called Object Storage.

14. What is Glacier?


Ans: It’s an archival storage.

15. What are the different class of S3 storage?


Ans: S3 basically have three different class of file storage.

A. Standard class
B. Statndard_infrequent
C. REDUCED_REDUNDANCY

16. What is the Versioning in S3 and why we should use it?


Ans: Versioning automatically keeps up with different versions of the same object.

17. What is Cloud-Watch, what are the difference between Advance and basic monitoring of
Cloud watch ?
Ans: Cloud-Watch is monitoring tool of aws. Free - tier support basic monitoring with 5 min
duration and Advance monitoring support every minutes monitoring of AWS resources.

19. What is mean by VPC?


Ans: VPC is Virtual Private Cloud.

Que. What is EIP, Is it chargeable or free?


Ans: EIP is free but it will be chargeable if it attached with any stop instance.

########## Source Code Management ###########

1. What is source code management?


Ans: Source code management is basically the process to manage the codes in any
repository.
Exmp. GIT, Bit Bucket, SVN.

2. What is the commands to clone repository in GIT.

Ans: git clone https://giturl.com/branch_name

3. What is the command to check current branch?


Ans: git branch

o/p: develope or master

4. What is default branches in GIT?


Ans: There is two default GIT branch

A. master B. develop

5. What are the steps to commit any file in GIT?


Ans:

git add file_name


git push file_name
git commit -m "This is new file" file_name

6. What is webhook in GIT?


Ans: Webhook is used to enable auto build, with jenkins or any other CI/CD tools.

7. How to enable webhook in git?


Ans: In git --> go to profile --> go to settings --> Search for webhook
Enable it.

8. How to share ssh key with bit-bucket or git?


Ans: If you have Linux machine go to user home
Generate ssh-key by typing
"ssh-keygen" go to your .ssh directory and copy the public key.
Go to your GIT account --> profile --> setting --> Add_ssh_key
paste your ssh_public key here.

9. What is the difference between GIT and Bit Bucket?


Ans: Bit bucket and GitHub are very closely matched in terms of features if you need to use
Git. And if your VCS is Mercurial, then it's only Bit bucket for you.
Each has some useful features not found in the other, such as GitHub pages for small web-
hosting projects, or Bit bucket’s JIRA integration

10. What is the difference between GIT and SVN?


Ans:
The difference between GIT and SVN is
a) Git is less preferred for handling extremely large files or frequently changing binary files
while SVN can handle multiple projects stored in the same repository.

b) GIT does not support ‘commits’ across multiple branches or tags. Subversion allows the
creation of folders at any location in the repository layout.

c) Gits are unchangeable, while Subversion allows committers to treat a tag as a branch and
to create multiple revisions under a tag root.

11. What is the purpose of branching in GIT?

Ans: The purpose of branching in GIT is that you can create your own branch and jump
between those branches.
It will allow you to go to your previous work keeping your recent work intact

12. What is a ‘conflict’ in git?

Ans: A ‘conflict’ arises when the commit that has to be merged has some change in one
place, and the current commit also has a change at the same place.
Git will not be able to predict which change should take precedence.

13. How can conflict in git resolved?

Ans: To resolve the conflict in git, edit the files to fix the conflicting changes and then add
the resolved files by running “git add” after that to commit the repaired merge, run “git
commit”.
Git remembers that you are in the middle of a merger, so it sets the parents of the commit
correctly.

14. To delete a branch what is the command that is used?

Ans: Once your development branch is merged into the main branch, you don’t need

development branch. To delete a branch use, the command “git branch –d [head]”.

15. What is another option for merging in git?


Ans: “Rebasing” is an alternative to merging in git.

16. What is the syntax for “Rebasing” in Git?

Ans: The syntax used for rebase is “git rebase [new-commit] “

17. What is the difference between ‘git remote’ and ‘git clone’?

Ans: ‘git remote add’ just creates an entry in your git config that specifies a name for a
particular URL.
While, ‘git clone’ creates a new git repository by copying and existing one located at the
URI.

############ Topic 4 - Linux ###############

1. What is load on Linux machine and how to check the load on machine, how much load on
machine is good or bad?
Ans: Load on machine is never good, The command w show the average load on linux
machine
for 5 minute duration.

2. How to check memory in Linux machine?


Ans: free -m

3. What is the output of top command?


Ans:

4. What is difference between softlink and hard link?


Ans: Soft link is like and shortcut file in windows and hard-link is the same as main file. In
case of soft link inode value will be change but in case of hard-link inode value will be same.

5.What happen if i remove soft link of any file?


Ans: The parent file will always be there.

6. Let’s say my server is performing very slow, What are the basic steps involved to
troubleshoot this issue?
Ans: Check the load on server, check the memory consumptions and users logedin.

7. What happen if I use command cp -r /tmp/abc.txt /tmp/abcd/abc.txt?


Ans: This command will copy all the data of abc.txt file with recursive permission from old
location to
new location

8. How to increase user limit for any file,If my application is giving error at start up for user
limit?
Ans: Since the default limit for any file in Linux for any user is 1024 pages. So If my
application is giving error in start up
for user limit, then we should go to the file
vim /etc/security/limits.conf

Examples

These are some example lines which might be specified in /etc/security/limits.conf.

* soft core 0
* hard nofile 512
@student hard nproc 20
@faculty soft nproc 20
@faculty hard nproc 50
ftp hard nproc 0
@student - maxlogins 4
:123 hard cpu 5000
@500: soft cpu 10000
600:700 hard locks 10

9. What is swap file in Linux, why we should use this?


Ans:
Swap space in Linux is used when the amount of physical memory (RAM) is full. If the
system needs more memory resources and the RAM is full,
inactive pages in memory are moved to the swap space. While swap space can help
machines with a small amount of RAM,
it should not be considered a replacement for more RAM. Swap space is located on hard
drives, which have a slower access time than physical memory.

10. What is the command is use to create an swap file in Linux?


Ans: Creating a Swap File

To add a swap file:

Determine the size of the new swap file in megabytes and multiply by 1024 to determine
the number of blocks. For example, the block size of a 64 MB swap file is 65536.
At a shell prompt as root, type the following command with count being equal to the desired
block size:
# dd if=/dev/zero of=/swapfile bs=1024 count=65536
Setup the swap file with the command:
# mkswap /swapfile
To enable the swap file immediately but not automatically at boot time:
# swapon /swapfile
To enable it at boot time, edit /etc/fstab to include the following entry:
# /swapfile swap swap defaults 0 0
The next time the system boots, it enables the new swap file.

After adding the new swap file and enabling it, verify it is enabled by viewing the output of
the command cat
#/proc/swaps or free.

11. What is Inode in Linux?


Ans: An inode is an entry in inode table, containing information (the metadata) about a
regular file and directory.

# Inode number also called as index number , it consists following attributes.

File types ( executable, block special etc )


Permissions ( read, write etc )
UID ( Owner )
GID ( Group )
FileSize
Time stamps including last access, last modification and last inode number change.
File deletion time
Number of links ( soft/hard )
Location of ile on harddisk.
Some other metadata about file.

12. Can you please let me know the entry of /etc/password file?
Ans:

Username: It is used when user logs in. It should be between 1 and 32 characters in length.
Password: An x character indicates that encrypted password is stored in /etc/shadow file.
User ID (UID): Each user must be assigned a user ID (UID). UID 0 (zero) is reserved for
root and UIDs 1-99 are reserved for other predefined accounts.
Further UID 100-999 are reserved by system for administrative and system
accounts/groups.
Group ID (GID): The primary group ID (stored in /etc/group file)
User ID Info: The comment field. It allow you to add extra information about the users such
as user’s full name, phone number etc.
This field use by finger command.
Home directory: The absolute path to the directory the user will be in when they log in. If
this directory does not exists then users directory becomes /
Command/shell: The absolute path of a command or shell (/bin/bash). Typically, this is a
shell. Please note that it does not have to be a shell.

13. How can we add user and assign customize home directory to it ?

Ans: Create a new user with home directory in Linux


If you are logged in as root then write the following:

#useradd -m -d /home/dirjoe joe

If you are logged in as a user with “sudoers” privileges:

# sudo useradd -m -d /home/dirjoe joe

14. I want to copy a file abc.txt from server A to server B in same neteork, By whcih
command I can achive it ?
Ans: By using scp command we can achive this and command will be
# scp -r source_path user@destination_Server_IP:/destination_path

15. How do i check how many user’s logins to my server?


# By using " w " command we can check how many users are logged-in to my server.

16. How do you create ext4 file system?


Ans: # mke2fs -t ext4 /dev/DEV

17. Which account is created on Linux installation?


Ans: - With the installation of Linux, a super user account is created called as ‘root’.

You might also like