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 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.
Answer : A
Show Answer
Hide Answer
Question: 3
Install and configure ansible
User sandy has been created on your control node. Give him the appropriate permissions on the control node. Install the necessary packages to run ansible on the control node.
Create a configuration file /home/sandy/ansible/ansible.cfg to meet the following requirements:
* The roles path should include /home/sandy/ansible/roles, as well as any other path that may be required for the course of the sample exam.
* The inventory file path is /home/sandyansible/inventory.
* Ansible should be able to manage 10 hosts at a single time.
* Ansible should connect to all managed nodes using the sandy user.
Create an inventory file for the following five nodes:
Configure these nodes to be in an inventory file where node1 is a member of group dev. nodc2 is a member of group test, nodc3 is a member of group proxy, nodc4 and node 5 are members of group prod. Also, prod is a member of group webservers.
A Explanation:
In/home/sandy/ansible/ansible.cfg
[defaults]
inventory=/home/sandy/ansible/inventory
roles_path=/home/sandy/ansible/roles
remote_user= sandy
host_key_checking=false
[privilegeescalation]
become=true
become_user=root
become_method=sudo
become_ask_pass=false
In /home/sandy/ansible/inventory
[dev]
node 1 .example.com
[test]
node2.example.com
[proxy]
node3 .example.com
[prod]
node4.example.com
node5 .example.com
[webservers:children]
prod
Answer : A
Show Answer
Hide Answer
Question: 4
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
Question: 5
Create an empty encrypted file called myvault.yml in /home/sandy/ansible and set the password to notsafepw. Rekey the password to iwejfj2331.