My question on stdout[0] is specific to below output. As i understand from ansible documentation, stdout means that it quotes the output of a variable and [0] means referencing the first char or command. I am just trying to figure out how the definition relates to what it does in below script.
The output of show flash: is stored in custom variable called show_flash shown below. 1st script below contains .stdout[0] after name of custom variable whereas 2nd script does not. I am trying to understand how stdout[0] affects the output the way it does given it’s above meaning?
even though below syntax may not appear in correct format, it is properly formatted when executed and i get no error, just a different kind of output
SCRIPT 1:
- name: Pass text and template_path
ansible.utils.cli_parse:
text: “{{ show_flash.stdout[0] }}”
parser:
name: ansible.utils.ttp
template_path: “templates/sample2.ttp”‘’’
OUTPUT:
TASK [Display facts]
ok: [ROUTER] => {
“msg”: [
[
{
“flash:/”: {
“bytes_free”: 22840320,
“bytes_total”: 122185728
script 2:
- name: Pass text and template_path
ansible.utils.cli_parse:
text: “{{ show_flash }}”
parser:
name: ansible.utils.ttp
template_path: “templates/sample2.ttp”
OUTPUT:
TASK [Display facts]
ok: [ROUTER] => {
“msg”: [
[
{}
]
]
}
Thanks,
Vikram