Ansible Quiz

 What file formats are valid for Ansible custom fact files?
Answer: INI,JSON, or an executable that return JSON

True or False: A host in an inventory may only be part of one host group
Answer: False. A host can be in any number of groups

Will the following ansible command fail: ‘ansible all -a "mkdir/tmp/testfile" ’
No! When not used with the module flag, the argument flag will simple run commands supplied via the argument flag directly against a target hosts (as long as they are valid commands)

What does max_failure_percentage set a threshold for?
Answer: The maximum number of host failures that ansible will allow before stopping the play

What module would you use to create a new system user?
Answer: The user module
Expand web[01:03].example.com which is part of inventory
Answer: 
web01.example.com 
web02.example.com 
web03.example.com

True or False: Parallelism allows Ansible to act on multiple hosts simultaneously.
Answer: True!
Parralellism is accomplished in Ansible by forking the Ansible process which allows many copies of Ansible to act at one time against many hosts

What keyword makes ansible continue a play execution despite a task failure?
Answer: ignore_errors: yes

True or false: ‘ansible-doc - - list’ is a quick way to a module listing on a system.
Answer: False. ‘Ansible-doc - -list’ is a rather slow to run.

What is the use of a machine credential in Ansible Tower?
Answer: The machine credential is used to supply a username and password (or ssh key) to access remote systems for use with ansible.

Ansible Tower provides what kind of interface to Ansible?
Answer: A web interface!

How can you make a task conditional on a binary expression?
Answer: The ‘when’ keyword.

How would you install the galaxy role named ‘awesome’ published by the user ‘stallman’?
Answer: ‘ansible-galaxy install stallman.awesome’

True or false: Ansible always runs 15% more forks than the number of hosts it is executing against.
False. Ansible always run the minimum number of forks it require

Not considering command line defined variables, what variable definition takes the highest precedence in an ansible role?
Answer: Variables defined in the ‘vars’ directory of a role

What two ansible-vault sub-commands allow you to edit an already encrypted file and see the contents of an encrypted file?
Answer: ‘Edit’ and ‘view’, respectively

What flag allows you provide a non-default role path?
Answer: The ‘-p’ flag.

What command is used to run ad-hoc ansible commands?
Answer: ‘ansible'

If you know Ansible is retrieving variables from a file called ‘./host_vars/Johnny’ , what host must exists in the inventory?
Answer: There must be a host named Johnny. Ansible checks ‘host_vars/‘ for files by host names within the inventory.

How does Ansible group a common set of tasks, variables, files, and handlers?
Answer: With Ansible Roles!

Which Ansible variable type allows for keyvalue pairs?
Answer: A dictionary variable

True or False: By default, playbooks gather facts on execution
Answer: True! Though you can disable fact gathering

What is the module index?
Answer: The comprehensive online listing of available ansible modules.

True or False: Handles and variables are shared between all roles on the system.
Answer: True.

What ‘ansible-vault’ command will encrypt a file named "classified" ?
Answer: ‘ansible-vault encrypt classified’

True or False: The ansible-galaxy command can only pull roles from galaxy.ansible.com.
Answer: False! The command can use any GitHub repo that is has credentials for.

True or False: ‘ad-hoc’ commands may be run from a tower project.
Answer: False! There is not an option to run an ‘adhoc’ command from the project menu.

True or False: It is not possible to provide more than one vault password when executing an Ansible playbook.
Answer: False. As of Ansible 2.4, the vault-id feature allows for multiple passwords to be used in a single playbook execution.

What is the data format returned by Ansible modules?
Answer: JSON

True or False: Ansible variables may be defined in external files
Answer: True! But the file must be included using either the vars_file keyword or through a command line switch

What is the command to return information on the htpasswd module?
Answer: ‘Ansible-doc htpasswd'

What keyword is used to pass parameters to an Ansible role?
Answer: ‘vars:’

What does the keyword ‘changed_when’ do?
Answer: It allows you to have Ansible mark a certain task result "changed" presuming the accompanying conditional returns true.

What directory does Ansible Tower use to look for project artifacts by default when configured to use a manual project?
Answer: The directory set in PROJECTS_ROOT.

What is the best way to manage a config file with Ansible?
Answer: Ansible Template

What is the processing langue for ansible templates?
Answer: Jinja2

If you know Ansible is retrieving variables from a file called ‘./group_vars/webservers’ , what group must exist in the inventory?
Answer: ‘Webservers’ , because the files for group_vars must be named after the group.

