Jinja2 Ansible lab in Ansible Certification course

Hi All,

I have been learning the Ansible Certification course and when it comes to Jinja2 Ansible lab it says the target hosts are not UP and just to update the playbook. But when I run the check it says the task is not completed stating the ssh connectivity is not there.

If the target hosts are not up then can we skip that task during check?


Hi Momshad,

Need your help here. Question says the target servers are not UP and if i check its trying to connect and ssh is getting failed for the same.

Attached the playbook and error screen for the same. Please assist here so I can proceed with others.

can you share image of inventory file ?

Attached the inventory file

@Karthik

You need to copy this template to monitoring server and you just need to fetch web nodes information within the template, see the sample template given. (you actually need not to execute the same for web nodes). You might need to use hostvars in your template so please try that way.

@Inderpreet

Thank you… I have done that but when i come to load balancer part there seems to be an issue.
Could you please help me with this?

The files are not copied to the remote servers.





Looking for a reply to proceed with this lab.

@Karthik

The hostname inside inventory is load_balancer but you have passed load-balancer in your playbook so its not running for correct host. Please try again with correct hostname.

@Inderpreet

Thank you

I have one doubt on hostvars. Why do we need to use hostvars in the for loop?

We can use it like below right?

{% for i in groups[‘web’] %}
server {{ i.ansible_host }};
{% endfor %}