Question: 1
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''
A Explanation:
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
Answer : A
Show Answer
Hide Answer
Question: 2
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.
Answer : A
Show Answer
Hide Answer
Question: 3
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''
A Explanation:
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
Answer : A
Show Answer
Hide Answer
Question: 4
Install the RHEL system roles package and create a playbook called timesync.yml that:
--> Runs over all managed hosts.
--> Uses the timesync role.
--> Configures the role to use the time server 192.168.10.254 ( Hear in redhat lab
use "classroom.example.com" )
--> Configures the role to set the iburst parameter as enabled.
A Explanation:
Solution as:
# pwd
home/admin/ansible/
# sudo yum install rhel-system-roles.noarch -y
# cd roles/
# ansible-galaxy list
# cp -r /usr/share/ansible/roles/rhelsystem-roles.timesync .
# vim timesync.yml
---
- name: timesynchronization
hosts: all
vars:
timesync_ntp_provider: chrony
timesync_ntp_servers:
- hostname: classroom.example.com _ in exam its ip-address
iburst: yes
timezone: Asia/Kolkata
roles:
- rhel-system-roles.timesync
tasks:
- name: set timezone
timezone:
name: '{{ timezone }}'
:wq!
timedatectl list-timezones | grep india
# ansible-playbook timesync.yml --syntax-check
# ansible-playbook timesync.yml
# ansible all -m shell -a 'chronyc sources -v'
# ansible all -m shell -a 'timedatectl'
# ansible all -m shell -a 'systemctl is-enabled chronyd'
Answer : A
Show Answer
Hide Answer
Question: 5
Create a file called specs.empty in home/sandy/ansible on the local machine as follows:
HOST=
MEMORY=
BIOS=
VDA_DISK_SIZE=
VDB_DISK_SIZE=
Create the playbook /home/sandy/ansible/specs.yml which copies specs.empty to all remote nodes' path /root/specs.txt. Using the specs.yml playbook then edit specs.txt on the remote machines to reflect the appropriate ansible facts.
Answer : A
Show Answer
Hide Answer