---
- 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
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 ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
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.
Thanks Matt. I tried the '| quote' and it did not crash this time. I will look into the template module.
--
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 ansible-project+unsubscribe@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/6aebd3c31e9d0533bfcb4b5a377fd9ae%40olstad.com.
Hi all I am facing error in aws please help.[root@server2 ~]# ssh -i bhadra.pem ec2-...@ec2-50-112-6-190.us-west-2.compute. amazonaws.comThe authenticity of host 'ec2-50-112-6-190.us-west-2.compute.amazonaws.com (50.1 12.6.190)' can't be established.
ECDSA key fingerprint is 1f:1b:6b:13:d2:7a:b5:a4:4b:78:84:b7:98:05:ab:39.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'ec2-50-112-6-190.us-west-2.compute.amazonaws.com,50. 112.6.190' (ECDSA) to the list of known hosts.
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: UNPROTECTED PRIVATE KEY FILE! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0644 for 'bhadra.pem' are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.
bad permissions: ignore key: bhadra.pem
Permission denied (publickey,gssapi-keyex,gssapi-with-mic).
Thanks & Regards,
BADRAJ ANGIREKULA
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CANP%3DzZwR%2B0dHWsMdJgNQ2v7FSBtdUAYLdZTasu685gO%3Daq1xqA%40mail.gmail.com.