EX407 Hosts Practice Questions
The free EX407: Red Hat Certified Specialist in Ansible Automation questions that deal with hosts, with answers and explanations. The full bank and the timed practice test cover every topic the exam asks about.
Question #4
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.
Type your answer, then reveal.
Correct answer: A
Explanation
* 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
Question #7
=================================================================================== 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 packages.yml that: ---------------------------------------------- --> Installs the php and mariadb packages on hosts in the dev, test, and prod host groups. --> Installs the Development Tools package group on hosts in the dev host group. --> Updates all packages to the latest version on hosts in the dev host group.
Type your answer, then reveal.
Correct answer: A
Explanation
Solution as: # pwd home/admin/ansible/ # vim packages.yml --- - name: Install the packages hosts: dev,test,prod vars: - php_pkg: php - mariadb_pkg: mariadb tasks: - name: install the packages yum: name: - "{{ php_pkg }}" - "{{ mariadb_pkg }}" state: latest - name: install the devops tool packages hosts: dev tasks: - name: install devepment tools yum: name: "@Development Tools" state: latest - name: upgrade all the packages yum: name: "*" state: latest exclude: kernel* !wq # ansible-playbook package.yml –-syntax-check # ansible-playbook package.yml
Question #10
=================================================================================== 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. =================================================================================== Generate a hosts file: * Download an initial template file hosts.j2 from http://classroom.example.com/hosts.j2 to /home/admin/ansible/ Complete the template so that it can be used to generate a file with a line for each inventory host in the same format as /etc/hosts: 172.25.250.9 workstation.lab.example.com workstation * Create a playbook called gen_hosts.yml that uses this template to generate the file /etc/myhosts on hosts in the dev host group. * When completed, the file /etc/myhosts on hosts in the dev host group should have a line for each managed host: * 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 172.25.250.10 serevra.lab.example.com servera * 172.25.250.11 serevrb.lab.example.com serverb * 172.25.250.12 serevrc.lab.example.com serverc * 172.25.250.13 serevrd.lab.example.com serverd ----------------------------------------------------------------- while practising you to create these file hear. But in exam have to download as per questation. hosts.j2 file consists. localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 -------------------------------------------------------------------
Type your answer, then reveal.
Correct answer: A
Explanation
Solution as: # pwd /home/admin/ansible # wget http://classroom.example.com/hosts.j2 # vim hosts.j2 * 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 {% for host in groups['all'] %} {{ hostvars[host]['ansible_facts']['default_ipv4']['address'] }} {{ hostvars[host] ['ansible_facts']['fqdn'] }} {{ hostvars[host]['ansible_facts']['hostname'] }} {% endfor %} wq! # vim gen_hosts.yml --- - name: collecting all host information hosts: all tasks: - name: template: src: hosts.j2 dest: /etc/myhosts when: inventory_hostname in groups['dev'] wq # ansible-playbook gen_hosts.yml -–syntax-check # ansible-playbook gen_hosts.yml
Continue with EX407: Red Hat Certified Specialist in Ansible Automation exam
Unlock the full question bank
You have read the first 10 questions. A subscription opens every question in EX407: Red Hat Certified Specialist in Ansible Automation exam, the full timed practice test, and your progress and weak-topic reporting.
Single exam
$19.99for 30 days
Full question bank and practice test for one exam, for 30 days.
Single exam
$49.99for 1 year
One exam for a full year. Nothing renews and nothing to cancel.
Full access
$39.99/mo
Every exam in the catalogue, month to month.
Full access
$199.99/yr
Every exam in the catalogue for a year.
Already subscribed? Sign in to pick up where you left off.
All EX407: Red Hat Certified Specialist in Ansible Automation practice questions →
