I have a bash script on each server that gathers some information and then 
stores that info in the commands variable.  If I write 'commands.stdout | 
to_nice_json' to a file, everything is fine.  If I use 
'commands.stdout_lines | to_nice_json' it immediately reboots my Ansible 
server.  If I remove the 'to_nice_json' it doesn't have an issue.  Should I 
file a bug? or do you have any other theories?  

ansible-2.6.1-1.el7.noarch

Playbook:
---
- hosts: "{{ host }}"
  tasks:
    - name: Gather used sudo commands
      shell: "/home/myuser/scripts/dba_history.sh"
      register: commands

    - name: Write results
      shell: "echo {{ commands.stdout_lines | to_nice_json }} >> 
/tmp/dba_commands.txt"
      delegate_to: localhost

It crashes when writing results:
ansible:/playbooks/one-offs # ansible-playbook ./dba_sudo_commands.yml -e 
host=labenv

PLAY
 [labenv] 
****************************************************************************************************************************************************************************************************************************

TASK
 [Gathering Facts] 
*******************************************************************************************************************************************************************************************************************
ok: [labebs-apps1]
ok: [labebs-db]

TASK
 [Gather used sudo commands] 
*********************************************************************************************************************************************************************************************************
changed: [labebs-apps1]
changed: [labebs-db]

TASK
 [Write results] 
*********************************************************************************************************************************************************************************************************************
Connection to ansible closed by remote host.
Connection to ansible closed.

Sample output of the script without 'to_nice_json':
ok: [labebs-apps1] => {
    "commands": {
        "changed": true,
        "cmd": "/home/myuser/scripts/dba_history.sh",
        "delta": "0:00:00.109182",
        "end": "2018-08-01 21:27:47.942792",
        "failed": false,
        "rc": 0,
        "start": "2018-08-01 21:27:47.833610",
        "stderr": "",
        "stderr_lines": [],
        "stdout": "cd 
/labebs/inst/apps/LABEBS_labebs-apps1/ora/10.1.3/Apache/Apache/bin\ncd 
/labebs/inst/apps/LABEBS_labebs-apps1/ora/10.1.3/Apache/Apache/bin\ncd 
/labebs/inst/apps/LABEBS_labebs-apps1/ora/10.1.3/Apache/Apache/bin\ncd 
/labebs/inst/apps/LABEBS_labebs-apps1/ora/10.1.3/Apache/Apache/bin\ncd 
/labebs/inst/apps/LABEBS_labebs-apps1/ora/10.1.3/Apache/Apache/bin\ncd 
.gi\ncd .git/\ncd 
/labebs/inst/apps/LABEBS_labebs-apps1/ora/10.1.3/Apache/Apache/bin\ncd 
scripts/\nvi config \ncd 
/labebs/inst/apps/LABEBS_labebs-apps1/ora/10.1.3/Apache/Apache/bin\ncd 
/etc/rsyslog.d/\ncd 
/labebs/inst/apps/LABEBS_labebs-apps1/ora/10.1.3/Apache/Apache/bin\nclear\ninit 
0\nrsyslogd\nrsyslogd -c5\nrsyslogd -N1\ncat 91-applmgr.conf \ncd 
/etc/security/limits.d/\ncd 
/labebs/inst/apps/LABEBS_labebs-apps1/ora/10.1.3/Apache/Apache/bin\nps aux 
| grep smon\ncat 91-applmgr.conf \ncd /etc/security/limits.d/\ncd 
/labebs/\ncd 
/labebs/inst/apps/LABEBS_labebs-apps1/ora/10.1.3/Apache/Apache/bin\nps aux 
| grep smon\nvi /etc/fstab \nreboot",
        "stdout_lines": [
            "cd 
/labebs/inst/apps/LABEBS_labebs-apps1/ora/10.1.3/Apache/Apache/bin",
            "cd 
/labebs/inst/apps/LABEBS_labebs-apps1/ora/10.1.3/Apache/Apache/bin",
            "cd 
/labebs/inst/apps/LABEBS_labebs-apps1/ora/10.1.3/Apache/Apache/bin",
            "cd 
/labebs/inst/apps/LABEBS_labebs-apps1/ora/10.1.3/Apache/Apache/bin",
            "cd 
/labebs/inst/apps/LABEBS_labebs-apps1/ora/10.1.3/Apache/Apache/bin",
            "cd .gi",
            "cd .git/",
            "cd 
/labebs/inst/apps/LABEBS_labebs-apps1/ora/10.1.3/Apache/Apache/bin",
            "cd scripts/",
            "vi config ",
            "cd 
/labebs/inst/apps/LABEBS_labebs-apps1/ora/10.1.3/Apache/Apache/bin",
            "cd /etc/rsyslog.d/",
            "cd 
/labebs/inst/apps/LABEBS_labebs-apps1/ora/10.1.3/Apache/Apache/bin",
            "clear",
            "init 0",
            "rsyslogd",
            "rsyslogd -c5",
            "rsyslogd -N1",
            "cat 91-applmgr.conf ",
            "cd /etc/security/limits.d/",
            "cd 
/labebs/inst/apps/LABEBS_labebs-apps1/ora/10.1.3/Apache/Apache/bin",
            "ps aux | grep smon",
            "cat 91-applmgr.conf ",
            "cd /etc/security/limits.d/",
            "cd /labebs/",
            "cd 
/labebs/inst/apps/LABEBS_labebs-apps1/ora/10.1.3/Apache/Apache/bin",
            "ps aux | grep smon",
            "vi /etc/fstab ",
            "reboot"
        ]
    }
}




-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/833fdc77-151b-42cf-815c-6903a21fd918%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to