{"id":22728,"date":"2021-07-24T20:08:51","date_gmt":"2021-07-24T20:08:51","guid":{"rendered":"https:\/\/www.devopsschool.com\/blog\/?p=22728"},"modified":"2021-10-23T07:24:29","modified_gmt":"2021-10-23T07:24:29","slug":"interview-questions-answers-for-ansible","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/interview-questions-answers-for-ansible\/","title":{"rendered":"Interview Questions &#038; Answers for Ansible"},"content":{"rendered":"\n<h1 class=\"wp-block-heading\">Ansible<\/h1>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">Describe each of the following components in Ansible, including the relationship between them:<\/h3>\n\n\n\n<ul class=\"wp-block-list\"><li>Task<\/li><li>Module<\/li><li>Play<\/li><li>Playbook<\/li><li>Role<\/li><\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">How Ansible is different from other Automation tools?<\/h3>\n\n\n\n<h3 class=\"wp-block-heading\">True or False? Ansible follows the mutable infrastructure paradigm<\/h3>\n\n\n\n<h3 class=\"wp-block-heading\">True or False? Ansible uses declarative style to describe the expected end state<\/h3>\n\n\n\n<h3 class=\"wp-block-heading\">What kind of automation you wouldn&#8217;t do with Ansible and why?<\/h3>\n\n\n\n<h3 class=\"wp-block-heading\">What is an inventory file and how do you define one?<\/h3>\n\n\n\n<h3 class=\"wp-block-heading\">What is a dynamic inventory file? When you would use one?<\/h3>\n\n\n\n<h3 class=\"wp-block-heading\">How do you list all modules and how can you see details on a specific module?<\/h3>\n\n\n\n<h3 class=\"wp-block-heading\">Write a task to create the directory \u2018\/tmp\/new_directory\u2019<\/h3>\n\n\n\n<h3 class=\"wp-block-heading\">You want to run Ansible playbook only on specific minor version of your OS, how would you achieve that?<\/h3>\n\n\n\n<h3 class=\"wp-block-heading\">What the &#8220;become&#8221; directive used for in Ansible?<\/h3>\n\n\n\n<h3 class=\"wp-block-heading\">What are facts? How to see all the facts of a certain host?<\/h3>\n\n\n\n<h3 class=\"wp-block-heading\">What would be the result of the following play?<\/h3>\n\n\n\n<h3 class=\"wp-block-heading\">What would be the result of running the following task? How to fix it?<\/h3>\n\n\n\n<ul class=\"wp-block-list\"><li>hosts: localhost tasks:<ul><li>name: Install zlib<br>package:<br>name: zlib<br>state: present<\/li><\/ul><\/li><\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Which Ansible best practices are you familiar with?. Name at least three<\/h3>\n\n\n\n<h3 class=\"wp-block-heading\">Explain the directory layout of an Ansible role<\/h3>\n\n\n\n<h3 class=\"wp-block-heading\">What &#8216;blocks&#8217; are used for in Ansible?<\/h3>\n\n\n\n<h3 class=\"wp-block-heading\">How do you handle errors in Ansible?<\/h3>\n\n\n\n<h3 class=\"wp-block-heading\">You would like to run a certain command if a task fails. How would you achieve that?<\/h3>\n\n\n\n<h3 class=\"wp-block-heading\">Write a playbook to install \u2018zlib\u2019 and \u2018vim\u2019 on all hosts if the file \u2018\/tmp\/mario\u2019 exists on the system.<\/h3>\n\n\n\n<h3 class=\"wp-block-heading\">Write a single task that verifies all the files in files_list variable exist on the host<\/h3>\n\n\n\n<h3 class=\"wp-block-heading\">Write a playbook to deploy the file \u2018\/tmp\/system_info\u2019 on all hosts except for controllers group, with the following content<\/h3>\n\n\n\n<h3 class=\"wp-block-heading\">The variable &#8216;whoami&#8217; defined in the following places:<\/h3>\n\n\n\n<ul class=\"wp-block-list\"><li>role defaults -&gt; whoami: mario<\/li><li>extra vars (variables you pass to Ansible CLI with -e) -&gt; whoami: toad<\/li><li>host facts -&gt; whoami: luigi<\/li><li>inventory variables (doesn\u2019t matter which type) -&gt; whoami: browser<\/li><\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">According to variable precedence, which one will be used?<\/h3>\n\n\n\n<h3 class=\"wp-block-heading\">For each of the following statements determine if it&#8217;s true or false:<\/h3>\n\n\n\n<ul class=\"wp-block-list\"><li>A module is a collection of tasks<\/li><li>It\u2019s better to use shell or command instead of a specific module<\/li><li>Host facts override play variables<\/li><li>A role might include the following: vars, meta, and handlers<\/li><li>Dynamic inventory is generated by extracting information from external sources<\/li><li>It\u2019s a best practice to use indention of 2 spaces instead of 4<\/li><li>\u2018notify\u2019 used to trigger handlers<\/li><li>This \u201chosts: all:!controllers\u201d means \u2018run only on controllers group hosts<\/li><\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Explain the Diffrence between Forks and Serial &amp; Throttle.<\/h3>\n\n\n\n<h3 class=\"wp-block-heading\">What is ansible-pull? How is it different from how ansible-playbook works?<\/h3>\n\n\n\n<h3 class=\"wp-block-heading\">What is Ansible Vault?<\/h3>\n\n\n\n<h3 class=\"wp-block-heading\">Demonstrate each of the following with Ansible:<\/h3>\n\n\n\n<ul class=\"wp-block-list\"><li>Conditionals<\/li><li>Loops<\/li><\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">What are filters? Do you have experience with writing filters?<\/h3>\n\n\n\n<h3 class=\"wp-block-heading\">Write a filter to capitalize a string<\/h3>\n\n\n\n<h3 class=\"wp-block-heading\">You would like to run a task only if previous task changed anything. How would you achieve that?<\/h3>\n\n\n\n<h3 class=\"wp-block-heading\">What are callback plugins? What can you achieve by using callback plugins?<\/h3>\n\n\n\n<h3 class=\"wp-block-heading\">What is Ansible Collections?<\/h3>\n\n\n\n<h3 class=\"wp-block-heading\">Ansible Testing<\/h3>\n\n\n\n<h3 class=\"wp-block-heading\">How do you test your Ansible based projects?<\/h3>\n\n\n\n<h3 class=\"wp-block-heading\">What is Molecule? How does it works?<\/h3>\n\n\n\n<h3 class=\"wp-block-heading\">You run Ansibe tests and you get &#8220;idempotence test failed&#8221;. What does it mean? Why idempotence is important?<\/h3>\n\n\n<div class=\"epyt-gallery\" data-currpage=\"1\" id=\"epyt_gallery_29128\"><iframe loading=\"lazy\"  id=\"_ytid_83226\"  width=\"760\" height=\"427\"  data-origwidth=\"760\" data-origheight=\"427\" src=\"https:\/\/www.youtube.com\/embed\/?enablejsapi=1&#038;autoplay=0&#038;cc_load_policy=0&#038;cc_lang_pref=&#038;iv_load_policy=1&#038;loop=0&#038;rel=1&#038;fs=1&#038;playsinline=0&#038;autohide=2&#038;theme=dark&#038;color=red&#038;controls=1&#038;disablekb=0&#038;\" class=\"__youtube_prefs__  no-lazyload\" title=\"YouTube player\"  data-epytgalleryid=\"epyt_gallery_29128\"  allow=\"fullscreen; accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen data-no-lazy=\"1\" data-skipgform_ajax_framebjll=\"\"><\/iframe><div class=\"epyt-gallery-list\"><div>Sorry, there was a YouTube error.<\/div><\/div><\/div>","protected":false},"excerpt":{"rendered":"<p>Ansible Describe each of the following components in Ansible, including the relationship between them: Task Module Play Playbook Role How Ansible is different from other Automation tools? True or False?&#8230; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_joinchat":[],"footnotes":""},"categories":[5038,52],"tags":[],"class_list":["post-22728","post","type-post","status-publish","format-standard","hentry","category-ansible","category-interview-questions-answers"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/22728","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=22728"}],"version-history":[{"count":3,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/22728\/revisions"}],"predecessor-version":[{"id":24251,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/22728\/revisions\/24251"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=22728"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=22728"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=22728"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}