EMT Practice Test

1. Question Content...


Question List

Question1: What file should you look at first when installing tower?

Question2: What keyword stores a command's output into a variable?

Question3: Create a role called sample-apache and store it in /home/bob/ansible/roles. The role should satisfy the following requirements:
*In the role, install and enable httpd. Also enable the firewall to allow http. Also run the template
*index.html.j2 and make sure this runs Create a template index.html.j2 that displays "Welcome to the server HOSTNAME" In a play called apache.yml in /home/bob/ansible/ run the sample-apache role.

Question4: Templates must be written in what language?

Question5: In what format are ansible playbooks written?

Question6: Which flags must be accepted as input for a dynamic inventory script?

Question7: Which of the following is a good use case for an ad-hoc command? (Choose all that apply.)

Question8: Where is Ansible's inventory stored by default?

Question9: What does the lineinfile module do?

Question10: How are facts collected? (Choose all that apply.)

Question11: Consider the following playbook.
---
- hosts: local
become: yes
tasks:
- name: create users
user: name: "{{item}}" with_items:
- sam
- john
- bob
How many times is the user module invoked?

Question12: Create a playbook /home/bob /ansible/motd.yml that runs on all inventory hosts and docs the following: The playbook should replaee any existing content of/etc/motd in the following text. Use ansible facts to display the FQDN of each host On hosts in the dev host group the line should be "Welcome to Dev Server FQDN".
On hosts in the webserver host group the line should be "Welcome to Apache Server FQDN".
On hosts in the database host group the line should be "Welcome to MySQL Server FQDN".

Question13: Create a file called requirements.yml in /home/sandy/ansible/roles to install two roles. The source for the first role is geerlingguy.haproxy and geerlingguy.php. Name the first haproxy-role and the second php-role.
The roles should be installed in /home/sandy/ansible/roles.

Question14: State whether the following statement is true or false.
A template can only use 1 variable.

Question15: What command is used to run a playbook?

Question16: How is a role name set?

Question17: State whether the following statement is true or false.
There is a 10 user trial available.

Question18: Which keywords will cause a role to be applied in a playbook? (Choose all that apply.)

Question19: What does the -a flag allow you to specify?

Question20: State whether the following statement is true or false.
Will this command use servers in a local inventory called invent.local?
ansible all -m ping -i invent.local

Question21: Create a playbook /home/bob/ansible/timesync.yml that runs on hosts in the webservers host group and does the following:
* Uses the timesync RHEL system role.
* Sets the ntp server to 0.uk.pool.ntp.org
* Sets the timezone to UTC

Question22: Which of the following are valid ways to populate an Ansible Tower project with your source files?
(Choose all that apply.)

Question23: Templates have access to variables scoped at which of the following levels? (Choose all that apply.)

Question24: Create an ansible vault password file called lock.yml with the password reallysafepw in the
/home/sandy/ansible directory. In the lock.yml file define two variables. One is pw_dev and the password is
'dev' and the other is pw_mgr and the password is 'mgr' Create a regular file called secret.txt which contains the password for lock.yml.

Question25: Where is the first place Ansible checks for a role definition?

Question26: Which of the following are Ansible modules? (Choose all that apply.)

Question27: What character is used to denote use of a jinja filter on an Ansible variable?

Question28: Observe the details of the following dynamic inventory file.
$ ls -l dynamic.py -rw-rw-r--. 1 user user 1928 Mar 30 08:21 dynamic.py Why will this inventory file cause the ansible command to fail?

Question29: How does a user Access Ansible Tower once it is installed?

Question30: Using the Simulation Program, perform the following tasks:
Ad-Hoc Ansible Commands (Number Two) Task:
1. Use the ad-hoc command to make sure php is installed.
2. Use the ad-hoc command to make sure that php is installed and is the latest version.
3. Use the ad-hoc command to make sure that httpd is installed.
4. Use the ad-hoc command to remove httpd from the servers.

Question31: Which line instructs ansible to install httpd?

Question32: Create a playbook that changes the default target on all nodes to multi-user tarqet. Do this in playbook file called target.yml in /home/sandy/ansible

Question33: Which of the following are valid flags for the ansible-playbook command? (Choose all that apply.)

Question34: Which is the default inventory file used by Ansible?

Question35: Create a playbook called timesvnc.yml in /home/sandy/ansible using rhel system role timesync. Set the time to use currently configured nip with the server 0.uk.pool.ntp.org. Enable burst. Do this on all hosts.

Question36: Install and configure ansible
User sandy has been created on your control node with the appropriate permissions already, do not change or modify ssh keys. Install the necessary packages to run ansible on the control node. Configure ansible.cfg to be in folder /home/sandy/ansible/ansible.cfg and configure to access remote machines via the sandy user. All roles should be in the path /home/sandy/ansible/roles. The inventory path should be in
/home/sandy/ansible/invenlory.
You will have access to 5 nodes.
node1.example.com
node2.example.com
node3.example.com
node4.example.com
node5.example.com
Configure these nodes to be in an inventory file where node I is a member of group dev. nodc2 is a member of group test, node3 is a member of group proxy, nodc4 and node 5 are members of group prod. Also, prod is a member of group webservers.

Question37: State whether the following statement is true or false.
Ansible expects templates to use json format.

Question38: Which of these are valid as the first thing in a playbook? (Choose all that apply.)

Question39: State whether the following statement is true or false.
The command ansible-galaxy init won't create the file structure you need for roles.

Question40: What special character is used to designate that you are passing a variable file to a play using the
-e flag?

Question41: Consider the following playbook:
# playbook name: /home/ansible/web.yml
---
- hosts: webservers
become: yes
tasks:
- name: edit file 1
lineinfile:
path: /var/www/content.hml line: "{{ text }}" tags:
- content
- name: edit file 2
lineinfile: path: /var/www/index.hml
line: "{{ text }}"
tags:
- web
- name: edit file 3
lineinfile:
path: /var/www/etc.hml
line: "{{ text }}"
tags: - content - misc
Which use of the ansible-playbook command on the provided playbook will result in ONLY editing the file /var/www/index.html?

Question42: Which command will allow you to collect all facts for the specific host group 'labmachines'?

Question43: Which of the following are sub commands of the ansible-galaxy command? (Choose all that apply.)

Question44: What is the primary difference between the shell and command module?