# ansible-playbook truncating results

**URL:** <https://forum.ansible.com/t/ansible-playbook-truncating-results/15946>\
**Category:** Ansible Developer\
**Created:** [August 14, 2014, 11:08am UTC](https://forum.ansible.com/t/ansible-playbook-truncating-results/15946 "2014-08-14T11:08:08Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![bruce\_bushby](https://avatars.discourse-cdn.com/v4/letter/b/958977/32.png) [@bruce\_bushby](https://forum.ansible.com/u/bruce_bushby)\
**Post date:** [August 14, 2014, 11:08am UTC](https://forum.ansible.com/t/ansible-playbook-truncating-results/15946/1 "2014-08-14T11:08:08Z")

</div>

Hi

I’m new to ansible so still copying examples. I have this playbook example which appears to work…but is truncating the results:

[root@adm1-lon ansible]# cat ps.yaml

- hosts: development  
gather\_facts: no  
tasks:

- shell: “ps -eo ppid,pid,user,pcpu,args”  
register: ps

- debug: var=“ps.stdout\_lines”  
[root@adm1-lon ansible]#

and when I run it…

[root@adm1-lon ansible]# ansible-playbook -i hosts ps.yaml

PLAY [development] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

TASK: [shell ps -eo ppid,pid,user,pcpu,args] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
changed: [[appl12-lon.global.tudor.com](http://appl12-lon.global.tudor.com)]

TASK: [debug var=“{{ps.stdout\_lines}}”] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [[appl12-lon.global.tudor.com](http://appl12-lon.global.tudor.com)] =\> {  
“”:   
}

PLAY RECAP \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
[appl12-lon.global.tudor.com](http://appl12-lon.global.tudor.com) : ok=2 changed=1 unreachable=0 failed=0

[root@adm1-lon ansible]#

However, if I change the yaml to limit the line count like so:

[root@adm1-lon ansible]# cat ps.yaml

- hosts: development  
gather\_facts: no  
tasks:

- shell: “ps -eo ppid,pid,user,pcpu,args | head -200”  
register: ps

- debug: var=“ps.stdout\_lines”  
[root@adm1-lon ansible]#

I then get my results…although only the first 200 lines:

[root@adm1-lon ansible]# ansible-playbook -i hosts ps.yaml

PLAY [development] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

TASK: [shell ps -eo ppid,pid,user,pcpu,args | head -200] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
changed: [[appl12-lon.global.tudor.com](http://appl12-lon.global.tudor.com)]

TASK: [debug var=“ps.stdout\_lines”] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [[appl12-lon.global.tudor.com](http://appl12-lon.global.tudor.com)] =\> {  
“ps.stdout\_lines”: [  
" PPID PID USER %CPU COMMAND",  
" 0 1 root 0.0 /sbin/init",  
" 0 2 root 0.0 [kthreadd]“,  
" 2 3 root 0.0 [migration/0]”,  
" 2 4 root 0.0 [ksoftirqd/0]“,  
" 2 5 root 0.0 [migration/0]”,  
" 2 6 root 0.0 [migration/1]“,  
" 2 7 root 0.0 [migration/1]”,

…

System details:

[root@adm1-lon ansible]# cat /etc/redhat-release  
Red Hat Enterprise Linux Server release 6.4 (Santiago)  
[root@adm1-lon ansible]# rpm -qa | grep -i ansible  
ansible-1.5.3-1.el6.noarch  
[root@adm1-lon ansible]#

Any ideas?

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [August 14, 2014, 12:17pm UTC](https://forum.ansible.com/t/ansible-playbook-truncating-results/15946/2 "2014-08-14T12:17:24Z")

</div>

Do you mean you only get 200 lines of the standard output, or you don’t see the rest of the playbook run?

Thanks!

---

<div class="post-metadata">

**Author:** ![bruce\_bushby](https://avatars.discourse-cdn.com/v4/letter/b/958977/32.png) [@bruce\_bushby](https://forum.ansible.com/u/bruce_bushby)\
**Post date:** [August 14, 2014, 12:33pm UTC](https://forum.ansible.com/t/ansible-playbook-truncating-results/15946/3 "2014-08-14T12:33:32Z")

</div>

I don’t get ANY results…unless I limit the line count.

Here you can see my ps.yaml and the empty results:

[root@adm1-lon ansible]#  
[root@adm1-lon ansible]# cat ps.yaml

- hosts: development  
gather\_facts: no  
tasks:

- **shell: “ps -eo ppid,pid,user,pcpu,args”**  
register: ps

- debug: var=“ps.stdout\_lines”  
[root@adm1-lon ansible]#

[root@adm1-lon ansible]# ansible-playbook -i hosts ps.yaml

PLAY [development] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

TASK: [shell ps -eo ppid,pid,user,pcpu,args] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
changed: [[appl12-lon.global.tudor.com](http://appl12-lon.global.tudor.com)]

TASK: [debug var=“ps.stdout\_lines”] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [[appl12-lon.global.tudor.com](http://appl12-lon.global.tudor.com)] =\> {  
**“ps.stdout\_lines”: []**  
}

PLAY RECAP \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
[appl12-lon.global.tudor.com](http://appl12-lon.global.tudor.com) : ok=2 changed=1 unreachable=0 failed=0

[root@adm1-lon ansible]#

The all I do is add a “| tail -210” and suddenly I start getting results:

[root@adm1-lon ansible]# cat ps.yaml

- hosts: development  
gather\_facts: no  
tasks:

- **shell: “ps -eo ppid,pid,user,pcpu,args | tail -210”**  
register: ps

- debug: var=“ps.stdout\_lines”  
[root@adm1-lon ansible]#  
[root@adm1-lon ansible]# ansible-playbook -i hosts ps.yaml

PLAY [development] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

TASK: [shell ps -eo ppid,pid,user,pcpu,args | tail -210] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
changed: [[appl12-lon.global.tudor.com](http://appl12-lon.global.tudor.com)]

TASK: [debug var=“ps.stdout\_lines”] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [[appl12-lon.global.tudor.com](http://appl12-lon.global.tudor.com)] =\> {  
**“ps.stdout\_lines”: [**  
" 2748 2793 68 0.0 hald-addon-acpi: listening on acpid socket /var/run/acpid.socket",  
" 1 2805 bbushby 0.0 /bin/sh /etc/vnc/xstartup",  
" 2805 2809 bbushby 0.0 /usr/bin/ck-xinit-session /usr/bin/ssh-agent /etc/X11/xinit/Xclients",  
" 1 2825 bbushby 0.0 dbus-launch --sh-syntax --exit-with-session",  
" 1 2827 bbushby 0.0 /bin/dbus-daemon --fork --print-pid 5 --print-address 7 --session",  
" 2809 2855 bbushby 0.0 /usr/bin/gnome-session",  
" 2855 2856 bbushby 0.0 /usr/bin/ssh-agent /etc/X11/xinit/Xclients",

I was wondering about paramiko buffers/max char reads?

This is not a “line count” issue because it varies from system to system, it’s more a “max chars” limit that renders the result blank.

To make things more confusing…I created a large file with thousands of lines with many thousands of chars and I can “cat” it without any truncation.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [August 14, 2014, 12:40pm UTC](https://forum.ansible.com/t/ansible-playbook-truncating-results/15946/4 "2014-08-14T12:40:27Z")

</div>

Hmm, ok, I think I understand now, you’re not seeing any stdout from that task.

Can you please debug the full value and show me what you get (without the tail?)

- debug: var=ps

I’m also interested in your Ansible version. (Also, are you sure you are using paramiko? Perhaps explicitly specify with -c, as I want to make sure of the connection type).

Thanks!

---

<div class="post-metadata">

**Author:** ![bruce\_bushby](https://avatars.discourse-cdn.com/v4/letter/b/958977/32.png) [@bruce\_bushby](https://forum.ansible.com/u/bruce_bushby)\
**Post date:** [August 14, 2014, 1:15pm UTC](https://forum.ansible.com/t/ansible-playbook-truncating-results/15946/5 "2014-08-14T13:15:50Z")

</div>

Here we go…I simplified the “ps” command

[root@adm1-lon ansible]#  
[root@adm1-lon ansible]# cat ps.yaml

- hosts: development  
gather\_facts: no  
tasks:

- shell: “ps -ef”  
register: ps

- debug: var=ps  
[root@adm1-lon ansible]#  
[root@adm1-lon ansible]# ansible-playbook -i hosts ps.yaml

PLAY [development] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

TASK: [shell ps -ef] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
changed: [[appl12-lon.global.tudor.com](http://appl12-lon.global.tudor.com)]

TASK: [debug var=ps] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [[appl12-lon.global.tudor.com](http://appl12-lon.global.tudor.com)] =\> {  
“ps”: {  
“changed”: true,  
“cmd”: "ps -ef ",  
“delta”: “0:00:00.025065”,  
“end”: “2014-08-14 14:00:52.483265”,  
“invocation”: {  
“module\_args”: “ps -ef”,  
“module\_name”: “shell”  
},  
“rc”: 0,  
“start”: “2014-08-14 14:00:52.458200”,  
“stderr”: “”,  
“stdout”: “”,  
“stdout\_lines”:   
}  
}

PLAY RECAP \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
[appl12-lon.global.tudor.com](http://appl12-lon.global.tudor.com) : ok=2 changed=1 unreachable=0 failed=0

[root@adm1-lon ansible]#

I think it has something to do with the way ansible is parsing the shell command. If I change the command to simply “ps” …then it works 100% on my 3 test servers…although “ps” on it’s does generate less characters.

[root@adm1-lon ansible]#  
[root@adm1-lon ansible]#  
[root@adm1-lon ansible]# cat ps.yaml

- hosts: development  
gather\_facts: no  
tasks:

- shell: “ps”  
register: ps

- debug: var=ps  
[root@adm1-lon ansible]#  
[root@adm1-lon ansible]# ansible-playbook -i hosts ps.yaml

PLAY [development] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

TASK: [shell ps] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
changed: [[appl12-lon.global.tudor.com](http://appl12-lon.global.tudor.com)]

TASK: [debug var=ps] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [[appl12-lon.global.tudor.com](http://appl12-lon.global.tudor.com)] =\> {  
“ps”: {  
“changed”: true,  
“cmd”: "ps ",  
“delta”: “0:00:00.016743”,  
“end”: “2014-08-14 14:03:04.342171”,  
“invocation”: {  
“module\_args”: “ps”,  
“module\_name”: “shell”  
},  
“rc”: 0,  
“start”: “2014-08-14 14:03:04.325428”,  
“stderr”: “”,  
“stdout”: " PID TTY TIME CMD\n 1 ? 00:00:04 init\n 2 ? 00:00:00 kthreadd\n 3 ? 00:00:09 migration/0\n 4 ? 00:02:37 ksoftirqd/0\n 5 ? 00:00:00 migration/0\

…cut

Here I run a simple “cat /tmp/file” which returns 768k+ characters…so perhaps not just a simple max character/buffer issue.

[root@adm1-lon ansible]#  
[root@adm1-lon ansible]# cat count.yaml

- hosts: development  
gather\_facts: no  
tasks:

- shell: cat /tmp/test-count  
register: count

- debug: var=“{{count.stdout\_lines}}”  
[root@adm1-lon ansible]#  
[root@adm1-lon ansible]# ansible-playbook -i hosts count.yaml | wc -c  
768386  
[root@adm1-lon ansible]#

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [August 14, 2014, 1:22pm UTC](https://forum.ansible.com/t/ansible-playbook-truncating-results/15946/6 "2014-08-14T13:22:07Z")

</div>

That’s really weird - all shell commands are parsed the same.

before I ask you to file a bug on this, can you share what version of Ansible you are using?

Aside on one thing really quickly:

" - debug: var=“{{count.stdout\_lines}}”

This really should be:

- debug: msg=“{{ count.stdout\_lines }}”

Though it appears to work for simple integers, 768386 is not a variable name, so that’s why it’s weird.

- debug: var=count.stdout\_lines

should be legit.
