That was my assumption after looked images result. There is no mean of default-ipv4-address. Basically we do gather_facts to get a information of system info. I haven’t seen task description so i have no clue to say more.
Hi @kleansoul , @Tej-Singh-Rana, @Lakshmi , @kodekloud-support3 , @Inderpreet
for this task do we need to use {{ ansible_facts.default_ipv4.address }} in the block attribute of blockinfile module since there is no such variable/fact that is called “default-ipv4-address” ,ie,
like
block: "Ansible managed node IP is {{ ansible_facts.default_ipv4.address }}"
and is that the only task that needs to be present in index.yml file , ie, is the httpd installation to be done manually without using ansible ?
The task question seems to lack some further information. That’s why I too wanted to clarify it but havn’t received any reply yet. Seems like only you and I have received this task soo far.
Awaiting for a response from KKE team to clarify and recheck my task.
Yeah , ip address variable is confusing . But @kleansoul for the httpd setup and the copy of facts.txt to index.html , did you do those steps without using ansible ?
For me question was not completely clear. I understood that if there is nothing mentioned in the task to use the specific variable then better not use it , so thus I didn’t and therefore failed and easy one!
I wish the task was framed correctly so at least it would say something about using a variable.
I have failed this task though I was able to complete is successfully as per the instructions. I have added the block “Ansible managed node IP is ” as it is. Yes, the “” does not do the job but it is what was given from the task instructions .
Hi @Salim , the facts.txt should be located at /root dir and not at / dir . Your validation screenshot shows that the file is located at / dir which is also indicated in the task failure message (/root/facts.txt does not exist) and you should also use an ansible variable when using blockinfile module like so
"Ansible managed node IP is {{ ansible_facts.default_ipv4.address }}"
since as per you screenshot you are using the sentence given in the task
However you are missing the point here. If you check my post I agree with you that the “<default-ipv4-address” is incorrect and but it what was given from the task instructions. And yes I am aware that I put the facts.txt file in the wrong location. It would be better if the task removed the “<default-ipv4-address” or replace it which the correct entry. Suppose I have put the facts.txt in the /root/ but I have used the"<default-ipv4-address" , would this task marked failed or success?
There is also a trick on how you can speed up your plays with filtering facts gathering in ansible. If you need only default_ipv4.address in the play you can do following:
- hosts: someinventorygroup
gather_facts: no
pre_tasks:
- setup:
filter: ansible_default_ipv4
roles: # or tasks:
This trick is working with gathering = explicit in /etc/ansible/ansible.cfg
Hi @Salim facts.txt isn’t in the right place u fail the task,
another point, right there is nothing in task instructions that tells you to use the ansible variable for default_ipv4, but in your case that’s not the cause , Good luck for the rest