IaC Ansible
Please answer the quiz and click the "Test" button at the bottom right.
Question 1
Consider the following playbook:
- name: Frontend servers
hosts: frontend
become: yes
tasks:
- name: ???
ansible.builtin.apt:
name: nginx
state: absent
Applying this playbook on an Ubuntu host with Nginx already installed:
- Will install nginx again.
- Will remove the nginx installation.
- Will do nothing since nginx is already installed.
- None of the above
Consider the below playbook:
- name: deploy app config
template:
src: app.xml.j2
dest: /etc/app.xml
notify:
- restart memcached
- restart apache
- name: deploy httpd config
template:
src: httpd.conf.j2
dest: /etc/httpd/conf/httpd.conf
notify:
- restart apache
- name: deploy httpd config
template:
src: site.conf.j2
dest: /etc/httpd/conf/site.conf
notify:
- restart apache
Answer the below 2 questions:
Question 2
After applying the playbook, the output is:
PLAY RECAP ******************************************************************************************************************************
server : ok=3 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
- The
restart apache
handler have been called once. - The
restart apache
handler have been called 2 times. - The
restart apache
handler have been called 3 times once. - The
restart apache
handler have not been called.
Question 3
After applying the playbook, the output is:
PLAY RECAP ******************************************************************************************************************************
server : ok=3 changed=2 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
- The
restart apache
handler have been called once. - The
restart apache
handler have been called 2 times. - The
restart apache
handler have been called 3 times once. - The
restart apache
handler have not been called.
Question 4
Which of the following is a good use case for an ad-hoc command?
- Installing firewall on application servers
- Checking the free memory on a particular group of hosts
- Experimenting with an Ansible module
- Upgrading some application stack