Im having troube in Ansible 2.3.0 to print out my output in a human format. Currently everything comes out as one line. below is a sample of my yaml output.
`
register: output
- name: show output
debug:
var: output.stdout
`
Im having troube in Ansible 2.3.0 to print out my output in a human format. Currently everything comes out as one line. below is a sample of my yaml output.
`
register: output
Give an example please. Which output did you expected and what did you actually got?
ok: [192.168.14.25] => {
“output.stdout”: [
“Radio power mode = ON\nChannel Number = 1062\nCurrent Band = WCDMA 850\nCurrent RSSI(RSCP) = -70 dBm\nLTE Technology Preference = AUTO\nLTE Technology Selected = UMTS”
]
Try it like this:
Which will result in:
localhost | SUCCESS => {
“msg”: [
“Radio power mode = ON”,
“Channel Number = 1062”,
“Current Band = WCDMA 850”,
“Current RSSI(RSCP) = -70 dBm”,
“LTE Technology Preference = AUTO”,
“LTE Technology Selected = UMTS”
]
}
That didn’t work. The output I got from that was:
ok: [192.168.14.25] => {
“msg”: “output.stdout.split("\n")”
Ups, my bad. Like this “{{ output.stdout.split(‘\n’) }}”
Tried that and ended up getting the below error:
fatal: [192.168.14.25]: FAILED! => {
“failed”: true
}
MSG:
the field ‘args’ has an invalid value, which appears to include a variable that is undefined. The error was: ‘list object’ has no attribute ‘split’
The error appears to have been in ‘/home/ansible/4G.yml’: line 22, column 7, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
Since you output.stdout is a list you need to say which element in the list you would like to do a split on.
{{ output.stdout.0.split('\n') }}