Build Automation Gradle Interview Questions


What does the command ./gradlew do when it is run from within a Gradle project’s directory?
– It runs the Gradle Wrapper.

What does a smoke test do?
– Tests large-scale, basic things like whether or not the application runs.

What can you use to take advantage of pre-built Gradle tasks created by the Gradle community?
– Gradle plugins

Which of the following are the kinds of tasks build automation tools usually handle? (Choose all that apply)

– Compiling code
– Packaging the app for deployment
– Dependency management

What does Gradle do?
– Build Automation

Which type of testing tests the smallest amount of code in a single test?
– Unit test

Which of the following does declaring a dependency between two tasks in Gradle do? (Choose all that apply)

– It ensures that when a task is called, the task that it depends on also runs.
– It ensures that if both tasks are run, the task which is a dependency will always run before the one that depends on it.
What software does Gradle require to be installed on a system before it can run?
– Java JDK 7 or higher

What does build automation do?
– It automates the process of processing source code in preparation for deployment.

Terraform Interview Questions


You are testing out a new environment and need to ensure you are using the right syntax to reference resources. What are two commands that can help you discover and test the correct interpolation syntax?

– terraform console
– terraform show
How would name a Docker image resource for reference later?

– resources “docker_image”
How do you specify the location of the module you are referencing in the root/main.tf file?

– source = “./modulename”
You need to deploy a development and a production environment simultaneously on the same machine. What feature of Terraform allows you to deploy multiple environments with independent states?

– workspace

You are writing a Terraform script to deploy Docker containers for your organization. You have several items to deploy, what word does Terraform use to refer to each item it deploys?

– Resources
If you change the port of a Docker container in your Terraform script and run a “terraform apply”, what will happen to your deployment?

– The old resource is destroyed and the new one takes its place.
You are referencing infrastructure in an output file. In this resource: “resource “docker_image” “ghost””, which string is the resource ID?

– ghost
You need to be able to specify different variable definitions based on whether the environment is a production or development area. What type of variables rely on key-value pairs in order to be defined dynamically based on other provided information?

– Maps

You are trying to search your system for the file that contains all of your variable definitions. The previous admin has lost it. What extension does the file that holds your variable definitions have?

– .tfvars

Which of the following is an accurate use description for Terraform?

– Terraform is used for building, changing, and versioning infrastructure with safely and efficiently.

You need to output the IP address of your docker container with ID “container_id” in order to provide access to your coworkers. How would you script this output value?

– value = “${docker_container.container_id.ip_address}”

Which provisioner should you use to run a command on the Terraform server during deployment?

– local-exec

At your company, you need to provide a deployment with variables that are defined interactively when applying. For the “image” variable, you want to ensure the user knows this refers to the name of the image. How would you word this in your variable block?

– description = “name of the image”

You are trying to decide how to define your variables. What are three common files in which you can specify the value of a variable without having to use a function to extract them? (Choose all that apply)

– variables.tf
– main.tf
– terraform.tfvars

You have a variable that changes often and you want the ability to modify it during your Terraform apply, either via an external file or by entering it interactively. How should this variable be expressed in the variables.tf file?

– variable “image” {}

The best place to learn Terraform is :Linux Academy

Common commands in Terraform


$ terraform help

Common commands:

apply              Builds or changes infrastructure

console            Interactive console for Terraform interpolations

destroy            Destroy Terraform-managed infrastructure

env                Workspace management

fmt                Rewrites config files to canonical format

get                Download and install modules for the configuration

graph              Create a visual graph of Terraform resources

import             Import existing infrastructure into Terraform

init               Initialize a Terraform working directory

output             Read an output from a state file

plan               Generate and show an execution plan

providers          Prints a tree of the providers used in the config

push               Upload this Terraform module to Atlas to run

refresh            Update local state file against real resources

show               Inspect Terraform state or plan

taint              Manually mark a resource for recreation

How to install Ansible


 

root@aryan-VirtualBox:~# apt-add-repository ppa:ansible/ansible
Ansible is a radically simple IT automation platform that makes your applications and systems easier to deploy. Avoid writing scripts or custom code to deploy and update your applications— automate in a language that approaches plain English, using SSH, with no agents to install on remote systems.

http://ansible.com/
More info: https://launchpad.net/~ansible/+archive/ubuntu/ansible
Press [ENTER] to continue or Ctrl-c to cancel adding it.

Hit:1 http://ca.archive.ubuntu.com/ubuntu bionic InRelease
Get:2 http://ca.archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7 kB]
Get:3 http://ca.archive.ubuntu.com/ubuntu bionic-backports InRelease [74.6 kB]

 

root@aryan-VirtualBox:~# apt-get install ansible
Reading package lists… Done
Building dependency tree
Reading state information… Done
The following additional packages will be installed:
python-httplib2 python-jinja2 python-markupsafe python-paramiko
python-pyasn1 python-yaml sshpass
Suggested packages:
python-jinja2-doc python-gssapi
The following NEW packages will be installed:
ansible python-httplib2 python-jinja2 python-markupsafe python-paramiko
python-pyasn1 python-yaml sshpass
0 upgraded, 8 newly installed, 0 to remove and 10 not upgraded.
Need to get 4,369 kB of archives.
After this operation, 36.7 MB of additional disk space will be used.
Do you want to continue? [Y/n]

Terraform acquires a state lock to protect the state from being written by multiple users at the same time.


Terraform acquires a state lock to protect the state from being written by multiple users at the same time.

Please resolve the issue above and try again. For most commands, you can disable locking with the “-lock=false” flag, but this is not recommended.

Terraform.tfstate file got corrupted. rename your terraform.tfstate file.  

Error: Error locking state: Error acquiring the state lock: open terraform.tfstate: permission denied

Terraform acquires a state lock to protect the state from being writtenby multiple users at the same time. Please resolve the issue above and try again. For most commands, you can disable locking with the “-lock=false” flag, but this is not recommended.
aryan@aryan-VirtualBox:~/docker$ ll
aryan@aryan-VirtualBox:~/docker$ ls .terraform/
aryan@aryan-VirtualBox:~/docker$ less terraform.tfstate
aryan@aryan-VirtualBox:~/docker$ mv terraform.tfstate old_terraform.tfstate