- (Exam Topic 1)
Create a file called packages.yml in /home/sandy/ansible to install some packages for the following hosts. On dev, prod and webservers install packages httpd, mod_ssl, and mariadb. On dev only install the development tools package. Also, on dev host update all the packages to the latest.
Solution:
Solution as:
** NOTE 1 a more acceptable answer is likely 'present' since it's not asking to install the latest
state: present
** NOTE 2 need to update the development node
- name: update all packages on development node yum:
'*'name:
state: latest
Does this meet the goal?
Correct Answer:
A
- (Exam Topic 2)
Modify file content.
-----------------------
Create a playbook called /home/admin/ansible/modify.yml as follows:
* The playbook runs on all inventory hosts
* The playbook replaces the contents of /etc/issue with a single line of text as follows:
--> On hosts in the dev host group, the line reads: “Development”
--> On hosts in the test host group, the line reads: “Test”
--> On hosts in the prod host group, the line reads: “Production”
Solution:
Solution as:
# pwd
/home/admin/ansible
# vim modify.yml
--
- name: hosts: all tasks:
- name: copy:
content: "Development" dest: /etc/issue
when: inventory_hostname in groups['dev']
- name: copy:
content: "Test" dest: /etc/issue
when: inventory_hostname in groups['test']
- name: copy:
content: "Production" dest: /etc/issue
when: inventory_hostname in groups['prod'] wq
# ansible-playbook modify.yml –-syntax-check
# ansible-playbook modify.yml
Does this meet the goal?
Correct Answer:
A
- (Exam Topic 1)
In /home/sandy/ansible/ create a playbook called logvol.yml. In the play create a logical volume called Iv0 and make it of size 1500MiB on volume group vgO If there is not enough space in the volume group print a message "Not enough space for logical volume" and then make a 800MiB Iv0 instead. If the volume group still doesn't exist, create a message "Volume group doesn't exist" Create an xfs filesystem on all Iv0 logical volumes. Don't mount the logical volume.
Solution:
Solution as:
Does this meet the goal?
Correct Answer:
A
- (Exam Topic 1)
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
Solution:
- name: change default target hosts: all
tasks:
- name: change target file:
src: /usr/lib/systemd/system/multi-user.target dest: /etc/systemd/system/default.target state: link
Does this meet the goal?
Correct Answer:
A
- (Exam Topic 1)
Create a playbook called issue.yml in /home/sandy/ansible which changes the file /etc/issue on all managed nodes: If host is a member of (lev then write "Development" If host is a member of test then write "Test" If host is a member of prod then write "Production"
Solution:
Solution as:
Does this meet the goal?
Correct Answer:
A