---
# System prepended metadata

title: Ansible

---

I have done my bachelors in Computer science in SRM unoversity and then I came to US to pursue my master in computer science. I have graduated from in Summer 2022 from UNT. While I was studying Master, My interests grew on cloud and I started learning basics of Linux, Kubernetes AWS, Ansible and Terraform. 



Linux Question 

1. How to check which ports are being used in linux
`netstat -na | grep <the port number>`

Example:
`netstat -na | grep 8080`
 
2. How to get child process id from parent id?
`pgrep -P <parent_process_id>`
or
`pstree -p <Parent_process_ID>`

Example: 
* pgrep -P 6734
* pstree -p 9869

3. Check running process in Linux
`ps aux`

4. How to curl from server or client
curl `<hostname>`

Example: 
* curl `www.google.com`
* curl `192.0.0.1`

5. How to install packages in linux:

In Debain Systems: like Ubuntu
`apt get install <package name>`
Example: 
* `apt get install googlechrom`
* `apt get install ntp`

In Red Hat Systems:
yum install `<package name>`
Example: 
* `yum install googlechrom`
* `yum install ntp`

6. How to check routes in linux

`route -n`

Example:
```
$ route -n
Kernel IP routing table
Destination    Gateway       Genmask        Flags  Metric Ref Use Iface
0.0.0.0        192.168.0.1   0.0.0.0        UG     0      0   0   wlan0
192.168.0.0    0.0.0.0       255.255.255.0  U      9      0   0   wlan0
```

7. How do you analayze packets in linux

`tcpdump`

Example
* `tcpdump -i eth0 udp`

8. How do you check the traffic flow between server A and Server B

`traceroute <end server>`
    
Example: if you want to check the traffic flow between your local server and google
    
    traceroute google.com
    
9. Do you know IP address class     

```
                     Subnet Mask    Example IP  Usage
Class A  1 to 126    255.0.0.0      1.1.1.1    Used for large number of hosts.
Class B  128 to 191  255.255.0.0    128.1.1.1  Used for medium size network
Class C  192 to 223  255.255.255.0  192.1.1.1  Used for local area network.
Class D  224 to 239                 224.1.1.1  Reserve for multi-tasking.
Class E  240 to 254                 240.1.1.1  This class is reserved for research and Development Purposes.
```

11. What is a subnet?
 
A subnet, or subnetwork, is a network inside a network. Subnets make networks more efficient. Through subnetting, network traffic can travel a shorter distance without passing through unnecessary routers to reach its destination.
![](https://i.imgur.com/bpPC67O.png)

12. Network and Host portion
https://www.youtube.com/watch?v=eHV1aOnu7oM


14. How to calcuate the number of IP address or hosts in a subnet 

https://www.youtube.com/watch?v=9uC-6lV1xT4
https://www.geeksforgeeks.org/how-to-calculate-number-of-host-in-a-subnet/#:~:text=In%20simple%20words,%20the%20Number,bits%20in%20the%20IP%20address.


**Kubernetes**

9. What container technologies are you familair with 

* docker
* containerd

10. What is kubernetes? 
Kubernetes is open source platform for managing containerized workloads and services.

11. liveness  vs Readiness probe
Kubernetes uses liveness probes to know when to restart a container. Kubernetes uses readiness probes to decide when the container is available for accepting traffic.

12. Replica Sets vs Replication controller 
The key difference between the replica set and the replication controller is, the replication controller only supports equality-based selector(selector whereas the replica set supports set-based selector(match Labels).

13.  difference between a DaemonSet and deployment?
A Daemonset will not run more than one replica per node. Another advantage of using a Daemonset is that, if you add a node to the cluster, then the Daemonset will automatically spawn a pod on that node, which a deployment will not do.

14. differnace between Statefulset and Deployment
Every replica of a stateful set will have its own state, and each of the pods will be creating its own PVC(Persistent Volume Claim). Deployment would share same PV.

15. What is ingress
Ingress provides the ability to pods to communicate  outside of cluster. For example if your application needs to be accessed from outside of kubernetes cluster you need ingress

`kubectl get ingress`

16. What is kube-proxy used for ?
maintains network rules on nodes.

18. kubernetes architecture

Kubernetes has Control Plan and Compute Plane

Control Plane has below componenets:
* kube-apiserver: Exposes the Kubernetes API.
* etcd: Consistent and highly-available key value store used as Kubernetes' backing store for all cluster data.
* kube-scheduler: Used to schedule pods
* kube-controller-manager: Control plane component that runs controller processes.

Compute Plane or Worker Node:
* kubelet: An agent that runs on each node in the cluster.
* Kube-proxy: maintains network rules on nodes.

![](https://i.imgur.com/kPhS001.png)


# Ansible
20. What is Ansible? 
Ansible is a Configuration management tool that can be used to deploy applictions, provision infrastructure and and many other manual IT processes

21. Have you written any Ansible Playbooks?
Yes, I have written a Ansible Playbooks in my local. Its simple playbook that uses `apt` module to install ntp package and used `lineinfile` to update the configuration file and `service` module to start the ntp service  

if they ask what is NTP?
NTP stands for Network Time Protocol, and it is an Internet protocol used to synchronize the clocks of computers to some time reference


22. What modules you used in ansible
I am aware of 
shell, lineinfile, blockinfile, copy, fetch, sysct, file, apt, yum modules 

23. What is a `role` in Ansible?

Instead of writing everything in playbook, it is a mechanism for breaking a playbook into multiple files. roles can be reused in other playbooks

24. What is a Handler in Ansible?
When you have two tasks, lets say `Task A` and `Task B`. In a scenario where task B should be executed only when task A is successful, then you use handler

25. Ansible Playbook looks like

```
--- 
   name: Install and configure NTP
   hosts: localhost
   become: yes
  
   tasks:
   -name: Install the ntp package
    apt: name=ntp state=installed
    
   -name: Ensure the installed service is enabled and running
   service: name=ntp state=start
```

# AWS

26. What Services in AWS are you Familiar with ?
EC2, EBS, S3, EKS, IAM and VPC 

EC2(Elastic Cloud Compute) is a service in AWS used for creating Virtual Machines 
EBS(Elastic Block Storage) is a service in AWS used for managing block Storage 
S3  is a service in AWS used for managing object storage
EKS is a Managed service Kubernetes service provided by AWS
VPC is a service in AWS used for managing networks and subnets
IAM is a service in AWS used for managing users, groups, roles, polices 

27. How do you connect two VPCs?
A VPC peering connection is a networking connection between two VPCs that enables you to route traffic between them

28. IAM Role, Policy,

# Terrafrom

terrafrom plan: Preview the actions Terraform would take to modify your infrastructure 
terrafrom apply: Will Apply the change from plan

