Explore topic-wise InterviewSolutions in .

This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.

1.

How to use YAML files in high programming languages such as JAVA, Python, etc?

Answer»

YAML is supported in most programming languages and can be easily integrated with USER programs.
In JAVA we can use the Jackson module which also parses XML and JSON. For e.g

// We need to declare Topic class with necessary attributes such as name, total_score, user_score, sub_topicsList<Topic> topics = NEW ArrayList<Topic>();topics.add(new Topic("String Manipulation", 10, 6));topics.add(new Topic("Knapsack", 5, 5));topics.add(new Topic("Sorting", 20, 13));// We want to save this Topic in a YAML fileTopic topic = new Topic("DS & Algo", 35, 24, topics);// ObjectMapper is instantiated just like beforeObjectMapper om = new ObjectMapper(new YAMLFactory());// We write the `topic` into `topic.yaml`om.writeValue(new File("/src/main/resources/topics.yaml"), topic);---name: "DS & Algo"total_score: 35user_score: 24sub_topics:- name: "String Manipulation" total_score: 10 user_score: 6- name: "Knapsack" total_score: 5 user_score: 5- name: "Sorting" total_score: 20 user_score: 13

Similarly, we can read from YAML also:

// Loading the YAML file from the /resources folderClassLoader classLoader = Thread.currentThread().getContextClassLoader();File file = new File(classLoader.getResource("topic.yaml").getFile());// Instantiating a new ObjectMapper as a YAMLFactoryObjectMapper om = new ObjectMapper(new YAMLFactory());// Mapping the employee from the YAML file to the Employee classTopic topic = om.readValue(file, Topic.class);

In python similarly, we can use the pyyaml library and read and write easily in YAML format.

2.

What are Ansible tasks?

Answer»

The task is a unit action of ANSIBLE. It helps by breaking a configuration policy into smaller files or blocks of code. These blocks can be USED in AUTOMATING a process. For example, to install a PACKAGE or update a software

Install &LT;package_name>, update <software_name>

3.

What is a YAML file and how do we use it in Ansible?

Answer»

YAML or files are LIKE any formatted text file with few sets of RULES just like JSON or XML. Ansible uses this syntax for playbooks as it is more readable than other formats.
An example of JSON vs YAML is:

{ "object": {"key": "VALUE","array": [ { "null_value": null }, { "boolean": true }, { "integer": 1 }, { "alias": "aliases are like VARIABLES" }] }}---object: key: value array: - null_value: - boolean: true - integer: 1 - alias: aliases are like variables
4.

Explain Ansible modules in detail?

Answer»

Ansible modules are like functions or standalone scripts which run specific tasks idempotently. The return value of these are JSON string in stdout and input depends on the type of MODULE. These are used by Ansible playbooks.
There are 2 types of modules in Ansible:

  • Core Modules

The core Ansible team is responsible for maintaining these modules thus these come with Ansible itself. The issues reported are fixed on priority than those in the “extras” repo.

  • Extras Modules

The Ansible COMMUNITY maintains these modules so, for now, these are being SHIPPED with Ansible but they MIGHT get discontinued in the future. These can be used but if there are any FEATURE requests or issues they will be updated on low priority.

Now popular extra modules might enter into the core modules anytime. You may find these separate repos for these modules as ansible-modules-core and ansible-modules-extra respectively.

5.

What is Ansible Galaxy?

Answer»

Galaxy is a repository of Ansible roles that can be shared AMONG users and can be directly dropped into playbooks for execution. It is also used for the distribution of packages containing roles, plugins, and modules also known as collection. The ansible-galaxy-collection command IMPLEMENTS similar to init, build, install, ETC like an ansible-galaxy command.

6.

Explain Infrastructure as Code?

Answer»

INFRASTRUCTURE as Code or IaC is a process that DevOps teams should follow to have a more organized way of MANAGING the infra. Instead of some throwaway scripts or manually configuring any cloud component, there should be a code repo where all of these will lie and any change in configuration should be done through it. It is wise to PUT it under source control also. This improves speed, CONSISTENCY, and ACCOUNTABILITY.

7.

What are the features of Ansible?

Answer»

It has the following features:

  • Agentless – Unlike puppet or chef there is no software or AGENT managing the nodes.
  • Python – Built on top of python which is very easy to learn and write scripts and one of the robust programming languages.
  • SSH – Passwordless network authentication which makes it more SECURE and easy to set up.
  • Push architecture – The core concept is to push multiple small codes to the configure and run the action on client nodes.
  • Setup – This is very easy to set up with a very low learning curve and any OPEN source so that anyone can get hands-on.
  • Manage Inventory – Machines’ addresses are STORED in a simple text format and we can add different sources of truth to pull the list using PLUGINS such as Openstack, Rackspace, etc.
8.

How does Ansible work?

Answer»

Ansible is a combination of multiple pieces working together to become an automation tool. Mainly these are modules, playbooks, and plugins.

  • Modules are small codes that will get executed. There are multiple inbuilt modules that serve as a starting point for building tasks.
  • Playbooks contain plays which further is a group of tasks. This is the PLACE to DEFINE the workflow or the steps needed to COMPLETE a process
  • Plugins are special kinds of modules that run on the main control machine for LOGGING PURPOSES. There are other types of plugins also.

The playbooks ran via an Ansible automation engine. These playbooks contain modules that are basically actions that run in host machines. The mechanism is followed here is the push mechanism, so ansible pushes small programs to these host machines which are written to be resource models of the desired state of the system.

9.

What is Configuration Management?

Answer»

It’s a practice that we should follow in ORDER to keep track of all updates that are going into the system over a period of time. This also HELPS in a situation where a major bug has been introduced to the system due to some new changes and we need to FIX it with minimum DOWNTIME. Instead of fixing the bug, we can roll back the new changes(which caused this bug) as we have been TRACKING those.

10.

What is CI/CD?

Answer»

Continuous Integration is something that is USED for streamlining the development and deployment process. These lead to the more rapid development of cohesive software. 
Continuous Delivery is on the other hand is a process where your code after being pushed to a remote repository can be taken to production at any time.

In the above diagram our integration TEST and UNIT test are performed without any manual intervention and after UAT we just NEEDED the APPROVAL to ship our tested features to production and to make such a process we need CI/CD.