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 jinja template in /home/sandy/ansible/ and name it hosts.j2. Edit this file so it looks like the one below. The order of the nodes doesn't matter. Then create a playbook in /home/sandy/ansible called hosts.yml and install the template on dev node at /root/myhosts
Answer : A
Show Answer
Hide Answer
Question: 3
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: 4
Create an empty encrypted file called myvault.yml in /home/sandy/ansible and set the password to notsafepw. Rekey the password to iwejfj2331.
Question: 5
Create a playbook /home/sandy/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'.
Answer : A
Show Answer
Hide Answer