What facts are contained in the ansible_local variable?
Answer: Custom facts defined on remote systems using facts.d

What are the three flags that allow you to specify a password that will allow ansible to successfully use ansible-vault encrypted files?
Answer: ‘ask-vault-password’ , ‘ask-vault-file’ , and ‘vault-id’

What flag does the ansible-playbook command take that will cause the command to only run against a specified host?
Answer: The ‘- -limit’ flag'

What makes an Ansible inventory dynamic?
Answer: It is an executable file! Script or binary)

What are the two required parameters for the template module?
Answer:  
-src 
-dest

What directories may be used by an Ansible role?
Answer: 
-tasks 
-handlers
-vars 
-defaults 
-files 
-templates 
-meta

What Ansible module can write to stdout and stderr on the ansible control node during play execution?
Answer: The debug module

What three keywords work together to provide "try / catch" style error handling?
Answer: 
-block 
-rescue 
-always

What types of items may be in an Ansible inventory?
Answer: Hosts, groups, and variable declarations

What do the terms ‘install’, ‘init’ , ‘remove, and ‘search’ have in common when it comes to Ansible?
Answer: They are all sub commands of the ansible-galaxy command

What format must be returned by an Ansible dynamic inventory?
Answer: JSON

How can you manipulate text output from Ansible variables?
Answer: Using a Jinja filter

True or False: Ansible Tower is installed with Ansible Core
Answer: False. Ansible Tower is only available standalone

What keyword must be set to true in order to allow a role to be applied more than once within a play?
Answer: ‘allow_duplicates’

Which flag is used to specify the arguments that pass to a module for the ansible command?
Answer: ‘-a’

What is the script name that kicks off the Ansible Tower install?
Answer: ‘setup.sh’

Is it possible to use a directory as an Ansible inventory?
Answer: Yes! If you provide a directory as your inventory Ansible will use all of the valid inventories it finds in that directory (static or dynamic)

What Ansible modules allow one to insert text into an existing file?
Answer: ‘Lineinfile’

What does the template module do?
Answer: Deploys ansible templates

What are the two ways you can supply a vault password using ‘- -vault-id’?
Answer: You may specify a password file using ‘label@fileName’ or you may have ansible prom using ‘label@prompt’

What inventory file does the following command use: ‘ansible webservers -m setup’
Answer: The default inventory file

What keyword allows you to batch play execution by hosts?
Answer: The serial keyword

What ansible-vault sub-command allows you to encrypt a single string?
Answer: Encrypt-string

Using source control is the preferred way to set up what Ansible Tower artifact?
Answer: A Tower project

What flags must be handled by the dynamic inventory in Ansible?
Answer: 
 - - list 
 - - host <HOSTNAME>

Ansible Variable names should only be made of what?
Answer: ‘Letters, number, and underscores’

With no extra options, how does ansible-doc present output?
Answer: In a less like text viewing application

What is the Ansible module used to validate host connectivity?
Answer: ‘Ping’

What does the filter parameter for for the setup module?
Answer: It allows you to filter Ansible facts returned using a regular expression

Which Ansible role directories do not require a main.yml if they are being used?
Answer: ‘Templates’ and ‘files’

What Ansible module runs a command against a remote host with no environment set up?
Answer: The command module

This Ansible role directory is primarily used to define role dependencies
Answer: The ‘meta’ directory

How do you change the name of an Ansible role?
Answer: Rename the directory that defines the role

What is the Ansible command that gathers facts for all servers in the webservers group (assume default inventory file)?
Answer: ‘Ansible webservers -m setup’

What are the required parameters for the service module?
Answer: Only a name

What flag sets the fork count for an ansible ‘ad-hoc’ command?
Answer: -f <NUM_FORKS>

Where does ansible-galaxy install roles by default?
Answer: /etc/ansible/roles

Ansible variable names may only start with what?
Answer: A letter

What Ansible module installs software on Red Hat systems?
Answer: The yum module

True or False: The number of forks will limit how many hosts that a play with serial defined can execute on
Answer: True. Ansible will never make more than the maximum number of forks, even if serial is defined higher than that number in a play

True or false: Ansible variables may be prompted during play execution
Answer: True! Using the vars_prompt keyword

What file extension must be used for custom Ansible fact files?
Answer: .fact




 



0 Comments