---
tags:
- devops
- l1
- flashcard-deck
- ansible-playbooks
---
<!-- wiki:breadcrumb:start -->
[Portal](../../../../library/portal/index.md) | **Level:** [L1: Foundations](../../../../library/portal/levels.md) | **Topics:** [Ansible](../../../../library/portal/topics.md) | **Domain:** DevOps & Tooling
<!-- wiki:breadcrumb:end -->

id	category	difficulty	tags	question	answer	source_path
ansible-playbooks/01c1c6ad937d	ansible-playbooks	medium	ansible, jinja	File '/tmp/exercise' includes the following content	"```\n- name: Change saiyans levels\n  lineinfile:\n    dest: /tmp/exercise\n    regexp: ""{{ item.regexp }}""\n    line: ""{{ item.line }}""\n  with_items:\n    - { regexp: '^Vegeta', line: 'Vegeta = 250' }\n    - { regexp: '^Trunks', line: 'Trunks = 40' }\n    ...\n```\n\nNote: with_items still works but `loop:` is preferred since Ansible 2.5.\n\nRemember: import_* = static (parsed at playbook load). include_* = dynamic (parsed at runtime). Use import for roles, include for conditional logic."	projects/knowledge/interview/ansible/021-file-tmpexercise-includes-the-following-content-go.txt
ansible-playbooks/0e33e3409f91	ansible-playbooks	medium	ansible, playbook, jinja, fact	Explain the concept of Ansible Facts in a Windows environment.	Ansible Facts in a Windows environment provide information about the target system, such as hardware details, IP addresses, and installed software. Ansible gathers these facts during playbook execution, and they can be used in tasks or templates.\n\nGotcha: YAML indentation matters in playbooks. Use 2-space indent consistently. A single wrong indent can change a task's behavior or cause a syntax error.	projects/knowledge/interview/ansible/082-explain-the-concept-of-ansible-facts-in-a-windows-.txt
ansible-playbooks/0e76d5c9ad8e	ansible-playbooks	medium	ansible, jinja	"The value of a certain variable you use is the string ""True"". You would like the value to be a boolean. How would you cast it?"	`{{ some_string_var | bool }}`\n\nUnder the hood: Jinja2's bool filter converts strings like 'True', 'yes', '1' to Python True, and 'False', 'no', '0' to False. Essential when variables come from external sources as strings.\n\nRemember: variable precedence (low to high): defaults, inventory, playbook, role vars, extra vars (-e). Extra vars always win.	projects/knowledge/interview/ansible/014-the-value-of-a-certain-variable-you-use-is-the-str.txt
ansible-playbooks/0ed0de9577a1	ansible-playbooks	easy	ansible, galaxy, roles	What is Ansible Galaxy?	Ansible Galaxy is a community repository for Ansible roles. It allows you to share and download roles written by others (via ansible-galaxy command).\n\nUnder the hood: Galaxy hosts both roles and collections (bundles of modules, roles, and plugins). Collections are the modern packaging format since Ansible 2.10+.\n\nExample: ansible-galaxy install geerlingguy.docker installs a community role. Use requirements.yml to pin versions for reproducible builds.	projects/knowledge/interview/ansible/144-what-is-ansible-galaxy.txt
ansible-playbooks/100a7ebffd10	ansible-playbooks	easy	ansible, role, testing	What is Molecule? How does it works?	It's used to rapidly develop and test Ansible roles.  Molecule can be used to test Ansible roles against a variety of Linux distros at the same time.  This testing ability helps instill confidence in the automation today and as time goes on while a role is maintained.\n\nGotcha: YAML indentation matters in playbooks. Use 2-space indent consistently. A single wrong indent can change a task's behavior or cause a syntax error.	projects/knowledge/interview/ansible/026-what-is-molecule-how-does-it-works.txt
ansible-playbooks/120b2e29ee6f	ansible-playbooks	medium	ansible, vault, playbook	How do you handle sensitive information like passwords in Ansible?	Sensitive information is managed using Ansible Vault to encrypt and secure data. Vault-encrypted files or strings can be included in playbooks, and passwords can be provided at runtime using various methods, such as prompting or external tools.\n\nGotcha: YAML indentation matters in playbooks. Use 2-space indent consistently. A single wrong indent can change a task's behavior or cause a syntax error.	projects/knowledge/interview/ansible/070-how-do-you-handle-sensitive-information-like-passw.txt
ansible-playbooks/12ad6298fa03	ansible-playbooks	medium	ansible, playbook, role	What is the purpose of an Ansible Playbook?	An Ansible Playbook is a YAML file containing organized instructions (plays) for configuring and managing systems. Playbooks define tasks, roles, and dependencies, providing a structured way to automate complex tasks.\n\nGotcha: YAML indentation matters in playbooks. Use 2-space indent consistently. A single wrong indent can change a task's behavior or cause a syntax error.	projects/knowledge/interview/ansible/035-what-is-the-purpose-of-an-ansible-playbook.txt
ansible-playbooks/144010e38bbe	ansible-playbooks	medium	ansible, fact, playbook	"What is the purpose of the ""gather_facts"" task in Ansible?"	The gather_facts task collects system information (facts) from managed nodes. Facts are then available as variables in the playbook. It is often used at the beginning of playbooks to gather information about the target environment.\n\nGotcha: YAML indentation matters in playbooks. Use 2-space indent consistently. A single wrong indent can change a task's behavior or cause a syntax error.	projects/knowledge/interview/ansible/046-what-is-the-purpose-of-the-gatherfacts-task-in-ans.txt
ansible-playbooks/1c8e64d1fea0	ansible-playbooks	medium	ansible, playbook, inventory, tower	How do you troubleshoot failed jobs in Ansible Tower?	Troubleshoot by:\n* Examining job details and logs in the Ansible Tower UI.\n* Reviewing playbook output for error messages.\n* Checking inventory, credentials, and playbooks for misconfigurations.\n* Analyzing job status and error codes.\n\nExample: assert: that: ansible_memtotal_mb >= 1024 fail_msg: 'Insufficient memory' — validates preconditions before proceeding with the playbook.	projects/knowledge/interview/ansible/107-how-do-you-troubleshoot-failed-jobs-in-ansible-tow.txt
ansible-playbooks/1dc608a4bcb9	ansible-playbooks	medium	ansible, connection, role, fact	Explain the role of the ansible_ssh_common_args variable in connection settings.	ansible_ssh_common_args is used to pass additional SSH connection parameters globally. It's helpful for setting common options like custom SSH keys or connection timeouts across multiple hosts.\n\nExample: setting ansible_ssh_common_args: '-o ProxyJump=bastion.example.com' routes all SSH through a bastion/jump host — useful for reaching private subnets.\n\nRemember: a role is a self-contained bundle: tasks/, handlers/, templates/, files/, defaults/, vars/, meta/. Think 'reusable Ansible package.'\n\nExample: ansible-galaxy init myrole scaffolds the directory structure. Share roles via Galaxy or private Git repos.	projects/knowledge/interview/ansible/097-explain-the-role-of-the-ansiblesshcommonargs-varia.txt
ansible-playbooks/2031d7b37867	ansible-playbooks	medium	ansible, playbook, role, idempotency	What are some best practices for writing clean and maintainable Ansible code?	Best practices include:\n* Organizing playbooks with clear structure and naming conventions.\n* Using roles to modularize and reuse code.\n* Documenting tasks and variables.\n* Employing version control.\n* Avoiding hardcoded values and using variables.\n* Ensuring idempotence in tasks.\n\nGotcha: YAML indentation matters in playbooks. Use 2-space indent consistently. A single wrong indent can change a task's behavior or cause a syntax error.	projects/knowledge/interview/ansible/069-what-are-some-best-practices-for-writing-clean-and.txt
ansible-playbooks/25ed2a52859f	ansible-playbooks	medium	ansible, role, jinja	Explain the use of Ansible roles in network automation.	Ansible roles in network automation help organize and modularize tasks. Roles can encapsulate configurations, templates, and tasks specific to network devices, making it easier to reuse and share automation code.\n\nRemember: a role is a self-contained bundle: tasks/, handlers/, templates/, files/, defaults/, vars/, meta/. Think 'reusable Ansible package.'\n\nExample: ansible-galaxy init myrole scaffolds the directory structure. Share roles via Galaxy or private Git repos.	projects/knowledge/interview/ansible/078-explain-the-use-of-ansible-roles-in-network-automa.txt
ansible-playbooks/25f5833d8969	ansible-playbooks	medium	handlers, notify, services	What are Ansible handlers and when should you use them?	Handlers are special tasks that only run when notified by other tasks.\nThey're typically used for actions that should happen once after multiple\nchanges, like restarting a service after config updates.\n\nHow they work:\n1. Tasks notify handlers when they make changes\n2. Handlers run at the end of the play (by default)\n3. Each handler runs only once, even if notified multiple times\n\nRemember: handlers run once at end of play, even if notified multiple times. Use meta: flush_handlers to force immediate execution.	projects/knowledge/interview/ansible/166-handlers.txt
ansible-playbooks/26d7d6522bb6	ansible-playbooks	medium	ansible, playbook	Explain the concept of Ansible Ad-Hoc commands.	Ad-Hoc commands are one-line commands used for quick tasks without creating playbooks. For example, ansible all -m ping checks connectivity to all nodes.\n\nExample: ansible all -m shell -a 'uptime' -b runs uptime as root on all hosts. Ad-hoc is for quick one-off tasks; use playbooks for repeatable workflows.\n\nGotcha: YAML indentation matters in playbooks. Use 2-space indent consistently. A single wrong indent can change a task's behavior or cause a syntax error.	projects/knowledge/interview/ansible/040-explain-the-concept-of-ansible-ad-hoc-commands.txt
ansible-playbooks/280fa3ca6b89	ansible-playbooks	medium	ansible, playbook, module, fact	What are some best practices for effective debugging and troubleshooting with Ansible?	Best practices include:\n* Using the debug module for variable inspection.\n* Enabling verbose mode with -vvv for detailed output.\n* Breaking down playbooks into smaller tasks for targeted debugging.\n* Leveraging Ansible facts for dynamic information.\n\nGotcha: YAML indentation matters in playbooks. Use 2-space indent consistently. A single wrong indent can change a task's behavior or cause a syntax error.	projects/knowledge/interview/ansible/113-what-are-some-best-practices-for-effective-debuggi.txt
ansible-playbooks/2d04aab4fb0c	ansible-playbooks	easy	ansible, yaml, playbooks	What language are Ansible playbooks written in?	YAML (Yet Another Markup Language), a human-readable data serialization format.\n\nFun fact: YAML stands for 'YAML Ain't Markup Language' (recursive acronym). It was chosen for readability over JSON or XML.\n\nGotcha: YAML is whitespace-sensitive. Mixing tabs and spaces causes parse errors. Convention is 2-space indentation.\n\nGotcha: YAML indentation matters in playbooks. Use 2-space indent consistently. A single wrong indent can change a task's behavior or cause a syntax error.	projects/knowledge/interview/ansible/134-playbook-language.txt
ansible-playbooks/30247ab2e8d0	ansible-playbooks	medium	ansible, playbook, tower	How do you install and configure Ansible Tower?	Ansible Tower is installed by following the installation guide provided by Red Hat. It involves downloading the installer, running the installation playbook, and configuring settings. Tower settings are configured using the web interface after installation.\n\nGotcha: YAML indentation matters in playbooks. Use 2-space indent consistently. A single wrong indent can change a task's behavior or cause a syntax error.	projects/knowledge/interview/ansible/066-how-do-you-install-and-configure-ansible-tower.txt
ansible-playbooks/32497e82d2b5	ansible-playbooks	easy	ansible, variables, commands	How do you pass variables to Ansible at runtime?	"You can use the -e flag (extra vars) on the command line, e.g., ansible-playbook play.yml -e ""var1=value1 var2=value2"".\n\nRemember: variable precedence (low to high): defaults, inventory, playbook, role vars, extra vars (-e). Extra vars always win."	projects/knowledge/interview/ansible/145-pass-variables-at-runtime.txt
ansible-playbooks/369289f637b7	ansible-playbooks	medium	ansible, idempotency, playbook	What kind of automation you wouldn't do with Ansible and why?	While it's possible to provision resources with Ansible, some prefer to use tools that follow immutable infrastructure paradigm.\nAnsible doesn't save state by default. So a task that creates 5 instances for example, when executed again will create additional 5 instances (unless\nadditional check is implemented or explicit names are provided) while other tools might check if 5 instances exist. If only 4 exist (by checking the state file for example), one additional instance will be created to reach the end goal of 5 instances.	projects/knowledge/interview/ansible/005-what-kind-of-automation-you-wouldnt-do-with-ansibl.txt
ansible-playbooks/3997d3fc13ee	ansible-playbooks	medium	ansible, role, galaxy	How do you use Ansible Galaxy to download and install roles?	Ansible Galaxy is used to share and download roles. To install a role from Galaxy, use the ansible-galaxy command:\n```bash\nansible-galaxy install author_name.role_name\n```\n\nExample: ansible-galaxy install geerlingguy.docker installs a community role. Use requirements.yml to pin versions for reproducible builds.	projects/knowledge/interview/ansible/050-how-do-you-use-ansible-galaxy-to-download-and-inst.txt
ansible-playbooks/39d812cbc578	ansible-playbooks	medium	ansible, playbook	Explain the purpose of the --diff option in Ansible playbooks.	The --diff option shows the differences between the current and desired state of files being managed by Ansible. It's useful for understanding changes made during playbook execution.\n\nGotcha: YAML indentation matters in playbooks. Use 2-space indent consistently. A single wrong indent can change a task's behavior or cause a syntax error.	projects/knowledge/interview/ansible/093-explain-the-purpose-of-the-diff-option-in-ansible-.txt
ansible-playbooks/3de4ce8836f4	ansible-playbooks	medium	ansible, playbook, role, handler	Explain the difference between Ansible Playbook and Ansible Role.	An Ansible Playbook is a collection of plays, each specifying tasks to execute. A role, on the other hand, is a reusable and shareable collection of variables, tasks, handlers, and other Ansible artifacts, organized in a predefined directory structure.\n\nRemember: a role is a self-contained bundle: tasks/, handlers/, templates/, files/, defaults/, vars/, meta/. Think 'reusable Ansible package.'\n\nExample: ansible-galaxy init myrole scaffolds the directory structure. Share roles via Galaxy or private Git repos.	projects/knowledge/interview/ansible/036-explain-the-difference-between-ansible-playbook-an.txt
ansible-playbooks/3f9d1510146e	ansible-playbooks	medium	ansible, handler	Explain Ansible Handlers and their use.	Handlers are tasks that only run when notified by other tasks. They are often used to restart services or perform specific actions triggered by changes. Handlers are defined in the handlers section and notified using the notify directive.\n\nRemember: handlers run once at end of play, even if notified multiple times. Use meta: flush_handlers to force immediate execution.	projects/knowledge/interview/ansible/048-explain-ansible-handlers-and-their-use.txt
ansible-playbooks/421db7344cf1	ansible-playbooks	medium	ansible, jinja	When the value '2017'' will be used in this case: `{{ lookup('env', 'BEST_YEAR') | default('2017', true) }}`?	when the environment variable 'BEST_YEAR' is empty or false.\n\nExample: lookup('file', '/path/to/file') reads a file. lookup('env', 'HOME') reads an environment variable. lookup('pipe', 'date') runs a command. Lookups execute on the control node.	projects/knowledge/interview/ansible/012-when-the-value-2017-will-be-used-in-this-case-look.txt
ansible-playbooks/4b0a5284b97f	ansible-playbooks	medium	ansible, playbook, inventory	"Explain the use of the ""ec2.py"" script for AWS dynamic inventory."	"The ""ec2.py"" script is a dynamic inventory script for AWS in Ansible. It queries AWS API to dynamically generate inventory information, including EC2 instances and their attributes. It enables dynamic and automatic inclusion of AWS resources in Ansible playbooks.\n\nGotcha: YAML indentation matters in playbooks. Use 2-space indent consistently. A single wrong indent can change a task's behavior or cause a syntax error."	projects/knowledge/interview/ansible/064-explain-the-use-of-the-ec2py-script-for-aws-dynami.txt
ansible-playbooks/4c18ecc54dfb	ansible-playbooks	medium	ansible, playbook, jinja, tower	What is Ansible Tower Surveys, and how do they work?	Ansible Tower Surveys are forms that prompt users for input when launching job templates. They allow dynamic input, making playbook runs customizable. Users provide values for survey questions, influencing the behavior of the playbook.\n\nGotcha: YAML indentation matters in playbooks. Use 2-space indent consistently. A single wrong indent can change a task's behavior or cause a syntax error.	projects/knowledge/interview/ansible/083-what-is-ansible-tower-surveys-and-how-do-they-work.txt
ansible-playbooks/4ecddffb671e	ansible-playbooks	medium	ansible, playbook, role	How do you approach debugging in a large-scale Ansible environment?	Approach debugging in a large-scale environment by:\n* Utilizing centralized logging for aggregated information.\n* Implementing consistent playbook and role structures.\n* Employing version control for playbooks.\n* Ensuring proper documentation for team collaboration.\n\nGotcha: YAML indentation matters in playbooks. Use 2-space indent consistently. A single wrong indent can change a task's behavior or cause a syntax error.	projects/knowledge/interview/ansible/114-how-do-you-approach-debugging-in-a-large-scale-ans.txt
ansible-playbooks/50aa2c107d3d	ansible-playbooks	medium	ansible, playbook, module, connection	How does Ansible differ from other configuration management tools?	Ansible is agentless, relying on SSH for communication, making it easy to deploy. It uses YAML for human-readable playbooks, emphasizing simplicity. Ansible also supports multi-tier orchestration and provides a large collection of modules.\n\nGotcha: YAML indentation matters in playbooks. Use 2-space indent consistently. A single wrong indent can change a task's behavior or cause a syntax error.	projects/knowledge/interview/ansible/031-how-does-ansible-differ-from-other-configuration-m.txt
ansible-playbooks/567cd532096a	ansible-playbooks	medium	ansible, testing, playbook	Explain how to use the --check option for running Ansible in check mode.	The --check option runs Ansible in check mode, simulating playbook execution without making changes. It's used to preview potential changes and identify issues without impacting the target systems.\n\nExample: ansible-playbook site.yml --check --diff shows what WOULD change without actually changing anything. Perfect for pre-deployment review.	projects/knowledge/interview/ansible/090-explain-how-to-use-the-check-option-for-running-an.txt
ansible-playbooks/57ef41452295	ansible-playbooks	medium	ansible, playbook, jinja	How do you define variables in Ansible Playbooks?	Variables in Ansible Playbooks can be defined in various ways, including:\n* Inline: {{ variable_name }} within tasks.\n* In a separate YAML file and included using vars_files.\n* In the vars section of a playbook.\n\nRemember: variable precedence (low to high): defaults, inventory, playbook, role vars, extra vars (-e). Extra vars always win.	projects/knowledge/interview/ansible/043-how-do-you-define-variables-in-ansible-playbooks.txt
ansible-playbooks/59ae44b9473c	ansible-playbooks	medium	ansible, role, handler	Explain the difference between tasks, handlers, and defaults in an Ansible Role.	* Tasks: Contain the main work to be done. Defined in the tasks directory.\n* Handlers: Define actions to be taken based on notifications. Defined in the handlers directory.\n* Defaults: Contain default variables for the role. Defined in the defaults directory.\n\nRemember: a role is a self-contained bundle: tasks/, handlers/, templates/, files/, defaults/, vars/, meta/. Think 'reusable Ansible package.'\n\nExample: ansible-galaxy init myrole scaffolds the directory structure. Share roles via Galaxy or private Git repos.	projects/knowledge/interview/ansible/051-explain-the-difference-between-tasks-handlers-and-.txt
ansible-playbooks/5e054ce4e3de	ansible-playbooks	easy	playbooks, roles, organization	What is the difference between an Ansible playbook and a role?	A playbook is a YAML file that defines automation tasks to run on hosts.\nA role is a structured way to organize and reuse playbook content.\n\nPlaybook:\n- Entry point for Ansible execution\n- Defines which hosts to target\n- Contains plays with tasks, handlers, variables\n- Can be a single file or include others\n\nRole:\n- Standardized directory structure\n- Reusable, self-contained automation unit\n- Automatically loads files from specific directories\n- Can be shared via Ansible Galaxy\n\nRemember: a role is a self-contained bundle: tasks/, handlers/, templates/, files/, defaults/, vars/, meta/. Think 'reusable Ansible package.'\n\nExample: ansible-galaxy init myrole scaffolds the directory structure. Share roles via Galaxy or private Git repos.	projects/knowledge/interview/ansible/164-playbook-vs-role.txt
ansible-playbooks/6789c88ad3e8	ansible-playbooks	medium	ansible, playbook	How do you run only a specific part of a playbook?	"Use the --tags and --skip-tags options with the ansible-playbook command. \nFor example:\n* Run specific tags: ansible-playbook playbook.yml --tags ""tag_name""\n* Skip specific tags: ansible-playbook playbook.yml --skip-tags ""tag_name""\n\nGotcha: YAML indentation matters in playbooks. Use 2-space indent consistently. A single wrong indent can change a task's behavior or cause a syntax error."	projects/knowledge/interview/ansible/045-how-do-you-run-only-a-specific-part-of-a-playbook.txt
ansible-playbooks/67b8ccfffdf0	ansible-playbooks	medium	ansible, role, module	How do you set breakpoints or pause execution within an Ansible role for debugging?	Use the pause module to set breakpoints within roles. Example:\n```yaml\n- name: Pause for debugging\n  pause:\n    minutes: 30\n```\n\nRemember: Ansible playbooks should be idempotent — running them twice produces the same result. Use modules (not shell/command) to ensure this.\n\nGotcha: always test playbooks with --check --diff before applying. This shows what WOULD change without actually changing anything.	projects/knowledge/interview/ansible/101-how-do-you-set-breakpoints-or-pause-execution-with.txt
ansible-playbooks/6afb353afc4f	ansible-playbooks	medium	ansible, role, module, playbook	Describe each of the following components in Ansible, including the relationship between them:	Task – a call to a specific Ansible module\nModule – the actual unit of code executed by Ansible on your own host or a remote host. Modules are indexed by category (database, file, network, …) and also referred to as task plugins.\n    \nInventory – An inventory file defines hosts and/or groups of hosts on which Ansible tasks executed upon. The inventory file can be in one of many formats, depending on the inventory plugins you have. The most common formats are INI and YAML.\n\nPlay – One or more tasks executed on a given host(s)	projects/knowledge/interview/ansible/001-describe-each-of-the-following-components-in-ansib.txt
ansible-playbooks/6d62ffa73c9b	ansible-playbooks	medium	ansible, playbook, testing	What information is available in the output when using the --check option?	The output includes information about tasks that would be changed, added, or removed if the playbook were run normally. It helps identify what actions Ansible would take without actually applying them.\n\nGotcha: YAML indentation matters in playbooks. Use 2-space indent consistently. A single wrong indent can change a task's behavior or cause a syntax error.	projects/knowledge/interview/ansible/091-what-information-is-available-in-the-output-when-u.txt
ansible-playbooks/7701827d8954	ansible-playbooks	medium	ansible, playbook, idempotency, testing	What are some common pitfalls in Ansible, and how can they be avoided?	Common pitfalls include unhandled errors, inefficient playbook structures, and lack of idempotence. They can be avoided by:\n* Proper error handling.\n* Structuring playbooks for clarity.\n* Ensuring tasks are idempotent.\n* Regularly testing playbooks in non-production environments.\n\nGotcha: YAML indentation matters in playbooks. Use 2-space indent consistently. A single wrong indent can change a task's behavior or cause a syntax error.	projects/knowledge/interview/ansible/076-what-are-some-common-pitfalls-in-ansible-and-how-c.txt
ansible-playbooks/79e159e44599	ansible-playbooks	medium	ansible, playbook	How do you use the --list-tasks option to view tasks in an execution plan?	The --list-tasks option displays a list of tasks without executing them. Example:\n```bash\nansible-playbook playbook.yml --list-tasks\n```\n\nGotcha: combine --list-tasks with --tags to see which tasks would run with your tag filter, without executing anything. Great for verifying tag coverage before running on production.\n\nGotcha: YAML indentation matters in playbooks. Use 2-space indent consistently. A single wrong indent can change a task's behavior or cause a syntax error.	projects/knowledge/interview/ansible/095-how-do-you-use-the-list-tasks-option-to-view-tasks.txt
ansible-playbooks/7b5b2f01e166	ansible-playbooks	medium	ansible, module, jinja	"What is the ""template"" module used for?"	The template module is used to copy template files to remote nodes. It allows the use of variables and conditionals in files, making it useful for generating configuration files dynamically.\n\nExample: {{ ansible_hostname }}-{{ ansible_date_time.date }}.log renders to 'web01-2026-03-21.log'. Jinja2 supports filters: {{ name | upper }}.\n\nGotcha: always quote Jinja2 expressions in YAML: name: '{{ var }}' — unquoted {{ can break YAML parsing.	projects/knowledge/interview/ansible/057-what-is-the-template-module-used-for.txt
ansible-playbooks/8902247994b6	ansible-playbooks	medium	ansible, playbook	"Explain the use of the ""hosts"" directive in a playbook."	"The hosts directive in a playbook specifies the target hosts or groups where the playbook tasks should be executed. It can be a single host, a group of hosts, or the special group ""all"" for all hosts.\n\nGotcha: YAML indentation matters in playbooks. Use 2-space indent consistently. A single wrong indent can change a task's behavior or cause a syntax error."	projects/knowledge/interview/ansible/044-explain-the-use-of-the-hosts-directive-in-a-playbo.txt
ansible-playbooks/8af5054f70a4	ansible-playbooks	medium	ansible, fact, jinja	What would be the result of the following play?	"```\n---\n- name: Print information about my host\n  hosts: localhost\n  gather_facts: 'no'\n  tasks:\n      - name: Print hostname\n        debug:\n            msg: ""It's me, {{ ansible_hostname }}""\n```\n\nWhen given a written code, always inspect it thoroughly. If your answer is “this will fail” then you are right. We are using a fact (ansible_hostname), which is a gathered piece of information from the host we are running on. But in this case, we disabled facts gathering (gather_facts: no) so the variable would be undefined which will result in failure."	projects/knowledge/interview/ansible/011-what-would-be-the-result-of-the-following-play.txt
ansible-playbooks/8cf3b35e826d	ansible-playbooks	medium	ansible, playbook, role, tower	Explain the role of Ansible Tower in a CI/CD pipeline.	Ansible Tower plays a crucial role in CI/CD by providing a centralized platform for orchestrating and managing automation tasks. It integrates with version control systems, triggers playbooks based on events, and allows for the creation of workflows that automate deployment and testing processes.\n\nRemember: a role is a self-contained bundle: tasks/, handlers/, templates/, files/, defaults/, vars/, meta/. Think 'reusable Ansible package.'\n\nExample: ansible-galaxy init myrole scaffolds the directory structure. Share roles via Galaxy or private Git repos.	projects/knowledge/interview/ansible/067-explain-the-role-of-ansible-tower-in-a-cicd-pipeli.txt
ansible-playbooks/948193c2f9e5	ansible-playbooks	medium	ansible, role, jinja, handler	What is an Ansible Role, and how is it structured?	An Ansible Role is a collection of tasks, variables, templates, and other Ansible artifacts organized in a predefined directory structure. The structure typically includes directories like tasks, handlers, templates, and defaults.\n\nRemember: a role is a self-contained bundle: tasks/, handlers/, templates/, files/, defaults/, vars/, meta/. Think 'reusable Ansible package.'\n\nExample: ansible-galaxy init myrole scaffolds the directory structure. Share roles via Galaxy or private Git repos.	projects/knowledge/interview/ansible/049-what-is-an-ansible-role-and-how-is-it-structured.txt
ansible-playbooks/95798472fd71	ansible-playbooks	medium	ansible, playbook	How can you use the --limit option to limit playbook execution to specific hosts for debugging?	The --limit option restricts playbook execution to specific hosts. Example:\n```bash\nansible-playbook playbook.yml --limit=hostname\n```\n\nGotcha: --limit accepts patterns: --limit 'web*' targets hosts matching the glob. Combine with --list-hosts to verify which hosts match before running.\n\nGotcha: YAML indentation matters in playbooks. Use 2-space indent consistently. A single wrong indent can change a task's behavior or cause a syntax error.	projects/knowledge/interview/ansible/104-how-can-you-use-the-limit-option-to-limit-playbook.txt
ansible-playbooks/967a79551e1c	ansible-playbooks	medium	ansible, playbook, jinja	How to find out the data type of a certain variable in one of the playbooks?	{{ some_var | type_debug }}\n\nUnder the hood: type_debug outputs the Python type name (str, int, list, dict, etc.). Invaluable for debugging when a variable is unexpectedly a string instead of a list or integer.\n\nRemember: variable precedence (low to high): defaults, inventory, playbook, role vars, extra vars (-e). Extra vars always win.	projects/knowledge/interview/ansible/027-how-to-find-out-the-data-type-of-a-certain-variabl.txt
ansible-playbooks/97bdd6cababb	ansible-playbooks	medium	ansible, jinja	"If the value of certain variable is 1, you would like to use the value ""one"", otherwise, use ""two"". How would you do it?"	"`{{ (certain_variable == 1) | ternary(""one"", ""two"") }}`\n\nUnder the hood: ternary is a Jinja2 filter that acts like a C-style ternary operator: condition | ternary(true_val, false_val). Useful for concise conditional assignments in templates.\n\nRemember: variable precedence (low to high): defaults, inventory, playbook, role vars, extra vars (-e). Extra vars always win."	projects/knowledge/interview/ansible/013-if-the-value-of-certain-variable-is-1-you-would-li.txt
ansible-playbooks/99fc4381c76f	ansible-playbooks	medium	ansible, playbook, idempotency	True or False? Ansible uses declarative style to describe the expected end state	False. It uses a procedural style.\n\nUnder the hood: tasks execute top-to-bottom (procedural), unlike Terraform which builds a dependency graph (declarative). Individual modules like apt with state=present behave declaratively.\n\nGotcha: YAML indentation matters in playbooks. Use 2-space indent consistently. A single wrong indent can change a task's behavior or cause a syntax error.	projects/knowledge/interview/ansible/004-true-or-false-ansible-uses-declarative-style-to-de.txt
ansible-playbooks/9f00260424b2	ansible-playbooks	medium	ansible, playbook	How do you enable verbose mode for Ansible playbooks?	Verbose mode for Ansible playbooks can be enabled using the -v, -vv, or -vvv options with the ansible-playbook command. It increases the verbosity of output, providing more details during playbook execution.\n\nGotcha: YAML indentation matters in playbooks. Use 2-space indent consistently. A single wrong indent can change a task's behavior or cause a syntax error.	projects/knowledge/interview/ansible/084-how-do-you-enable-verbose-mode-for-ansible-playboo.txt
ansible-playbooks/a180f292def6	ansible-playbooks	medium	ansible, role	What steps would you take to debug an issue within an Ansible role?	Steps include:\n* Adding debug tasks to print variable values.\n* Using the --start-at-task option to isolate problematic tasks.\n* Setting breakpoints with pause or fail for interactive debugging.\n\nRemember: a role is a self-contained bundle: tasks/, handlers/, templates/, files/, defaults/, vars/, meta/. Think 'reusable Ansible package.'\n\nExample: ansible-galaxy init myrole scaffolds the directory structure. Share roles via Galaxy or private Git repos.	projects/knowledge/interview/ansible/100-what-steps-would-you-take-to-debug-an-issue-within.txt
ansible-playbooks/a2094b8b8d57	ansible-playbooks	medium	ansible, testing, playbook	How do you perform a dry run of an Ansible playbook to see what changes would be made?	Use the --check option for a dry run. Example:\n```bash\nansible-playbook playbook.yml --check\n```\n\nGotcha: --check (dry run) does not guarantee accuracy — modules that depend on previous task results may report incorrect changes. Use it as a sanity check, not a guarantee.\n\nExample: ansible-playbook site.yml --check --diff shows what WOULD change without actually changing anything. Perfect for pre-deployment review.	projects/knowledge/interview/ansible/092-how-do-you-perform-a-dry-run-of-an-ansible-playboo.txt
ansible-playbooks/aae7ab6ade64	ansible-playbooks	medium	ansible, idempotency, playbook	True or False? Ansible follows the mutable infrastructure paradigm	"True. In immutable infrastructure approach, you'll replace infrastructure instead of modifying it. \nAnsible rather follows the mutable infrastructure paradigm where it allows you to change the configuration of different components, but this approach is not perfect and has its own disadvantages like ""configuration drift"" where different components may reach different state for different reasons.\n\nGotcha: YAML indentation matters in playbooks. Use 2-space indent consistently. A single wrong indent can change a task's behavior or cause a syntax error."	projects/knowledge/interview/ansible/003-true-or-false-ansible-follows-the-mutable-infrastr.txt
ansible-playbooks/ad6c2725650d	ansible-playbooks	medium	ansible, best-practices, roles	How do you structure a good playbook or role?	Small, predictable roles. Defaults for variables, handlers for restarts, and clear separation of tasks, files, and templates. Idempotency first. Fail fast with clear messages. Reusability over cleverness.\n\nGotcha: YAML indentation matters in playbooks. Use 2-space indent consistently. A single wrong indent can change a task's behavior or cause a syntax error.	projects/knowledge/interview/ansible/130-how-do-you-structure-a-good-playbook-or-role.txt
ansible-playbooks/b2b836623f6c	ansible-playbooks	medium	ansible, playbook	What is the syntax for an Ansible Playbook?	Ansible Playbooks use YAML syntax. Example:\n```yaml\n---\n- name: Install and start Apache\n  hosts: webserver\n  tasks:\n    - name: Install Apache\n      yum:\n        name: httpd\n        state: present\n    - name: Start Apache\n      service:\n        name: httpd\n        state: started\n```\n\nGotcha: YAML indentation matters in playbooks. Use 2-space indent consistently. A single wrong indent can change a task's behavior or cause a syntax error.	projects/knowledge/interview/ansible/042-what-is-the-syntax-for-an-ansible-playbook.txt
ansible-playbooks/b323be08f5ac	ansible-playbooks	medium	ansible, playbook, role, fact	Explain the role of Ansible Facts in playbooks and how to debug them.	Ansible Facts provide information about target systems. Debug them by printing facts with debug tasks or using the -vvv option for increased verbosity.\n\nRemember: a role is a self-contained bundle: tasks/, handlers/, templates/, files/, defaults/, vars/, meta/. Think 'reusable Ansible package.'\n\nExample: ansible-galaxy init myrole scaffolds the directory structure. Share roles via Galaxy or private Git repos.	projects/knowledge/interview/ansible/102-explain-the-role-of-ansible-facts-in-playbooks-and.txt
ansible-playbooks/b47b1b074fc5	ansible-playbooks	medium	ansible, playbook, module	How can you print debug messages within an Ansible playbook?	"Use the debug module within Ansible playbooks to print debug messages. Example:\n```\n- name: Print debug message\n  debug:\n    msg: ""This is a debug message.""\n```\n\nGotcha: YAML indentation matters in playbooks. Use 2-space indent consistently. A single wrong indent can change a task's behavior or cause a syntax error."	projects/knowledge/interview/ansible/086-how-can-you-print-debug-messages-within-an-ansible.txt
ansible-playbooks/b94ae9786a96	ansible-playbooks	medium	ansible, playbook	Explain the importance of version control with Ansible playbooks.	Version control is crucial for tracking changes, collaborating with teams, and ensuring reproducibility. It allows rollbacks to previous versions, collaboration among team members, and proper management of code changes over time.\n\nRemember: import_* = static (parsed at playbook load). include_* = dynamic (parsed at runtime). Use import for roles, include for conditional logic.	projects/knowledge/interview/ansible/071-explain-the-importance-of-version-control-with-ans.txt
ansible-playbooks/b96fd5c4f40c	ansible-playbooks	medium	ansible, playbook, module	How do you print the values of variables in Ansible playbooks for debugging purposes?	Use the debug module to print variable values. Example:\n```yaml\n- name: Print variable value\n  debug:\n    var: variable_name\n```\n\nRemember: variable precedence (low to high): defaults, inventory, playbook, role vars, extra vars (-e). Extra vars always win.	projects/knowledge/interview/ansible/103-how-do-you-print-the-values-of-variables-in-ansibl.txt
ansible-playbooks/be246378c058	ansible-playbooks	medium	ansible, playbook, testing	How can you run a specific task or play within an Ansible playbook for testing?	Use tags to run specific tasks or plays. Example:\n```bash\nansible-playbook playbook.yml --tags=tag_name\n```\n\nGotcha: if a task's tag is not explicitly listed in --tags, it is skipped entirely. Use the special 'always' tag for tasks that must execute regardless of filtering.\n\nGotcha: YAML indentation matters in playbooks. Use 2-space indent consistently. A single wrong indent can change a task's behavior or cause a syntax error.	projects/knowledge/interview/ansible/089-how-can-you-run-a-specific-task-or-play-within-an-.txt
ansible-playbooks/c4ec515ed548	ansible-playbooks	easy	ansible, templates	"What are Ansible ""templates""?"	Files using Jinja2 syntax to generate dynamic configurations.\n\nExample: {{ ansible_hostname }}-{{ ansible_date_time.date }}.log renders to 'web01-2026-03-21.log'. Jinja2 supports filters: {{ name | upper }}.\n\nGotcha: always quote Jinja2 expressions in YAML: name: '{{ var }}' — unquoted {{ can break YAML parsing.	projects/knowledge/interview/ansible/143-ansible-templates.txt
ansible-playbooks/cc5a4473f4b7	ansible-playbooks	medium	ansible, playbook	What steps would you take to troubleshoot a playbook that fails during execution?	Troubleshooting a playbook involves:\n* Reviewing error messages.\n* Verifying playbook syntax.\n* Checking variable values using debug.\n* Running the playbook with increased verbosity (-vvv).\n* Isolating failing tasks for focused analysis.\n\nExample: assert: that: ansible_memtotal_mb >= 1024 fail_msg: 'Insufficient memory' — validates preconditions before proceeding with the playbook.	projects/knowledge/interview/ansible/088-what-steps-would-you-take-to-troubleshoot-a-playbo.txt
ansible-playbooks/cf34a2fae4f5	ansible-playbooks	medium	ansible, playbook	How do you enable verbose mode in Ansible for debugging?	Verbose mode can be enabled by using the -v, -vv, or -vvv options with the ansible or ansible-playbook command. It provides additional output for debugging purposes, with increasing levels of verbosity.\n\nGotcha: YAML indentation matters in playbooks. Use 2-space indent consistently. A single wrong indent can change a task's behavior or cause a syntax error.	projects/knowledge/interview/ansible/074-how-do-you-enable-verbose-mode-in-ansible-for-debu.txt
ansible-playbooks/cff3750e3358	ansible-playbooks	medium	ansible, module, role	What are collections in Ansible?	Ansible Collections are a way to package and distribute modules, roles, plugins, and documentation in a structured format. They help organize and distribute automation code efficiently, especially for complex environments.\n\nGotcha: YAML indentation matters in playbooks. Use 2-space indent consistently. A single wrong indent can change a task's behavior or cause a syntax error.	projects/knowledge/interview/ansible/028-what-are-collections-in-ansible.txt
ansible-playbooks/d29797c20876	ansible-playbooks	medium	ansible, roles, reusability	What is an Ansible role?	"A role is a structured collection of tasks, files, templates, and variables, organized in a standard directory structure, designed for reusability. Roles allow you to break playbooks into reusable components (e.g., a ""webserver"" role).\n\nRemember: a role is a self-contained bundle: tasks/, handlers/, templates/, files/, defaults/, vars/, meta/. Think 'reusable Ansible package.'\n\nExample: ansible-galaxy init myrole scaffolds the directory structure. Share roles via Galaxy or private Git repos."	projects/knowledge/interview/ansible/137-what-is-role.txt
ansible-playbooks/d3ac6b755e39	ansible-playbooks	medium	ansible, playbook, module	What is Ansible and how does it differ from other config management tools?	Ansible is an open-source automation tool used for configuration management, application deployment, task automation, and orchestration. It simplifies complex infrastructure tasks, enabling efficient management of IT environments.\n\nGotcha: YAML indentation matters in playbooks. Use 2-space indent consistently. A single wrong indent can change a task's behavior or cause a syntax error.	projects/knowledge/interview/ansible/030-what-is-ansible.txt
ansible-playbooks/d40bfcf8c827	ansible-playbooks	medium	ansible, jinja, playbook, fact	Write a playbook to deploy the file ‘/tmp/system_info’ on all hosts except for controllers group, with the following content	```\n  I'm <HOSTNAME> and my operating system is <OS>\n  ```\n\n  Replace <HOSTNAME> and  <OS> with the actual data for the specific host you are running on\n\nThe playbook to deploy the system_info file\n\n```\n---\n- name: Deploy /tmp/system_info file\n  hosts: all:!controllers\n  tasks:\n      - name: Deploy /tmp/system_info\n        template:\n            src: system_info.j2\n            dest: /tmp/system_info\n```\n\nThe content of the system_info.j2 template\n\n```\n# {{ ansible_managed }}\nI'm {{ ansible_hostname }} and my operating system is {{ ansible_distribution }\n```\n\nGotcha: YAML indentation matters in playbooks. Use 2-space indent consistently. A single wrong indent can change a task's behavior or cause a syntax error.	projects/knowledge/interview/ansible/017-write-a-playbook-to-deploy-the-file-tmpsysteminfo-.txt
ansible-playbooks/d5e93b5bfe06	ansible-playbooks	medium	ansible, jinja	"Modify the following task to use a variable instead of the value ""zlib"" and have ""zlib"" as the default in case the variable is not defined"	"```\n- name: Install a package\n  package:\n    name: ""{{ package_name|default('zlib') }}""\n    state: present\n```\n\nRemember: variable precedence (low to high): defaults, inventory, playbook, role vars, extra vars (-e). Extra vars always win."	projects/knowledge/interview/ansible/009-modify-the-following-task-to-use-a-variable-instea.txt
ansible-playbooks/d666a0dea43d	ansible-playbooks	medium	ansible, jinja, playbook	Write a filter to capitalize a string	```\ndef cap(self, string):\n    return string.capitalize()\n```\n\nUnder the hood: custom Jinja2 filters are Python functions placed in a filter_plugins/ directory alongside your playbook. Ansible auto-discovers them at runtime.\n\nRemember: useful Jinja2 filters: default('fallback'), join(','), replace('old','new'), regex_replace, to_yaml, to_json, combine (merge dicts). Filters chain: {{ var | lower | trim }}.	projects/knowledge/interview/ansible/020-write-a-filter-to-capitalize-a-string.txt
ansible-playbooks/dcbd32c08ed0	ansible-playbooks	medium	ansible, playbook, lint	What steps would you take to troubleshoot a failed Ansible playbook?	Steps include:\n* Examining playbook output for error messages.\n* Reviewing log files on target hosts.\n* Enabling verbose mode (-vvv) for detailed information.\n* Validating syntax using ansible-playbook --syntax-check.\n* Checking variable values and data.\n\nExample: assert: that: ansible_memtotal_mb >= 1024 fail_msg: 'Insufficient memory' — validates preconditions before proceeding with the playbook.	projects/knowledge/interview/ansible/073-what-steps-would-you-take-to-troubleshoot-a-failed.txt
ansible-playbooks/dd02693db757	ansible-playbooks	medium	ansible, playbook	What is an Ansible playbook execution plan, and how can you generate it?	An execution plan provides a summary of tasks that would be executed. Generate it using the --list-tasks option. Example:\n```bash\nansible-playbook playbook.yml --list-tasks\n```\n\nGotcha: combine --list-tasks with --tags to see which tasks would run with your tag filter, without executing anything. Great for verifying tag coverage before running on production.\n\nGotcha: YAML indentation matters in playbooks. Use 2-space indent consistently. A single wrong indent can change a task's behavior or cause a syntax error.	projects/knowledge/interview/ansible/094-what-is-an-ansible-playbook-execution-plan-and-how.txt
ansible-playbooks/dd139cfd4072	ansible-playbooks	medium	ansible, playbook, jinja, become	Write a playbook to install ‘zlib’ and ‘vim’ on all hosts if the file ‘/tmp/mario’ exists on the system.	"```\n---\n- hosts: all\n  vars:\n      mario_file: /tmp/mario\n      package_list:\n          - 'zlib'\n          - 'vim'\n  tasks:\n      - name: Check for mario file\n        stat:\n            path: ""{{ mario_file }}""\n        register: mario_f\n\n      - name: Install zlib and vim if mario file exists\n        become: ""yes""\n        package:\n            name: ""{{ item }}""\n            state: present\n        with_items: ""{{ package_list }}""\n        when: mario_f.stat.exists\n```\n\nNote: with_items still works but `loop:` is preferred since Ansible 2.5.\n\nGotcha: YAML indentation matters in playbooks. Use 2-space indent consistently. A single wrong indent can change a task's behavior or cause a syntax error."	projects/knowledge/interview/ansible/015-write-a-playbook-to-install-zlib-and-vim-on-all-ho.txt
ansible-playbooks/def304ec2266	ansible-playbooks	medium	ansible, role, testing, module	What makes good Ansible?	"Good Ansible code follows these principles:\n\n**Idempotent**: Running twice produces same result as running once. No ""changed"" on second run if state is correct.\n\n**Readable**: Clear task names, organized variables, logical role structure. Future you (or your team) must understand it.\n\n**Minimal conditionals**: If you have `when:` everywhere, your inventory structure is probably wrong.\n\n**Clear variables**: Good naming, appropriate scope (group_vars vs host_vars), documented defaults.\n\n**No shell unless necessary**: Shell/command modules break idempotence. Use proper modules first.\n\n**Tested**: Syntax checks, dry-runs, molecule tests for roles.\n\nBad Ansible is just scripting with extra steps."	projects/knowledge/interview/ansible/129-what-makes-good-ansible.txt
ansible-playbooks/e0ad8c1f129d	ansible-playbooks	medium	ansible, jinja	"How to make the variable ""use_var"" optional?"	"With ""default(omit)""\n```\n- name: Install a package\n  package:\n    name: ""zlib""\n    state: present\n    use: ""{{ use_var|default(omit) }}""\n```\n\nRemember: variable precedence (low to high): defaults, inventory, playbook, role vars, extra vars (-e). Extra vars always win."	projects/knowledge/interview/ansible/010-how-to-make-the-variable-usevar-optional-name-inst.txt
ansible-playbooks/e0b6eb6c3115	ansible-playbooks	medium	ansible, playbook	What is Ansible Container, and how does it integrate with Docker?	Ansible Container is an extension for managing containerized applications using Ansible. It allows defining container specifications in Ansible playbooks. Integration with Docker involves using Ansible to define Docker container configurations, build images, and deploy containers.\n\nGotcha: YAML indentation matters in playbooks. Use 2-space indent consistently. A single wrong indent can change a task's behavior or cause a syntax error.	projects/knowledge/interview/ansible/080-what-is-ansible-container-and-how-does-it-integrat.txt
ansible-playbooks/e253ecdc94bc	ansible-playbooks	medium	ansible, testing, lint, playbook	How do you test Ansible safely?	Multiple layers of safety:\n\n**Syntax and lint**:\n```bash\nansible-playbook --syntax-check playbook.yml\nansible-lint playbook.yml\n```\n\n**Dry-run (check mode)**:\n```bash\nansible-playbook --check --diff playbook.yml\n```\nShows what WOULD change without doing it.\n\n**Target safely**:\n* Non-prod environments first\n* Small batches: `--limit 'web[0:2]'`\n* Serial execution for risky changes: `serial: 1`\n\n**Role testing with Molecule**:\n```bash\nmolecule test\n```\nSpins up containers, applies role, runs verification.\n\n**Canary deployments**: Run on one host, verify, then expand.\n\nGotcha: YAML indentation matters in playbooks. Use 2-space indent consistently. A single wrong indent can change a task's behavior or cause a syntax error.	projects/knowledge/interview/ansible/132-how-do-you-test-ansible-safely.txt
ansible-playbooks/e80a0e1cd238	ansible-playbooks	medium	ansible, strategy, playbook	Explain the Difference between Forks and Serial & Throttle.	`Serial` is like running the playbook for each host in turn, waiting for completion of the complete playbook before moving on to the next host. `forks`=1 means run the first task in a play on one host before running the same task on the next host, so the first task will be run for each host before the next task is touched. Default fork is 5 in ansible.\n\n```\n[defaults]\nforks = 30\n```\n\n```\n- hosts: webservers\n  serial: 1\n  tasks:\n    - name: ...\n```\n\nAnsible also supports `throttle` This keyword limits the number of workers up to the maximum set via the forks setting or serial. This can be useful in restricting tasks that may be CPU-intensive or interact with a rate-limiting API\n\n```\ntasks:\n- command: /path/to/cpu_intensive_command\n  throttle: 1\n```	projects/knowledge/interview/ansible/019-explain-the-difference-between-forks-and-serial-th.txt
ansible-playbooks/e853abcb2087	ansible-playbooks	medium	ansible, playbook, role, inventory	The variable 'whoami' defined in the following places:	The answer is 'toad'. Ansible variable precedence (lowest to highest, simplified):\n\n1. Role defaults\n2. Inventory vars (group_vars, host_vars)\n3. Play vars, vars_files, vars_prompt\n4. Task vars, block vars\n5. Role params\n6. set_fact / registered vars\n7. Extra vars (-e on CLI) — always win\n\nRule of thumb: More specific scope beats less specific. CLI extra vars override everything.\n\nRemember: variable precedence (low to high): defaults, inventory, playbook, role vars, extra vars (-e). Extra vars always win.	projects/knowledge/interview/ansible/018-the-variable-whoami-defined-in-the-following-place.txt
ansible-playbooks/ea31d7ac27fb	ansible-playbooks	medium	ansible, strategy, playbook, fact	How can you optimize Ansible playbooks for performance?	Performance optimization involves:\n* Minimizing the use of gather_facts when not needed.\n* Limiting playbook runs to relevant hosts.\n* Using async tasks for long-running operations.\n* Employing parallelism with forks.\n* Avoiding unnecessary loops and conditionals.\n\nGotcha: YAML indentation matters in playbooks. Use 2-space indent consistently. A single wrong indent can change a task's behavior or cause a syntax error.	projects/knowledge/interview/ansible/072-how-can-you-optimize-ansible-playbooks-for-perform.txt
ansible-playbooks/eab6d10b3776	ansible-playbooks	medium	ansible, vault, playbook, role	What is Ansible Vault, and why is it used?	Ansible Vault is a feature that encrypts sensitive data, such as passwords or secret keys, within Ansible playbooks and roles. It ensures that sensitive information is kept secure and can be safely shared or stored in version control systems.\n\nGotcha: YAML indentation matters in playbooks. Use 2-space indent consistently. A single wrong indent can change a task's behavior or cause a syntax error.	projects/knowledge/interview/ansible/058-what-is-ansible-vault-and-why-is-it-used.txt
ansible-playbooks/eb8ca0aaaf51	ansible-playbooks	medium	ansible, playbook, module, connection	How can you use Ansible for managing Windows servers?	Ansible can manage Windows servers using WinRM (Windows Remote Management). Install the pywinrm Python module on the Ansible controller and configure WinRM on Windows servers. Use Ansible playbooks with appropriate Windows-specific modules to perform tasks.\n\nGotcha: YAML indentation matters in playbooks. Use 2-space indent consistently. A single wrong indent can change a task's behavior or cause a syntax error.	projects/knowledge/interview/ansible/081-how-can-you-use-ansible-for-managing-windows-serve.txt
ansible-playbooks/eda50fec4d02	ansible-playbooks	medium	ansible, playbook, module, inventory	Explain the key components of Ansible.	Ansible consists of:\n* Controller Node: The machine running Ansible, orchestrating tasks.\n* Managed Nodes: Systems Ansible manages and automates.\n* Inventory: A list of managed nodes.\n* Modules: Units of work executed by Ansible.\n* Playbooks: YAML files defining tasks and configurations.\n\nGotcha: YAML indentation matters in playbooks. Use 2-space indent consistently. A single wrong indent can change a task's behavior or cause a syntax error.	projects/knowledge/interview/ansible/032-explain-the-key-components-of-ansible.txt
ansible-playbooks/ef2db534069e	ansible-playbooks	medium	ansible, playbook, strategy	What is YAML, and why is it used in Ansible?	YAML (YAML Ain't Markup Language) is a human-readable data serialization format. Ansible uses YAML for playbooks and inventories due to its simplicity, readability, and easy mapping to data structures.\n\nGotcha: YAML indentation matters in playbooks. Use 2-space indent consistently. A single wrong indent can change a task's behavior or cause a syntax error.	projects/knowledge/interview/ansible/033-what-is-yaml-and-why-is-it-used-in-ansible.txt
ansible-playbooks/efb3f810c4af	ansible-playbooks	medium	ansible, playbook, module	What is the purpose of the debug module in Ansible?	The debug module in Ansible is used to print debug messages during playbook execution. It helps troubleshoot by providing information about variable values, task execution details, or any other custom messages.\n\nGotcha: YAML indentation matters in playbooks. Use 2-space indent consistently. A single wrong indent can change a task's behavior or cause a syntax error.	projects/knowledge/interview/ansible/087-what-is-the-purpose-of-the-debug-module-in-ansible.txt
ansible-playbooks/f09a822ef346	ansible-playbooks	medium	ansible, playbook	How do you include external tasks in an Ansible Playbook?	External tasks can be included using the include_tasks or import_tasks directives. For example:\n```yaml\n- name: Include external tasks\n  include_tasks: tasks/external_tasks.yml\n```\n\nRemember: import_* = static (parsed at playbook load). include_* = dynamic (parsed at runtime). Use import for roles, include for conditional logic.	projects/knowledge/interview/ansible/047-how-do-you-include-external-tasks-in-an-ansible-pl.txt
ansible-playbooks/f1a33b35a8d7	ansible-playbooks	medium	ansible, playbook, role	How can you use tags in Ansible Roles?	Tags in Ansible Roles allow selective execution of tasks. Tags are defined in the tasks themselves, and you can run only tasks with specific tags using the --tags option during playbook execution.\n\nGotcha: YAML indentation matters in playbooks. Use 2-space indent consistently. A single wrong indent can change a task's behavior or cause a syntax error.	projects/knowledge/interview/ansible/052-how-can-you-use-tags-in-ansible-roles.txt
ansible-playbooks/f4949b54fc19	ansible-playbooks	medium	ansible, playbook, vault	How do you use Ansible Vault in a playbook?	Include the ansible-vault command in the playbook execution command. \nExample:\n```bash\nansible-playbook --ask-vault-pass playbook.yml\n```\n\nGotcha: you can mix encrypted and unencrypted variable files in the same playbook. Use --vault-id to manage multiple vault passwords for different environments (dev, prod).\n\nGotcha: YAML indentation matters in playbooks. Use 2-space indent consistently. A single wrong indent can change a task's behavior or cause a syntax error.	projects/knowledge/interview/ansible/061-how-do-you-use-ansible-vault-in-a-playbook.txt
ansible-playbooks/f53e3633a0db	ansible-playbooks	medium	ansible, role, tower	What is Ansible Tower, and how does it differ from Ansible?	Ansible Tower is a web-based interface and automation orchestrator for Ansible. It provides a centralized platform for managing and monitoring Ansible automation. While Ansible is the underlying automation engine, Ansible Tower adds features like role-based access control, job scheduling, and a user-friendly interface.\n\nGotcha: YAML indentation matters in playbooks. Use 2-space indent consistently. A single wrong indent can change a task's behavior or cause a syntax error.	projects/knowledge/interview/ansible/065-what-is-ansible-tower-and-how-does-it-differ-from-.txt
ansible-playbooks/f839ee6953d1	ansible-playbooks	medium	ansible, jinja, testing	Write a single task that verifies all the files in files_list variable exist on the host	"```\n- name: Ensure all files exist\n  assert:\n    that:\n      - item.stat.exists\n  loop: ""{{ files_list }}""\n```\n\nRemember: variable precedence (low to high): defaults, inventory, playbook, role vars, extra vars (-e). Extra vars always win."	projects/knowledge/interview/ansible/016-write-a-single-task-that-verifies-all-the-files-in.txt
ansible-playbooks/fb623407ca6a	ansible-playbooks	easy	ansible, roles	"What are Ansible ""roles""?"	Organizational units that group related tasks and variables.\n\nRemember: a role is a self-contained bundle: tasks/, handlers/, templates/, files/, defaults/, vars/, meta/. Think 'reusable Ansible package.'\n\nExample: ansible-galaxy init myrole scaffolds the directory structure. Share roles via Galaxy or private Git repos.	projects/knowledge/interview/ansible/138-ansible-roles.txt

<!-- wiki:related:start -->
---

## Wiki Navigation

### Related Content

- [Ansible Automation](../../../../library/topics/ansible/index.md) (Topic Pack, L1) — Ansible
- Ansible Core Flashcards *(CLI)* (flashcard_deck, L1) — Ansible
- [Ansible Deep Dive](../../../../library/topics/ansible-deep-dive/index.md) (Topic Pack, L2) — Ansible
- [Ansible Drills](../../../../library/drills/ansible_drills.md) (Drill, L1) — Ansible
- Ansible Exercises (Quest Ladder) *(CLI)* (Exercise Set, L1) — Ansible
- Ansible Lab: Conditionals and Loops *(CLI)* (Lab, L1) — Ansible
- Ansible Lab: Facts and Variables *(CLI)* (Lab, L0) — Ansible
- Ansible Lab: Install Nginx (Idempotency) *(CLI)* (Lab, L1) — Ansible
- Ansible Lab: Ping and Debug *(CLI)* (Lab, L0) — Ansible
- Ansible Lab: Roles *(CLI)* (Lab, L1) — Ansible

<!-- wiki:related:end -->
