Dear All,
I want to get output message of the log using ansible debug .
[Case-1]
If I know the no of results and I want too print then I can use below code
CODE[start]
- name: Display all Endpoints Health_Check test results[--------]
debug:
msg: - " endpoint check - [{{ ansible_fqdn }}] - [status_code: {{ PCheck.results[0].status }}] - {{ PCheck.results[0].url }}"
- " endpoint check - [{{ ansible_fqdn }}] - [status_code: {{ PCheck.results[1].status }}] - {{ PCheck.results[1].url }}"
- " endpoint check - [{{ ansible_fqdn }}] - [status_code: {{ PCheck.results[2].status }}] - {{ PCheck.results[2].url }}"
[Case-2]
If I don’t know about the number of results ,because I’m taking data from a file then I don’t know the no of entry so output result will be a variable value
Then how the above code will look like ,please suggest
CODE[start]
- name: Display all Endpoints Health_Check test results[--------]
debug:
msg: - " endpoint check - [{{ ansible_fqdn }}] - [status_code: {{ PCheck.results[0].status }}] - {{ PCheck.results[0].url }}"
- " endpoint check - [{{ ansible_fqdn }}] - [status_code: {{ PCheck.results[0+1].status }}] - {{ PCheck.results[0+1].url }}"
- " endpoint check - [{{ ansible_fqdn }}] - [status_code: {{ PCheck.results[0+2].status }}] - {{ PCheck.results[0+2].url }}"
.
.
. - " endpoint check - [{{ ansible_fqdn }}] - [status_code: {{ PCheck.results[0+n].status }}] - {{ PCheck.results[0+n].url }}"
NOTE: here ‘n’ is the no of entries in file
Please suggest . I’m new in Ansible world.
Thanks & Regards
Ram