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]
TASK: [debug var=“{{ps.stdout_lines}}”] ***************************************
ok: [appl12-lon.global.tudor.com] => {
“”:
}
PLAY RECAP ********************************************************************
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]
TASK: [debug var=“ps.stdout_lines”] *******************************************
ok: [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?