devops1 Flashcards

devops questions

1
Q

Difference between Ansible Playbook and Role

A

Role is a set of tasks and additional files to configure host to serve for a certain role. Playbook is a mapping between hosts and roles.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

how do you get a list of all the variables available on a remote machine in ansible

A

Ansible -m setup

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

how do you check all the inventory variables for a host in ansible

A

Ansible -m debug- a “var=hostvars[‘hostname’]” localhost

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

how do you test connectivity with all the hosts in your hostfile in ansible

A

Ansible - m ping all

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How do you make Ansible code reusable

A

by using roles

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How do you create an Ansible Role file structure

A

ansible-galaxy init azavea.packer

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

how to syntax check an ansible file

A

ansible-playbook –syntax-check buildmachine.yml

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

how do you call an ansible handler

A

(handler are used to restart services and do other things when another action is performed.) with a notify: - restart memcached - restart apache

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

list hosts effected by a playbook

A

ansible-playbook playbook.yml –list-hosts

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

In terraform how do you include a module

A

Inside a resource you run: user_data = “${element(data.template_file.userdata01.*.rendered, count.index)}” and then you have a data section to render the template with variables data “template_file” “userdata01” { count = “${var.instanceCount}” template = “${file(“${path.module}/templates/cloud.tpl”)}” vars { cluster = “${var.cluster}” env = “${var.env}” fqdn = “${format(“${var.serverFunction}-${var.cluster}-%02d.${var.env}.inteliquent.net”, count.index+1)}” hostname = “${format(“${var.serverFunction}-${var.cluster}-%02d”, count.index+1)}” saltRoles = “${var.saltRoles}” serverFunction = “${var.serverFunction}” } }

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Limit memory on a docker container

A

docker run -m=4m limit it to 4meg

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Limit cpu on a docker containers

A

docker run -cpus=1.5

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Write a Docker file that uses ubuntu and runs ping www.google.com

A

FROM ubuntu

run “ping www.google.com”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is the difference between a docker container and a image?

A

An instance of an image is called a container. You have an image, which is a set of layers as you describe. If you start this image, you have a running container of this image. You can have many running containers of the same image.

You can see all your images with docker images whereas you can see your running containers with docker ps (and you can see all containers with docker ps -a).

So a running instance of an image is a container.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

how to do you clean unused docker stuff

A

docker system prune -a

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Configure iptables to allow all traffic

A

iptables –policy INPUT ACCEPT
iptables –policy OUTPUT ACCEPT
iptables –policy FORWARD ACCEPT

17
Q

configure iptables to drop all traffic

A

iptables –policy INPUT DROP
iptables –policy OUTPUT DROP
iptables –policy FORWARD DROP

18
Q

Configure iptables to block incoming connections from 10.10.10.10

A

iptables -A INPUT -s 10.10.10.10 -j DROP

19
Q

Configur iptables to drop traffic from the 10.10.10.0/24 network

A

iptables -A INPUT -s 10.10.10.0/24 -j DROP

or

iptables -A INPUT -s 10.10.10.0/255.255.255.0 -j DROP

20
Q

configure iptables to inbound ssh but disable outbound ssh (alothough allow ssh outbound if it’s from a inbound connection)

A

iptables -A INPUT -p tcp –dport ssh -s 10.10.10.10 -m state –state NEW,ESTABLISHED -j ACCEPT

iptables -A OUTPUT -p tcp –sport 22 -d 10.10.10.10 -m state –state ESTABLISHED -j ACCEPT

21
Q

configure iptables to drop ssh connection from 10.10.10.10

A

iptables -A INPUT -p tcp –dport ssh -s 10.10.10.10 -j DROP

22
Q

iptables list rules with line numbers

A

iptables -L -n –line-numbers

23
Q

Delete an iptables rule with it’s line number

A

iptables -D INPUT 2

24
Q

Insert a rule at the top of the chain in iptables

A

iptables -I INPUT 1 -s 59.45.175.10 -j ACCEPT

25
Q

Iptables drop multiple ports from a network range

A

iptables -A INPUT -p tcp -m multiport –dports 22,5901 -s 59.45.175.0/24 -j DROP

26
Q

configure iptables to only allow ports 22,80 and 443

A

iptables -A INPUT -p tcp -m multiport ! –dports 22,80,443 -j DROP

27
Q

Create a iptables custom chain called ssh-rules and add configure it to be in the main input chain.

A

iptables -N ssh-rules

iptables -A ssh-rules -s 18.130.0.0/16 -j ACCEPT

iptables -A ssh-rules -s 18.11.0.0/16 -j ACCEPT

iptables -A ssh-rules -j DROP

iptables -A INPUT -p tcp -m tcp –dport 22 -j ssh-rules

28
Q

make iptables persistant in centos/rhel

A

sudo yum install iptables-services

29
Q

make iptables persistant in ubuntu

A

sudo apt install iptables-persistent