Create a role called sample-apache in /home/sandy/ansible/roles that enables and starts httpd, enables and starts the firewall and allows the webserver service. Create a template called index.html.j2 which creates and serves a message from /var/www/html/index.html Whenever the content of the file changes, restart the webserver service.
Welcome to [FQDN] on [IP]
Replace the FQDN with the fully qualified domain name and IP with the ip address of the node using ansible facts. Lastly, create a playbook in /home/sandy/ansible/ called apache.yml and use the role to serve the index file on webserver hosts.
Suggested Answer: A
Get Premium EX294 Questions
as Interactive Web-Based Practice Test or PDF
Real Exam Format
Detailed Explanations
Instant Access
Get Your Practice Test
30 comments · newest first
CA
Carmela
11 months ago
This is a great example of using Ansible facts effectively!
WI
Willow
12 months ago
Don't forget to check the firewall rules too!
RE
Rene
12 months ago
Wait, does it really restart the webserver every time the file changes?
BR
Brianne
1 year ago
Totally agree, this is a solid way to manage web servers with Ansible!
NA
Naomi
1 year ago
Sounds straightforward, just need to set up the role and template.
TO
Toshia
1 year ago
I remember we need to restart the webserver service when the index.html changes, but I’m not clear on how to set that up in the handlers.
EM
Emogene
1 year ago
I believe we need to define the tasks in main.yml, but I'm a bit confused about how to handle the template for the index.html file.
BU
Buffy
1 year ago
I practiced a similar question where we had to set up a web server, but I can't recall how to use Ansible facts for the FQDN and IP.
SE
Selma
1 year ago
I think I remember that we need to create the role structure first, but I'm not entirely sure about the exact file paths.
LA
Lavina
1 year ago
Whoa, this is a pretty comprehensive question. I'll need to make sure I don't miss any of the requirements, like replacing the FQDN and IP in the template. And I'll have to remember to add the handler to restart the webserver when the index.html file changes.
TY
Ty
1 year ago
Hmm, this seems like a lot of moving parts. I'll need to make sure I have the file paths and task names correct. Maybe I should sketch out the role structure and playbook first before diving in.
DE
Deane
1 year ago
This looks like a straightforward Ansible role and playbook question. I'll need to create the role structure, the tasks to enable and start the services, the template for the index.html file, and the playbook to tie it all together.
AD
Adaline
1 year ago
Okay, I think I've got a handle on this. I'll create the sample-apache role, add the tasks to manage the services, build the index.html template, and then use that role in the apache.yml playbook. Shouldn't be too bad as long as I pay attention to the details.
CO
Coletta
1 year ago
My strategy is to try running the code with an empty array and see what the output is. That should help me figure out the right answer.
AV
Avery
2 years ago
This is a solid solution. The only thing I'd add is a comment in the index.html.j2 template to explain the use of the Ansible facts. Keeps it readable for future maintainers.
AR
Artie
1 year ago
Yes, clear comments can make a big difference in understanding the code later on.
TY
Ty
1 year ago
I agree, documentation is key for maintaining code in the long run.
SH
Sheron
1 year ago
That's a good point, adding a comment for future maintainers is always helpful.
ST
Stephane
2 years ago
Haha, I wonder if the FQDN and IP address will actually match the node's details. Better double-check that Ansible fact usage!
SH
Shawnda
1 year ago
User 4: Let's make sure everything is configured correctly before running it.
TA
Tamala
1 year ago
User 3: The playbook and role setup looks good though.
PE
Peggy
2 years ago
User 2: Yeah, we should double-check the Ansible facts.
LE
Levi
2 years ago
User 1: I hope the FQDN and IP address match the node's details.
WI
William
2 years ago
Hold on, does the firewall really need to be enabled and started? Seems like an unnecessary step for a simple web server setup.
TR
Trina
2 years ago
I feel confident about it, I have practiced similar tasks before.
BR
Brent
2 years ago
Looks good! The role and playbook seem well-structured, and the template for the index.html file looks perfect. Can't wait to see it in action!
XU
Xuan
2 years ago
User 2: I'm excited to see it work too. The template for the index.html file looks great!
SH
Shelton
2 years ago
User 1: Thanks! I spent some time making sure everything was set up correctly.
DE
Destiny
2 years ago
I agree, setting up all those tasks in ansible roles can be tricky.
SH
Shanda
2 years ago
I think this question is quite challenging.