Question 7

CORRECT TEXT
Create a playbook /home/bob /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".
Solution:
/home/sandy/ansible/apache.yml
EX407 dumps exhibit
/home/sandy/ansible/roles/sample-apache/tasks/main.yml

Does this meet the goal?

Correct Answer:A

Question 8

CORRECT TEXT
=====================================================================
==============
control.realmX.example.com _ workstation.lab.example.com
node1.realmX.example.com _ servera.lab.example.com
node2.realmX.example.com _ serverb.lab.example.com
node3.realmX.example.com _ serverc.lab.example.com
node4.realmX.example.com _ serverd.lab.example.com
node5.realmX.example.com
- username:root, password:redhat
- username:admin, password:redhat
note1. don??t change ??root?? or ??admin?? password.
note2. no need to create ssh-keygen for access, its pre-defined
note3. SELinux is in enforcing mode and firewalld is disabled/stop on whole managed hosts.
=====================================================================
==============
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

Question 9

CORRECT TEXT
Using the Simulation Program, perform the following tasks:
* 1. Use an ansible ad-hoc command, check the connectivity of your servers.
* 2. Use an ad-hoc ansible command, find the free space of your servers.
* 3. Use an ad-hoc ansible command, find out the memory usage of your servers.
* 4. Do an ls -l on the targets /var/log/messages file.
* 5. Tail the contents of the targets /var/log/messages file.
Solution:
* 1. ansible all -m ping
* 2. ansible all -a "/bin/df -h"
* 3. ansible all -a "/usr/bin/free"
* 4. ansible all -a "ls -l /var/log/messages"
* 5. ansible local -b -a "tail /var/log/messages"

Does this meet the goal?

Correct Answer:A

Question 10

CORRECT TEXT
Using the Simulation Program, perform the following tasks:
Static Inventories Task:
* 1. Add a new group to your default ansible host file. call the group [ec2]
* 2. Add a new host to the new group you created.
* 3. Add a variable to a new host entry in the /etc/ansible/hosts file. Add the following. localhost http_port=80 maxRequestsPerChild=808
* 4. Check to see if maxRequestsPerChild is pulled out with an ad-hoc command.
* 5. Create a local host file and put a target group and then a host into it. Then ping it with an ad-hoc command.
Solution:
* 1. Edit the /etc/ansible/hosts file. Add a group.
* 2. Edit the /etc/ansible/hosts file. Add a user under the group you created.
* 3. Edit the /etc/ansible/hosts file. Find a host. if we add a variable called maxRequestsPerChild to the host it would look like this. host1 maxRequestsPerChild=808
* 4. ansible ec2 -m shell -a "echo {{ maxRequestsPerChild }}"
* 5. Edit a local file. It could be called anything. Lets call it myhosts. Inside the file it would have a host like the following. [mygroup] myusername1.mylabserver.com

Does this meet the goal?

Correct Answer:A

Question 11

CORRECT TEXT
Using the Simulation Program, perform the following tasks:
Ad-Hoc Ansible Commands (Number Two) Task:
* 1. Use the ad-hoc command to make sure php is installed.
* 2. Use the ad-hoc command to make sure that php is installed and is the latest version.
* 3. Use the ad-hoc command to make sure that httpd is installed.
* 4. Use the ad-hoc command to remove httpd from the servers.
Solution:
* 1. ansible all -b -m yum -a 'name=php state=present'
* 2. ansible all -b -m yum -a 'name=php state=latest'
* 3. ansible all -b -m yum -a 'name=httpd state=latest'
* 4. ansible all -b -m yum -a 'name=httpd state=absent'

Does this meet the goal?

Correct Answer:A

Question 12

CORRECT TEXT
=====================================================================
==============
control.realmX.example.com _ workstation.lab.example.com
node1.realmX.example.com _ servera.lab.example.com
node2.realmX.example.com _ serverb.lab.example.com
node3.realmX.example.com _ serverc.lab.example.com
node4.realmX.example.com _ serverd.lab.example.com
node5.realmX.example.com
- username:root, password:redhat
- username:admin, password:redhat
note1. don??t change ??root?? or ??admin?? password.
note2. no need to create ssh-keygen for access, its pre-defined
note3. SELinux is in enforcing mode and firewalld is disabled/stop on whole managed hosts.
=====================================================================
==============
Create a playbook called web.yml as follows:
* The playbook runs on managed nodes in the "dev" host group
* Create the directory /webdev with the following requirements:
--> membership in the apache group
--> regular permissions: owner=r+w+execute, group=r+w+execute, other=r+execute s.p=set group-id
* Symbolically link /var/www/html/webdev to /webdev
* Create the file /webdev/index.html with a single line of text that reads: ??Development??
--> it should be available on http://servera.lab.example.com/webdev/index.html
Solution:
Solution as:
# pwd
/home/admin/ansible/
# vim web.yml
---
- name: hosts: dev tasks:
- name: create group yum:
name: httpd state: latest
- name: create group group:
name: apache state: present
- name: creating directiory file:
path: /webdev state: directory mode: '2775' group: apache
- sefcontext:
target: '/webdev/index.html' setype: httpd_sys_content_t state: present
- name: Apply new SELinux file context to filesystem command: restorecon -irv
- name: creating symbolic link file:
src: /webdev
dest: /var/www/html/webdev state: link
force: yes
- name: creating file file:
path: /webdev/index.html sate: touch
- name: Adding content to index.html file copy:
dest: /webdev/index.html content: "Development"
- name: add service to the firewall firewalld:
service: http permanent: yes state: enabled immediate: yes
- name: active http service service:
name: httpd state: restarted enabled: yes wq
# ansible-playbook web.yml -–syntax-check
# ansible-playbook web.yml

Does this meet the goal?

Correct Answer:A

START EX407 EXAM