devops1 Flashcards
devops questions
Difference between Ansible Playbook and Role
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 do you get a list of all the variables available on a remote machine in ansible
Ansible -m setup
how do you check all the inventory variables for a host in ansible
Ansible -m debug- a “var=hostvars[‘hostname’]” localhost
how do you test connectivity with all the hosts in your hostfile in ansible
Ansible - m ping all
How do you make Ansible code reusable
by using roles
How do you create an Ansible Role file structure
ansible-galaxy init azavea.packer
how to syntax check an ansible file
ansible-playbook –syntax-check buildmachine.yml
how do you call an ansible handler
(handler are used to restart services and do other things when another action is performed.) with a notify: - restart memcached - restart apache
list hosts effected by a playbook
ansible-playbook playbook.yml –list-hosts
In terraform how do you include a module
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}” } }
Limit memory on a docker container
docker run -m=4m limit it to 4meg
Limit cpu on a docker containers
docker run -cpus=1.5
Write a Docker file that uses ubuntu and runs ping www.google.com
FROM ubuntu
run “ping www.google.com”
What is the difference between a docker container and a image?
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 to do you clean unused docker stuff
docker system prune -a